-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
37 lines (32 loc) · 994 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
28
29
30
31
32
33
34
35
36
37
## Base Image with dependencies + Cargo Chef
FROM rust:1.81-slim-bullseye AS base
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
RUN cargo install cargo-chef --version ^0.1
## Cache stage using Cargo Chef to generate recipe
FROM base AS cache
WORKDIR /app
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
## Builder base stage
FROM base AS builder
WORKDIR /app
COPY --from=cache /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
## Build Debug Mode
FROM builder AS build-debug
WORKDIR /app
COPY . .
RUN cargo build
CMD ["/app/target/debug/discord-ani-schedule"]
## Build Production Mode
FROM builder AS build-prod
WORKDIR /app
COPY . .
RUN RUSTFLAGS="-C link-arg=-s" cargo build --locked --no-default-features --release
## Release Stage
FROM gcr.io/distroless/cc-debian12 AS release
COPY --from=build-prod /app/target/release/discord-ani-schedule /
CMD ["./discord-ani-schedule"]