-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
110 lines (84 loc) · 3.88 KB
/
Copy pathDockerfile
File metadata and controls
110 lines (84 loc) · 3.88 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# Build stage - use nightly for edition2024 support
FROM rustlang/rust:nightly-bookworm AS builder
WORKDIR /app
# Install build dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
# ── Dependency caching layer ──────────────────────────────────────────
# Copy only manifests first so that `cargo build` fetches and compiles
# all third-party crates. This layer is cached until Cargo.toml/lock
# change, saving minutes on incremental rebuilds.
COPY Cargo.toml Cargo.lock ./
COPY crates/olympus-common/Cargo.toml crates/olympus-common/Cargo.toml
COPY crates/olympus-rules/Cargo.toml crates/olympus-rules/Cargo.toml
COPY crates/vanguard/Cargo.toml crates/vanguard/Cargo.toml
COPY crates/sisyphus/Cargo.toml crates/sisyphus/Cargo.toml
COPY crates/minos/Cargo.toml crates/minos/Cargo.toml
COPY crates/horus/Cargo.toml crates/horus/Cargo.toml
# Create dummy source files so cargo can resolve the workspace and
# compile all dependencies without the real source code.
RUN mkdir -p crates/olympus-common/src && echo "pub fn _dummy(){}" > crates/olympus-common/src/lib.rs \
&& mkdir -p crates/olympus-rules/src && echo "pub fn _dummy(){}" > crates/olympus-rules/src/lib.rs \
&& mkdir -p crates/vanguard/src && echo "fn main(){}" > crates/vanguard/src/main.rs \
&& mkdir -p crates/sisyphus/src && echo "fn main(){}" > crates/sisyphus/src/main.rs \
&& mkdir -p crates/minos/src && echo "fn main(){}" > crates/minos/src/main.rs \
&& mkdir -p crates/horus/src && echo "fn main(){}" > crates/horus/src/main.rs
RUN cargo build --release --workspace
# ── Real source build ─────────────────────────────────────────────────
# Remove the dummy sources and copy the real code. Only our crates are
# recompiled; all dependencies stay cached from the layer above.
RUN rm -rf crates/
COPY crates/ crates/
# Touch source files so cargo sees them as newer than the dummy artifacts.
RUN find crates/ -name "*.rs" -exec touch {} +
# Build all binaries in release mode
RUN cargo build --release --workspace
# Runtime stage for Vanguard (API Gateway)
FROM debian:bookworm-slim AS vanguard
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
curl \
docker.io \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/target/release/vanguard /usr/local/bin/vanguard
ENV RUST_LOG=vanguard=info,sqlx=warn
EXPOSE 8080
CMD ["vanguard"]
# Runtime stage for Sisyphus (Compiler)
FROM debian:bookworm-slim AS sisyphus
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
docker.io \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/target/release/sisyphus /usr/local/bin/sisyphus
ENV RUST_LOG=sisyphus=info,sqlx=warn
CMD ["sisyphus"]
# Runtime stage for Minos (Judge)
# Needs:
# - C/C++ runtime libs for executing uploaded problem binaries (generators/checkers)
# that may have been compiled with modern GCC (17+)
# - Interpreters for languages that don't produce standalone binaries (Python, etc.)
FROM ubuntu:24.04 AS minos
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
libssl3t64 \
g++ \
python3 \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/target/release/minos /usr/local/bin/minos
ENV RUST_LOG=minos=info,sqlx=warn
EXPOSE 9091
CMD ["minos"]
# Runtime stage for Horus (Cleaner)
FROM debian:bookworm-slim AS horus
RUN apt-get update && apt-get install -y \
ca-certificates \
libssl3 \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/target/release/horus /usr/local/bin/horus
ENV RUST_LOG=horus=info,sqlx=warn
CMD ["horus"]