8 months ago
I get this error, it works fine on my PC:
112 Replies
8 months ago
Oh god I remember this error
8 months ago
It made me want to actually die inside
8 months ago
Can you share your Dockerfile
8 months ago
Sick
8 months ago
Alright 1 sec
8 months ago
You're going to be
8 months ago
yeah yeah
8 months 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"]8 months ago
No file extension, just Dockerfile
8 months ago
And throw that in it
8 months ago
Docker is not something you use in a project lol
8 months ago
It is a build tool
8 months ago
Railway is currently generating a dockerfile for you (sorta)
8 months ago
We're going to override it
8 months ago
Made cargo-chef
8 months ago
Better caching
8 months ago
I can give you a simplified version without caching if you like but it makes build speeds wayyy faster
8 months ago
are you serious
8 months ago
can you confirm it says Dockerfile detected at the top of the build logs
8 months ago
and not anything about Railpack
8 months ago
can you screenshot the root dir again
8 months ago
because if there is a dockerfile it should override that
8 months ago
Dockerfile
8 months ago
not DockerFile
8 months ago
All lowercase :)
8 months ago
sorry yeah Dockerfile
8 months ago
not all lowercase
8 months ago
Bluh
8 months ago
Rename every instance of where I said binary with that
8 months ago
Control f
8 months ago
Leave instances of bin just replace the word binary
8 months ago
Anywhere you see the word binary
8 months ago
Replace it with axumapibackend
8 months ago
I had thought it was generic but apparently not :)
8 months ago
😭
8 months ago
Can you show your cargo file
maybe I gotta use github repo name like axum gituhb repo name? idk https://github.com/GetGoofy/axumwithdb_demo
8 months ago
no no
8 months 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
8 months 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
8 months ago
Let me modify the Dockerfile with that research in mind
8 months ago
brb
8 months 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
8 months ago
What did here first is flip you to a system that I know works for me
8 months ago
I use that exact Dockerfile for all my deployments
8 months ago
Once I find that it doesn't work on what I know works, I branch out and look at specific issues
8 months ago
You did exactly what I would have done by googling it
8 months ago
Then I took that answer and applied it to the Dockerfile
8 months ago
And boom
Status changed to Solved chandrika • 8 months ago











