Skip to content

Commit

Permalink
Fix to use cargo-chef
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Apr 30, 2024
1 parent 25b3e3d commit 36ca097
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
FROM rust:1.77-alpine as builder

WORKDIR /usr/src/genuuid
FROM rust:1.77-alpine AS chef
RUN apk update && apk add --no-cache musl-dev
COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml
RUN mkdir src/
RUN touch src/lib.rs
RUN cargo build --release --target=x86_64-unknown-linux-musl
WORKDIR /app
RUN cargo install cargo-chef --locked

FROM chef AS planner
COPY . .
RUN cargo install --path . --target=x86_64-unknown-linux-musl
RUN cargo chef prepare --recipe-path recipe.json

FROM chef AS cacher
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --recipe-path recipe.json --release --target=x86_64-unknown-linux-musl

FROM chef AS builder
COPY . .
COPY --from=cacher /app/target target
RUN cargo build --release --target=x86_64-unknown-linux-musl

FROM scratch
LABEL org.opencontainers.image.source https://github.com/bouzuya/genuuid
ENV PORT=8080
COPY --from=builder /usr/local/cargo/bin/genuuid /usr/local/bin/genuuid
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/genuuid /usr/local/bin/genuuid
ENTRYPOINT ["genuuid"]

0 comments on commit 36ca097

Please sign in to comment.