Getting "Layer already exists" for project built with docker
My Docker image is working as expected locally, but it seems to be stuck on an older version on Railway. The build logs look fine, but when publishing the image there are a bunch of layer already exists errors.
My project id is: b74571d8-e862-4ac2-ad76-e19a69371a8e
Solution:Jump to solution
I honestly don't know. I think Cargo was doing some weird things. I simplified the Dockerfile to issue a single
cargo build --release
command.39 Replies
Project ID:
b74571d8-e862-4ac2-ad76-e19a69371a8e
Railway does layer caching if nothing in that layer has changed.
does this mean you are deploying with a Dockerfile?
Yes
please share the dockerfile
From a github repository
Ok I will share it when im back at my laptop
This is my Dockerfile
I might not be a rust dev by why is cargo build being ran twice?
The first time to install the dependencies, and the second one to build the application itself.
okay, odd given they are the exact same commands, rust sure loves ambiguity.
but what makes you think railway is not running the latest code?
Because it's printing hello world to the deploy logs and the http service is not running
My guess is a previous binary is being cached in one of those layers
if thats the case, set a variable
NO_CACHE=1
Ok, I'll try that
Setting NO_CACHE doesn't seem to have had any effect
I set it in the railway service, should I set it in other place?
show me how you are setting it
I can still see the messages saying the layers are cached
can you push an empty commit
Sure, but I already tried that as well
Just pushed
and what makes you think the http server isnt starting?
When I go to the generated domain I get "Application Failed to Respond"
https://rustbridge-reviews.up.railway.app/
Also it's weird that hello world its printed because that not in the code
how are you sure you are pushing code that runs an http server?
because im running the same code locally and it works
i can share the repo if it helps
i think it would be worth it
https://github.com/aloussase/rust-api-clean-architecture here's the code
GitHub
GitHub - aloussase/rust-api-clean-architecture: :crab: Demo API mad...
:crab: Demo API made in Rust for the Rust Bridge. Contribute to aloussase/rust-api-clean-architecture development by creating an account on GitHub.
show me the source of your service
GitHub
rust-api-clean-architecture/src/main.rs at master · aloussase/rust-...
:crab: Demo API made in Rust for the Rust Bridge. Contribute to aloussase/rust-api-clean-architecture development by creating an account on GitHub.
here you can see the server is set to run and there is no hello world being printed
full build logs please https://bookmarklets.up.railway.app/log-downloader/
Here you go
change the name of the binary thats being built?
Still the same thing sadly
try deploying the repo into a new service
Unfortunately, that doesnt seem to be working either
I think there is a problem with my Dockerfile, since I did a full rebuild now and it behaves same as railway
I'll investigate and report back
well I'm glad you came to that conclusion because you wouldn't have believed me if I told you it was an issue on your side
Yes, now the issue seems to be fixed. Thank you for your help!
haha you gotta tell me what the issue was
Solution
I honestly don't know. I think Cargo was doing some weird things. I simplified the Dockerfile to issue a single
cargo build --release
command.i knew that duplicate command was fishy