a year ago
I get this error, it works fine on my PC:
112 Replies
a year ago
Oh god I remember this error
a year ago
It made me want to actually die inside
a year ago
Can you share your Dockerfile
a year ago
Sick
a year ago
Alright 1 sec
a year ago
You're going to be
a year ago
yeah yeah
a year ago
Make a file called Dockerfile in the root directory
FROM lukemathwalker/cargo-chef:latest-rust-1 AS chef
RUN cargo install cargo-chef
WORKDIR /app
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
COPY . .
RUN cargo build --release --bin binary
FROM debian:bookworm-slim AS runtime
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates && rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/target/release/binary /usr/local/bin/binary
CMD ["/usr/local/bin/binary"]a year ago
No file extension, just Dockerfile
a year ago
And throw that in it
a year ago
Docker is not something you use in a project lol
a year ago
It is a build tool
a year ago
Railway is currently generating a dockerfile for you (sorta)
a year ago
We're going to override it
a year ago
Made cargo-chef
a year ago
Better caching
a year ago
I can give you a simplified version without caching if you like but it makes build speeds wayyy faster
a year ago
are you serious
a year ago
can you confirm it says Dockerfile detected at the top of the build logs
a year ago
and not anything about Railpack
a year ago
can you screenshot the root dir again
a year ago
because if there is a dockerfile it should override that
a year ago
Dockerfile
a year ago
not DockerFile
a year ago
All lowercase :)
a year ago
sorry yeah Dockerfile
a year ago
not all lowercase
a year ago
Bluh
a year ago
Rename every instance of where I said binary with that
a year ago
Control f
a year ago
Leave instances of bin just replace the word binary
a year ago
Anywhere you see the word binary
a year ago
Replace it with axum_api_backend
a year ago
I had thought it was generic but apparently not :)
a year ago
😭
a year ago
Can you show your cargo file
maybe I gotta use github repo name like axum gituhb repo name? idk https://github.com/GetGoofy/axum_with_db_demo
a year ago
no no
a year ago
Oh lol get rid of that
think It used to give an error and that fixed idk, I will just rename it so it doesnt work on railway
a year ago
It won’t fix anything though
I googled this and found this error from somebody else and apparently I need to install some postgres stuff but how am I going to do that in Railway? idk https://forum.freecodecamp.org/t/libpq-so-5-cannot-open-shared-object-file-no-such-file-or-directory/473096
also this they mention something about debian distros: https://stackoverflow.com/questions/12781566/error-while-loading-shared-libraries-libpq-so-5-cannot-open-shared-object-file
a year ago
Let me modify the Dockerfile with that research in mind
a year ago
brb
a year ago
FROM lukemathwalker/cargo-chef:latest-rust-1 AS chef
RUN cargo install cargo-chef
WORKDIR /app
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
COPY . .
RUN cargo build --release --bin axum_api_backend
FROM debian:bookworm-slim AS runtime
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates python3-psycopg2 libpq-dev && rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/target/release/axum_api_backend /usr/local/bin/axum_api_backend
CMD ["/usr/local/bin/axum_api_backend"]but now i have this question: wtf do I even do when I find these crazy errors? just ask here and hope somebody knows, google, stack overflow? :S I guess idk
a year ago
What did here first is flip you to a system that I know works for me
a year ago
I use that exact Dockerfile for all my deployments
a year ago
Once I find that it doesn't work on what I know works, I branch out and look at specific issues
a year ago
You did exactly what I would have done by googling it
a year ago
Then I took that answer and applied it to the Dockerfile
a year ago
And boom
Status changed to Solved chandrika • 11 months ago











