Skip to content

Commit 39adde6

Browse files
authored
fix: orion-server & mono dockerfile cache (#2049)
1 parent f009074 commit 39adde6

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

mono/Dockerfile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,16 @@ COPY saturn ./saturn
7474
COPY vault ./vault
7575

7676
# Build the mono binary (fixed release)
77-
RUN cargo build --release -p mono
77+
#
78+
# NOTE: Build output must be persisted into the image layer for the runtime stage `COPY`.
79+
# A buildkit cache mount is not committed into the layer, so we build into a cached dir
80+
# then copy the final binary into `/opt/mega/target/...` (regular filesystem).
81+
RUN --mount=type=cache,target=/usr/local/cargo/registry \
82+
--mount=type=cache,target=/usr/local/cargo/git \
83+
--mount=type=cache,target=/opt/mega/target-cache \
84+
CARGO_TARGET_DIR=/opt/mega/target-cache cargo build --release -p mono && \
85+
mkdir -p /opt/mega/target/release && \
86+
cp /opt/mega/target-cache/release/mono /opt/mega/target/release/mono
7887

7988

8089
# ---------- runtime stage ----------

orion-server/Dockerfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,15 @@ RUN --mount=type=cache,target=/usr/local/cargo/registry \
4444
COPY . .
4545

4646
# -- Step 2: build binary into normal target directory
47-
ENV CARGO_TARGET_DIR=/app/target
47+
# NOTE: build output must be persisted into the image layer for the runtime stage `COPY`.
48+
# A buildkit cache mount is not committed into the layer, so we build into a cached dir
49+
# then copy the final binary into `/app/target/...` (regular filesystem).
4850
RUN --mount=type=cache,target=/usr/local/cargo/registry \
4951
--mount=type=cache,target=/usr/local/cargo/git \
50-
--mount=type=cache,target=/app/target \
51-
cargo build -p orion-server --release
52+
--mount=type=cache,target=/app/target-cache \
53+
CARGO_TARGET_DIR=/app/target-cache cargo build -p orion-server --release && \
54+
mkdir -p /app/target/release && \
55+
cp /app/target-cache/release/orion-server /app/target/release/orion-server
5256

5357
# ────── Stage 3: Runtime ──────
5458
FROM debian:bookworm-slim

0 commit comments

Comments
 (0)