Skip to content

Commit e258542

Browse files
committed
chore(engine): publish engine bases in ci
1 parent 494bf0e commit e258542

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
@@ -73,6 +73,8 @@ cd self-host/compose/dev
7373
docker-compose up -d
7474
```
7575

76+
- 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`.
77+
7678
### Git Commands
7779
```bash
7880
# 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
@@ -12,37 +14,6 @@ ARG CARGO_BUILD_MODE=debug
1214
ARG VITE_APP_API_URL=__SAME__
1315
ARG OVERRIDE_GIT_SHA
1416

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

4819
COPY . .
@@ -83,27 +54,7 @@ RUN \
8354
cp target/$CARGO_BUILD_MODE/rivet-engine /app/dist/
8455

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

10859
# MARK: Engine (Full)
10960
FROM engine-full-base AS engine-full
@@ -116,26 +67,11 @@ ENTRYPOINT ["/usr/bin/rivet-engine"]
11667
CMD ["start"]
11768

11869
# MARK: Engine (Slim)
119-
FROM debian:13.1-slim AS engine-slim
70+
FROM ghcr.io/rivet-dev/rivet/engine-base-runtime-slim:${ENGINE_BASE_TAG} AS engine-slim
12071

12172
LABEL org.opencontainers.image.source=https://github.com/rivet-dev/rivet
12273

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

13976
ENTRYPOINT ["/usr/bin/rivet-engine"]
14077
CMD ["start"]
141-

0 commit comments

Comments
 (0)