diff --git a/Dockerfile b/Dockerfile index 9c78d16..f69ae64 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,8 @@ FROM rust:1.85-slim-bookworm AS build +# get x86_64-unknown-linux-musl as a build target +RUN rustup target add x86_64-unknown-linux-musl + # create a new empty shell project RUN USER=root cargo new --bin http_server WORKDIR /http_server @@ -18,12 +21,13 @@ COPY ./src ./src # build for release as a static-pie linked binary RUN rm ./target/release/deps/http_server* ENV RUSTFLAGS='-C target-feature=+crt-static' -RUN cargo build --release --target x86_64-unknown-linux-gnu +RUN cargo build --release --target x86_64-unknown-linux-musl +RUN strip /http_server/target/x86_64-unknown-linux-musl/release/http_server FROM scratch # copy the build artifact from the build stage -COPY --from=build /http_server/target/x86_64-unknown-linux-gnu/release/http_server / +COPY --from=build /http_server/target/x86_64-unknown-linux-musl/release/http_server / COPY ./www /www EXPOSE 8080