Skip to content

Commit

Permalink
Staged dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Oct 1, 2023
1 parent dd8fa19 commit d848b9e
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d848b9e

Please sign in to comment.