Ensure no cached images / layers are used in build?
jjmchew
PROOP

a year 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.

22 Replies

jjmchew
PROOP

a year 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.


a year ago

project id please


jjmchew
PROOP

a year ago

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


a year ago

what service in what environment?


jjmchew
PROOP

a year ago

staging environment for the "llm-staging" service


a year ago

do you mean launchschool-llm?


a year ago

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


a year 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
PROOP

a year ago

Thank you for confirming!


jjmchew
PROOP

a year ago

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


a year ago

yep!


jjmchew
PROOP

a year 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
PROOP

a year ago

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


a year ago

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


jjmchew
PROOP

a year ago

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


a year ago

are you running dockerfile or dockerfile.dev locally?


jjmchew
PROOP

a year 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.


a year ago

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


jjmchew
PROOP

a year ago

yes - good call


jjmchew
PROOP

a year 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!


a year ago

no problem!


a year ago

and good luck!


Welcome!

Sign in to your Railway account to join the conversation.

Loading...