forked from hubble459/fiars
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
27 lines (23 loc) · 784 Bytes
/
Dockerfile
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
# (1) installing cargo-chef & build deps
FROM rust:alpine AS chef
WORKDIR /app
RUN apk add --no-cache musl-dev openssl-dev upx
RUN cargo install --locked cargo-chef
# (2) preparing recipe file
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
# (3) building project deps, cache magic happen on COPY command
FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --recipe-path recipe.json --release
# (4) actual project build
COPY . .
RUN cargo build -r
RUN strip /app/target/release/fiars
RUN upx --ultra-brute --no-lzma /app/target/release/fiars
# (5) runtime image, you can use any base image you want
FROM scratch AS runtime
WORKDIR /app
COPY --from=builder /app/target/release/fiars /app/fiars
CMD ["/app/fiars"]