R
Railway

✋|help

Tell Nixpack to include public folder in build

YYoPassIt9/7/2023
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.
YYoPassIt9/7/2023
N/A
BBrody9/7/2023
are you sure you don't have that folder in a gitignore?
YYoPassIt9/7/2023
yes all I had in the git ignore was target
BBrody9/7/2023
are you using relative paths when you serve this folder?
YYoPassIt9/7/2023
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
BBrody9/7/2023
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?
YYoPassIt9/7/2023
I believe thats the case. Its just html, css, and js so I have no idea
BBrody9/7/2023
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
YYoPassIt9/7/2023
If railway detects a Docker File it will use it automatically?
BBrody9/7/2023
yep!
YYoPassIt9/7/2023
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
BBrody9/7/2023
hey you know rust (I don't) so I'm sure that would be a welcome PR (nixpacks is rust)
YYoPassIt9/7/2023
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.
BBrody9/7/2023
fair enough
YYoPassIt9/7/2023
But thanks.
BBrody9/7/2023
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?
YYoPassIt9/7/2023
Alright I'll give it a look. I don't mind making a docker image anyways, its not too hard.
BBrody9/7/2023
Dockerfile*
YYoPassIt9/7/2023
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?
BBrody9/7/2023
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
YYoPassIt9/7/2023
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
BBrody9/7/2023
did you set a PORT variable in the service variables?
YYoPassIt9/7/2023
FROM rust:1.72-alpine AS build

WORKDIR /app

COPY . .

RUN apk add --no-cache musl-dev openssl-dev
RUN cargo build --release

COPY ./public ./public

RUN cargo install --path .
RUN cargo build --release

ENV PORT=3000
EXPOSE 3000

CMD ["./target/release/wscr"]
FROM rust:1.72-alpine AS build

WORKDIR /app

COPY . .

RUN apk add --no-cache musl-dev openssl-dev
RUN cargo build --release

COPY ./public ./public

RUN cargo install --path .
RUN cargo build --release

ENV PORT=3000
EXPOSE 3000

CMD ["./target/release/wscr"]
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
BBrody9/7/2023
?
YYoPassIt9/7/2023
What are service variables Like in railway the environment?
BBrody9/7/2023
nvm, glad its working!
YYoPassIt9/7/2023
Lol, I didn't set any config in railway. Just deployed it. One click per say.

Looking for more? Join the community!

Want results from more Discord servers?
Add your server
Recommended Posts
.NET 6.0 Deployment Failed during build processProject ID f8a04cde-c088-4000-923e-0de1e0d144aa I can not deploy my backend, this is the error NETSMonorepoIf I am inside monorepo how will assigning domain work I wanna asign domain in two aspectsI can not deploy angular project, killedI do not know what is the problem I hope someone can help me, Project ID dd70810d-29a4-4c5e-b7b4-f2NPM ssh dependancyHi I'm running into an issue where I'm using a private github npm dependancy and the build step is How to set mailgun to Ghost(docker) + SqliteI had used Ghost with mysql, but currently I try to use a new Ghost template with Sqlite. I did not Timeout while waiting for registry?All of my deploys have been building successfully but failing to deploy for the past ~hour or so. TContainer is failing to start.Everything was working fine, I just added a few new features to the app and now it is failing to depSeeing failures in deploying saying container shut down, but cannot find the container logs.Need help figuring out how to debug this issue with deploying to prod. From my end I don't think theHow to Delete Project?How do I delete a project I created so it doesn't show up in my homepage? Railway's documentation juInitial Deployment Continues To FailHello everyone. I am trying to setup, and stuck at the starting line. All ive done is connect githubDeployments sometimes takes timeMany times deployments take more than 5 minutes, although it should take less than 1 minute.Sveltekit memory usagemy sveltekit apps are almost locked to 100mb memory, anyone knows if theres like an option or somethOpen SourceHi, I am Richard, creator of ExpressoTS framework. Currently we are working in a section of our docuDifficulty with deploying a Flask + React appHi - I have a code architecture with a Flask backend (python) and a Node React frontend. The architeAny way to measure API Metrics for APIs deployed via Railwaythe no. of requests, the avg response timeMultiple accounts with same Github account?Can I somehow have multiple accounts but use code from the same Github account? I want to have a sepCan't create accountI try to signup using email but only get this error: "Device requesting login is not supported pleaRedis Data not showing up. Also not able set the key as well from redis-cliI am not able to access redis via the Console of railway as well not set any key via redis cliregion is only exclusive for pro plan?i'm planning to subscribe to hobby plan because it's more fit for me but my only concern is that i cServer is not builtUntil last night at 2am I sent a PR and the server was updated this morning, I hired a professional