diff --git a/Dockerfile b/Dockerfile index 22f741f..16870d3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,26 @@ -FROM rust:1.70-slim +FROM rust:1.67 as builder -RUN apt-get update && \ - apt-get install -y clang cmake build-essential +WORKDIR /usr/src/app +COPY . . -WORKDIR /app +# Will build and cache the binary and dependent crates in release mode +RUN --mount=type=cache,target=/usr/local/cargo,from=rust:latest,source=/usr/local/cargo \ + --mount=type=cache,target=target \ + cargo build --release && mv ./target/release/mutinynet-faucet-rs ./mutinynet-faucet-rs -COPY . . +# Runtime image +FROM debian:bookworm-slim + +RUN apt update && apt install -y openssl libpq-dev pkg-config libc6 clang cmake build-essential + +# Run as "app" user +RUN useradd -ms /bin/bash app + +USER app +WORKDIR /app -RUN cargo build --release +# Get compiled binaries from builder's cargo install directory +COPY --from=builder /usr/src/app/mutinynet-faucet-rs /app/mutinynet-faucet-rs -ENTRYPOINT ["/bin/bash", "-c", "./target/release/mutinynet-faucet-rs ${FLAGS}"] +# Run the app +CMD ./mutinynet-faucet-rs