Skip to content

Commit 09f9ee8

Browse files
committed
chore(engine): publish engine bases in ci
1 parent 258991d commit 09f9ee8

8 files changed

Lines changed: 203 additions & 83 deletions

File tree

.github/actions/docker-setup/action.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: 'Docker Setup'
2-
description: 'Set up Docker Buildx and log in to Docker Hub'
2+
description: 'Set up Docker Buildx and log in to Docker Hub and GHCR'
33
inputs:
44
docker_username:
55
description: 'Docker Hub username'
@@ -22,11 +22,17 @@ runs:
2222
username: ${{ inputs.docker_username }}
2323
password: ${{ inputs.docker_password }}
2424

25+
- name: Log in to ghcr.io
26+
uses: docker/login-action@v3
27+
with:
28+
registry: ghcr.io
29+
username: ${{ github.actor }}
30+
password: ${{ inputs.github_token }}
31+
2532
# This will be used as a secret to authenticate with Git repo pulls
2633
- name: Create .netrc file
2734
run: |
2835
echo "machine github.com" > ${{ runner.temp }}/netrc
2936
echo "login x-access-token" >> ${{ runner.temp }}/netrc
3037
echo "password ${{ inputs.github_token }}" >> ${{ runner.temp }}/netrc
3138
shell: bash
32-

.github/workflows/publish.yaml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,43 @@ jobs:
236236
path: artifacts/${{ matrix.artifact }}
237237
if-no-files-found: error
238238

239+
# ---------------------------------------------------------------------------
240+
# engine-base-images — publish engine-specific GHCR bases for this commit SHA
241+
# ---------------------------------------------------------------------------
242+
engine-base-images:
243+
needs: [context]
244+
name: "Engine Base ${{ matrix.base }}"
245+
if: needs.context.outputs.is_fork != 'true'
246+
strategy:
247+
fail-fast: false
248+
matrix:
249+
include:
250+
- base: engine-builder
251+
- base: engine-runtime-full
252+
- base: engine-runtime-slim
253+
runs-on: ubuntu-24.04
254+
permissions:
255+
contents: read
256+
packages: write
257+
steps:
258+
- uses: actions/checkout@v4
259+
- uses: docker/setup-buildx-action@v3
260+
- name: Log in to ghcr.io
261+
uses: docker/login-action@v3
262+
with:
263+
registry: ghcr.io
264+
username: ${{ github.actor }}
265+
password: ${{ secrets.GITHUB_TOKEN }}
266+
- name: Build & Push Engine Base
267+
run: |
268+
TAG_OVERRIDE=${{ needs.context.outputs.sha }} \
269+
./scripts/docker-builder-base/build-push.sh ${{ matrix.base }} --push
270+
239271
# ---------------------------------------------------------------------------
240272
# docker-images — per-arch runtime images pushed to Docker Hub
241273
# ---------------------------------------------------------------------------
242274
docker-images:
243-
needs: [context]
275+
needs: [context, engine-base-images]
244276
name: "Docker ${{ matrix.arch_suffix }}"
245277
if: needs.context.outputs.is_fork != 'true'
246278
strategy:
@@ -283,6 +315,7 @@ jobs:
283315
target: engine-full
284316
platforms: ${{ matrix.platform }}
285317
build-args: |
318+
ENGINE_BASE_TAG=${{ needs.context.outputs.sha }}
286319
BUILD_FRONTEND=${{ steps.mode.outputs.build_frontend }}
287320
CARGO_BUILD_MODE=${{ steps.mode.outputs.cargo_build_mode }}
288321
- name: Build & Push (rivetdev/engine:slim)
@@ -295,6 +328,7 @@ jobs:
295328
target: engine-slim
296329
platforms: ${{ matrix.platform }}
297330
build-args: |
331+
ENGINE_BASE_TAG=${{ needs.context.outputs.sha }}
298332
BUILD_FRONTEND=${{ steps.mode.outputs.build_frontend }}
299333
CARGO_BUILD_MODE=${{ steps.mode.outputs.cargo_build_mode }}
300334

CLAUDE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ cd self-host/compose/dev
7676
docker-compose up -d
7777
```
7878

79+
- Rebuild publish base images with `scripts/docker-builder-base/build-push.sh <base-name|all> --push`; update `BASE_TAG` when rebuilding shared builder bases, while engine bases are published per commit in `publish.yaml`.
80+
7981
### Git Commands
8082
```bash
8183
# Use conventional commits with a single-line commit message, no co-author
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# syntax=docker/dockerfile:1.10.0
2+
# Base image for Linux engine container builds.
3+
# Pre-bakes Rust, Node.js 22, corepack, build dependencies, and the
4+
# FoundationDB client library for each target architecture.
5+
#
6+
# Build & push: scripts/docker-builder-base/build-push.sh engine-builder --push
7+
FROM mcr.microsoft.com/devcontainers/rust:1-1-bookworm
8+
9+
ARG TARGETARCH
10+
11+
ENV DEBIAN_FRONTEND=noninteractive
12+
RUN apt-get update -y && \
13+
apt-get install -y --no-install-recommends \
14+
ca-certificates \
15+
cmake \
16+
curl \
17+
g++ \
18+
git \
19+
gpg \
20+
libclang-dev \
21+
libpq-dev \
22+
libssl-dev \
23+
make \
24+
openssl \
25+
pkg-config \
26+
wget && \
27+
rustup toolchain install 1.91.0 && \
28+
rustup default 1.91.0 && \
29+
curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
30+
apt-get install -y --no-install-recommends nodejs && \
31+
corepack enable && \
32+
rm -rf /var/lib/apt/lists/* && \
33+
if [ "$TARGETARCH" = "arm64" ]; then \
34+
curl -Lf -o /lib/libfdb_c.so "https://github.com/apple/foundationdb/releases/download/7.3.68/libfdb_c.aarch64.so"; \
35+
else \
36+
curl -Lf -o /lib/libfdb_c.so "https://github.com/apple/foundationdb/releases/download/7.3.68/libfdb_c.x86_64.so"; \
37+
fi
38+
39+
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true \
40+
COREPACK_ENABLE_DOWNLOAD_PROMPT=0
41+
42+
WORKDIR /app
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# syntax=docker/dockerfile:1.10.0
2+
# Base image for the full Linux engine runtime image.
3+
#
4+
# Build & push: scripts/docker-builder-base/build-push.sh engine-runtime-full --push
5+
FROM mcr.microsoft.com/devcontainers/base:debian
6+
7+
ARG TARGETARCH
8+
9+
ENV DEBIAN_FRONTEND=noninteractive
10+
RUN apt-get update -y && \
11+
apt-get install -y --no-install-recommends \
12+
ca-certificates \
13+
curl \
14+
dirmngr \
15+
gpg \
16+
openssl && \
17+
apt-get clean && \
18+
rm -rf /var/lib/apt/lists/* && \
19+
if [ "$TARGETARCH" = "arm64" ]; then \
20+
curl -Lf -o /lib/libfdb_c.so "https://github.com/apple/foundationdb/releases/download/7.3.68/libfdb_c.aarch64.so"; \
21+
else \
22+
curl -Lf -o /lib/libfdb_c.so "https://github.com/apple/foundationdb/releases/download/7.3.68/libfdb_c.x86_64.so"; \
23+
fi
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# syntax=docker/dockerfile:1.10.0
2+
# Base image for the slim Linux engine runtime image.
3+
#
4+
# Build & push: scripts/docker-builder-base/build-push.sh engine-runtime-slim --push
5+
FROM mcr.microsoft.com/devcontainers/base:debian
6+
7+
ARG TARGETARCH
8+
9+
ENV DEBIAN_FRONTEND=noninteractive
10+
RUN apt-get update -y && \
11+
apt-get install -y --no-install-recommends \
12+
ca-certificates \
13+
curl \
14+
openssl && \
15+
apt-get clean && \
16+
rm -rf /var/lib/apt/lists/* && \
17+
if [ "$TARGETARCH" = "arm64" ]; then \
18+
curl -Lf -o /lib/libfdb_c.so "https://github.com/apple/foundationdb/releases/download/7.3.68/libfdb_c.aarch64.so"; \
19+
else \
20+
curl -Lf -o /lib/libfdb_c.so "https://github.com/apple/foundationdb/releases/download/7.3.68/libfdb_c.x86_64.so"; \
21+
fi

docker/engine/Dockerfile

Lines changed: 5 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# syntax=docker/dockerfile:1.10.0
22

3+
ARG ENGINE_BASE_TAG=latest
4+
35
# MARK: Builder
46
# TODO(RVT-4168): Compile libfdb from scratch for ARM
5-
FROM rust:1.91.0-trixie AS builder
7+
FROM ghcr.io/rivet-dev/rivet/engine-base-builder:${ENGINE_BASE_TAG} AS builder
68

79
# Docker automatically provides TARGETARCH
810
ARG TARGETARCH
@@ -13,37 +15,6 @@ ARG VITE_APP_API_URL=__SAME__
1315
ARG VITE_APP_TURNSTILE_SITE_KEY=
1416
ARG OVERRIDE_GIT_SHA
1517

16-
ENV DEBIAN_FRONTEND=noninteractive
17-
RUN apt-get update -y && \
18-
apt-get install -y \
19-
curl \
20-
g++ \
21-
git \
22-
libclang-dev \
23-
libpq-dev \
24-
libssl-dev \
25-
pkg-config \
26-
ca-certificates \
27-
gpg \
28-
openssl \
29-
wget \
30-
cmake \
31-
make && \
32-
curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
33-
apt-get install -y nodejs && \
34-
corepack enable && \
35-
if [ "$TARGETARCH" = "arm64" ]; then \
36-
curl -Lf -o /lib/libfdb_c.so "https://github.com/apple/foundationdb/releases/download/7.3.68/libfdb_c.aarch64.so"; \
37-
else \
38-
curl -Lf -o /lib/libfdb_c.so "https://github.com/apple/foundationdb/releases/download/7.3.68/libfdb_c.x86_64.so"; \
39-
fi
40-
41-
# Disable interactive prompt
42-
ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0
43-
44-
# Pull via Git CLI to improve reliability in CI
45-
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
46-
4718
WORKDIR /app
4819

4920
COPY . .
@@ -80,27 +51,7 @@ RUN \
8051
cp target/$CARGO_BUILD_MODE/rivet-engine /app/dist/
8152

8253
# MARK: Engine (full, base)
83-
FROM debian:13.1-slim AS engine-full-base
84-
85-
# Docker automatically provides TARGETARCH
86-
ARG TARGETARCH
87-
88-
ENV DEBIAN_FRONTEND=noninteractive
89-
# - Install curl for health checks
90-
RUN apt-get update -y && \
91-
apt-get install -y \
92-
ca-certificates \
93-
openssl \
94-
curl \
95-
gpg \
96-
dirmngr && \
97-
apt-get clean && \
98-
rm -rf /var/lib/apt/lists/* && \
99-
if [ "$TARGETARCH" = "arm64" ]; then \
100-
curl -Lf -o /lib/libfdb_c.so "https://github.com/apple/foundationdb/releases/download/7.3.68/libfdb_c.aarch64.so"; \
101-
else \
102-
curl -Lf -o /lib/libfdb_c.so "https://github.com/apple/foundationdb/releases/download/7.3.68/libfdb_c.x86_64.so"; \
103-
fi
54+
FROM ghcr.io/rivet-dev/rivet/engine-base-runtime-full:${ENGINE_BASE_TAG} AS engine-full-base
10455

10556
# MARK: Engine (Full)
10657
FROM engine-full-base AS engine-full
@@ -113,26 +64,11 @@ ENTRYPOINT ["/usr/bin/rivet-engine"]
11364
CMD ["start"]
11465

11566
# MARK: Engine (Slim)
116-
FROM debian:13.1-slim AS engine-slim
67+
FROM ghcr.io/rivet-dev/rivet/engine-base-runtime-slim:${ENGINE_BASE_TAG} AS engine-slim
11768

11869
LABEL org.opencontainers.image.source=https://github.com/rivet-dev/rivet
11970

120-
# Docker automatically provides TARGETARCH
121-
ARG TARGETARCH
122-
123-
ENV DEBIAN_FRONTEND=noninteractive
124-
RUN apt-get update -y && \
125-
apt-get install -y ca-certificates openssl curl && \
126-
apt-get clean && \
127-
rm -rf /var/lib/apt/lists/* && \
128-
if [ "$TARGETARCH" = "arm64" ]; then \
129-
curl -Lf -o /lib/libfdb_c.so "https://github.com/apple/foundationdb/releases/download/7.3.68/libfdb_c.aarch64.so"; \
130-
else \
131-
curl -Lf -o /lib/libfdb_c.so "https://github.com/apple/foundationdb/releases/download/7.3.68/libfdb_c.x86_64.so"; \
132-
fi
133-
13471
COPY --from=builder /app/dist/rivet-engine /usr/bin/rivet-engine
13572

13673
ENTRYPOINT ["/usr/bin/rivet-engine"]
13774
CMD ["start"]
138-

0 commit comments

Comments
 (0)