Tell Nixpack to include public folder in build
I have an Axum build on Rust that is are web socket chat rooms, which also serves static files. When I run the cargo locally everything is fine, but when I deploy to railway the routes all work fine, except for the static file route which I can only tell doesn't work because the Nixpack isn't placing the public folder within the directory. Do I need to manually build a Docker Image, and if so how do I get Railway to use my Docker Image instead of generating a new Image.
28 Replies
Project ID:
N/A
N/A
are you sure you don't have that folder in a gitignore?
yes all I had in the git ignore was target
are you using relative paths when you serve this folder?
I placed the public folder in src as well as externally
Well in rust its from the crate level
so relative to the crate yes
looks like there's a chance nixpacks is running just the built binary in a slim image, so it's possible the public folder isn't being copied to the final image
is it possible for you to just embed that folder into the binary?
I believe thats the case.
Its just html, css, and js so I have no idea
it's not clear to me on how to stop nixpacks from doing that, so I propose two options, embed the folder into the binary or write a dockerfile to deploy your app
If railway detects a Docker File it will use it automatically?
yep!
okay I'll get to it, by the way it may be wise to detech foldernames with static/public or other common static file folders and just load them into the build directory of the container
hey you know rust (I don't) so I'm sure that would be a welcome PR
(nixpacks is rust)
Lol I would love to but I'm not confident in my rust at all. This is actually my first project in it.
Just trying to deploy and show it off.
fair enough
But thanks.
https://github.com/railwayapp/nixpacks/blob/main/src/providers/rust.rs#L181
here's the logic for nixpacks on how it decides to run your binary in a slim image, maybe you can change some things around in your project to get it to stop running it in a slim image?
Alright I'll give it a look.
I don't mind making a docker image anyways, its not too hard.
Dockerfile*
yes, that's what i meant
Hey how do ports work with Nixpacks, do I just put any port as the env in the Dockerfile and will the Nixpack just be smart it enough to map it to the one they're supplying?
when using a dockerfile nixpacks is not used in anyway shape or form.
you do not need to specify any port in the dockerfile, you only need to have your app listen on the auto generated PORT variable
Well I just gave it 3000 and exposed 3000 and railway figured it out.
It works now.
https://wscr-rust-axum-production.up.railway.app/
// in case you would like to look
did you set a PORT variable in the service variables?
This all I've done. It just works, locally i need to -p port foward it to my computer which is what I thought would be needed to configure it with Railway but it just works
?
What are service variables
Like in railway the environment?
nvm, glad its working!
Lol, I didn't set any config in railway. Just deployed it.
One click per say.