-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
36 lines (27 loc) · 1005 Bytes
/
Dockerfile
File metadata and controls
36 lines (27 loc) · 1005 Bytes
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
FROM rust:1.93-slim AS chef
RUN cargo install cargo-chef --locked
RUN apt-get update && apt-get install -y pkg-config libssl-dev && rm -rf /var/lib/apt/lists/*
WORKDIR /app
FROM chef AS planner
COPY Cargo.toml Cargo.lock* ./
COPY src/ src/
COPY scripts/ scripts/
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder
COPY --from=planner /app/recipe.json recipe.json
# 只有 Cargo.lock 變動時才重新編譯依賴
RUN cargo chef cook --release --recipe-path recipe.json
COPY Cargo.toml Cargo.lock* ./
COPY src/ src/
COPY scripts/ scripts/
COPY migrations/ migrations/
RUN cargo build --release --bin coscup-newsletter
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y ca-certificates libssl3 && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=builder /app/target/release/coscup-newsletter /app/coscup-newsletter
COPY src/templates/ /app/src/templates/
COPY migrations/ /app/migrations/
COPY static/ /app/static/
EXPOSE 8080
CMD ["/app/coscup-newsletter"]