Skip to content
Ensure no cached images / layers are used in build?
jjmchew
OP

2 years ago

How can I make sure that no cached layers or images are being used when I build my Dockerfile for deployment? Does nixpacks build using a docker build command? (i.e., can I specify --no-cache specifically as part of a custom build command?)

I've already included both "NO_CACHE=1" and "NIXPACKS_NO_CACHE=1" (found both in online docs/responses) in my environment variables. I don't believe there are any flags or arguments that can be set in the Dockerfile itself.

----- Why am I asking?

Essentially, I'm encountering build errors in railway that I previously saw locally, likely caused by a change in my npm packages (ts project). I fixed those errors locally by deleting saved docker images and node_modules, new npm install and re-building the docker image - no more local issues.

Now encountering the same errors in railway, I'm re-tracing my steps, but realizing a lot happens on railway build that I don't quite understand. I'd like to be certain that I'm re-building the image and layers from scratch.

Closed

22 Replies

jjmchew
OP

2 years ago

Update - Railway may be using buildkit and not nixpacks - I'm not entirely certain.

I have a Dockerfile in the project github repo and we auto-deploy to railway based on updates to the 'main' branch. I believe images are being built by Railway and used for deployment since I can see the build occuring in the Railway build logs.


2 years ago

project id please


jjmchew
OP

2 years ago

1f52990d-cb46-47dc-9488-761f8b7abea5


2 years ago

what service in what environment?


jjmchew
OP

2 years ago

staging environment for the "llm-staging" service


2 years ago

do you mean launchschool-llm?


2 years ago

first off, you are using a dockerfile, so anything nixpacks related to is not applicable


2 years ago

for your context, that variable does exactly what you want, and i can confirm that your build was done without any layer cache

1367153277732655214


jjmchew
OP

2 years ago

Thank you for confirming!


jjmchew
OP

2 years ago

So the docker image used for deployment is always built from scratch with that "NO_CACHE = 1" variable?


2 years ago

yep!


jjmchew
OP

2 years ago

Then I'm stumped...... any other ideas why I would be getting build errors in railway, but no longer in my own local environment?


jjmchew
OP

2 years ago

Is it possible to access a CLI within the environment to confirm install package versions, etc?


2 years ago

yes, but in this case, no, you need something running otherwise there is nothing to ssh into


jjmchew
OP

2 years ago

right - since build failed, I can't inspect that build.


2 years ago

are you running dockerfile or dockerfile.dev locally?


jjmchew
OP

2 years ago

Typically we run dockerfile.dev for local environments, but I ran the dockerfile locally to test - i.e., built from dockerfile and used that as part of local environment. It seemed to work.


2 years ago

delete the entire project locally, then re-pull it, and try again


jjmchew
OP

2 years ago

yes - good call


jjmchew
OP

2 years ago

FWIW, those same errors are occurring locally again, so there's no escaping the need to get to the root of them.

Thanks for your help!


2 years ago

no problem!


2 years ago

and good luck!


Welcome!

Sign in to your Railway account to join the conversation.

Loading...