FROM rust:latest as builder ENV CONTAINER=true RUN USER=root mkdir /config RUN USER=root cargo new --bin {ProjectName} WORKDIR /{ProjectName} COPY Cargo.lock ./Cargo.lock COPY Cargo.toml ./Cargo.toml RUN cargo build --release RUN rm ./src/*.rs RUN rm ./target/release/deps/{ProjectName_DashesToUnderscores}* COPY src ./src RUN cargo build --release FROM debian:bullseye-slim as runner RUN mkdir -p /config COPY --from=builder /{ProjectName}/target/release/{ProjectName_DashesToUnderscores} /usr/bin/{ProjectName} VOLUME [ "/config" ] ENTRYPOINT [ "{ProjectName}" ]