Skip to content

Commit

Permalink
πŸ§‘β€πŸ³ docker cargo-chef
Browse files Browse the repository at this point in the history
  • Loading branch information
FelipeFTN committed Jan 27, 2024
1 parent 6e4d036 commit 083c34d
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions docker/backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
# Rust official image
FROM rust:1.67-slim
FROM rust:1 AS chef

# Copy from machine to docker
WORKDIR /usr/src/warfrost
RUN cargo install cargo-chef --locked
WORKDIR app

FROM chef as planner
COPY --from=warfrost . .

# Set Environment Variables
ENV PORT=8080
ENV HOST=0.0.0.0

# Build program for release
RUN cargo build --release
RUN cargo chef prepare --recipe-path recipe.json

FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json

RUN cargo chef cook --release --recipe-path recipe.json

COPY --from=warfrost . .
RUN cargo build --release --bin warfrost

# Run the binary
CMD ["./target/release/warfrost"]
FROM debian:bookworm-slim AS runtime
WORKDIR app
COPY --from=builder /app/target/release/warfrost /usr/local/bin
ENTRYPOINT ["/usr/local/bin/warfrost"]

0 comments on commit 083c34d

Please sign in to comment.