-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathDockerfile
More file actions
43 lines (27 loc) · 1.28 KB
/
Copy pathDockerfile
File metadata and controls
43 lines (27 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Stage 1: Chef (base image with cargo-chef installed)
FROM lukemathwalker/cargo-chef:latest-rust-alpine AS chef
RUN apk add --no-cache musl-dev git
RUN rustup target add x86_64-unknown-linux-musl
WORKDIR /app
# Stage 2: Planner — compute the dependency recipe from the workspace
FROM chef AS planner
COPY Cargo.toml Cargo.lock ./
COPY crates/ ./crates/
RUN cargo chef prepare --recipe-path recipe.json
# Stage 3: Build — cook dependencies first (cached layer), then build source
FROM chef AS build
COPY --from=planner /app/recipe.json recipe.json
# Build dependencies only; this layer is cached unless Cargo.toml/Cargo.lock change
RUN cargo chef cook --release --target x86_64-unknown-linux-musl --package clausura-cli --recipe-path recipe.json
# Copy the actual source and build the binary as a static musl binary
COPY Cargo.toml Cargo.lock ./
COPY crates/ ./crates/
RUN cargo build --release --target x86_64-unknown-linux-musl --package clausura-cli
# Stage 4: Runtime
FROM alpine:latest
RUN apk add --no-cache ca-certificates git
LABEL org.opencontainers.image.source="https://github.com/liuyanghejerry/Clausura"
COPY --from=build /app/target/x86_64-unknown-linux-musl/release/clausura /usr/local/bin/clausura
WORKDIR /workspace
ENTRYPOINT ["/usr/local/bin/clausura"]
CMD ["--help"]