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

10 months 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 "NOCACHE=1" and "NIXPACKSNO_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

10 months 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.


brody
EMPLOYEE

10 months ago

project id please


jjmchew
PROOP

10 months ago

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


brody
EMPLOYEE

10 months ago

what service in what environment?


jjmchew
PROOP

10 months ago

staging environment for the "llm-staging" service


brody
EMPLOYEE

10 months ago

do you mean launchschool-llm?


brody
EMPLOYEE

10 months ago

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


brody
EMPLOYEE

10 months ago

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

1367153277732655000


jjmchew
PROOP

10 months ago

Thank you for confirming!


jjmchew
PROOP

10 months ago

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


brody
EMPLOYEE

10 months ago

yep!


jjmchew
PROOP

10 months 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

10 months ago

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


brody
EMPLOYEE

10 months ago

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


jjmchew
PROOP

10 months ago

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


brody
EMPLOYEE

10 months ago

are you running dockerfile or dockerfile.dev locally?


jjmchew
PROOP

10 months 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.


brody
EMPLOYEE

10 months ago

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


jjmchew
PROOP

10 months ago

yes - good call


jjmchew
PROOP

10 months 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!


brody
EMPLOYEE

10 months ago

no problem!


brody
EMPLOYEE

10 months ago

and good luck!


Loading...