Axum in docker fails returns 404 but cargo run works fine #2577
Replies: 4 comments 8 replies
-
I'm not very good at docker so I recommend asking in a broader forum. Perhaps https://users.rust-lang.org/ |
Beta Was this translation helpful? Give feedback.
-
One last thing I have noticed is that the docker container cannot be killed, it hangs. |
Beta Was this translation helpful? Give feedback.
-
Based on the initial post I chenged firstly the dependencies a little bit in the [dependencies]
# ...
# common = {path = "../common"}
common = { git = "https://github.com/federal-courts-software-factory/open-case-filing-system.git" }
# ... And I used this ARG PACKAGE="web"
# Build container
FROM lukemathwalker/cargo-chef:latest-rust-1 AS chef
WORKDIR /build
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder
COPY --from=planner /build/recipe.json recipe.json
# Build dependencies - this is the caching Docker layer!
RUN cargo chef cook --release --recipe-path recipe.json
# Build application
ARG PACKAGE
COPY . .
RUN cargo build --release --bin $PACKAGE
# Final image
FROM debian:stable-slim
# installing nativetls dependencies
# RUN apt-get update && \
# apt-get install -y openssl libssl-dev ca-certificates && \
# rm -rf /var/lib/apt/lists/*
WORKDIR /app
ARG PACKAGE
COPY --from=builder /build/target/release/$PACKAGE /app/$PACKAGE
COPY --from=builder /build/dist/ /app/dist/
# Running
EXPOSE 3000
CMD ["./web"] This worked for me. The |
Beta Was this translation helpful? Give feedback.
-
the reason is you did not copy your assets files like |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Bug Report
I'm not able to access axum server from inside of a docker container.
Version
├── axum v0.7.4
│ ├── axum-core v0.4.3
Platform
Linux f44bf27f15bb 6.6.12-linuxkit #1 SMP Fri Jan 19 08:53:17 UTC 2024 aarch64 GNU/Linux
or M2 Pro
uname -r
23.3.0
Crates
Description
main.rs
route.rs
Dockerfile
Docker cmd
docker run -p 0.0.0.0:3000:3000 ghcr.io/federal-courts-software-factory/open-case-filing-system/web@sha256:f9aca3996cf60553d26907d3e987ba0fd654011e1b18f3e99078045e99b13215
Docker output:
2024-02-08T05:52:32.006717Z INFO web: hello, web server! ->> LISTENING on Ok(0.0.0.0:3000)
Cargo run works as expected with the index.html being served as expected.
Beta Was this translation helpful? Give feedback.
All reactions