Skip to content

Commit 0bcabc6

Browse files
committed
Multi-stage Docker build + simplified publish pipeline
- Dockerfile: build o-rly inside debian:bookworm against bookworm moxygen tarball, copy binary to bookworm-slim runtime image - ci-main.yml publish: download bookworm tarball via ORLY_PLATFORM override, docker build does compilation (no C++ toolchain on runner) - setup-deps-tarball.sh: support ORLY_PLATFORM env var override - .dockerignore: exclude build dirs, keep fbcode_builder/CMake - Update moxygen submodule to b3e8ab9 (find_dependency(fmt) fix)
1 parent 579ca78 commit 0bcabc6

5 files changed

Lines changed: 50 additions & 25 deletions

File tree

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
.scratch/
2+
.git/
23
build/
34
build-san/
5+
_build/
6+
deps/moxygen/.git/
7+
deps/moxygen/moxygen/
8+
deps/moxygen/standalone/
9+
install/

.github/workflows/ci-main.yml

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -113,33 +113,16 @@ jobs:
113113
with:
114114
submodules: true
115115

116-
- name: Install system dependencies
117-
run: bash deps/moxygen/standalone/install-system-deps.sh
118-
119-
- name: Download moxygen artifacts
116+
- name: Download bookworm moxygen tarball
120117
env:
121118
GH_TOKEN: ${{ steps.app-token.outputs.token }}
119+
ORLY_PLATFORM: bookworm-amd64
122120
run: bash scripts/setup-deps-tarball.sh
123121

124-
- name: Set up ccache
125-
uses: hendrikmuhs/ccache-action@v1
126-
with:
127-
key: publish-amd64
128-
max-size: 500M
129-
130-
- name: Configure
122+
- name: Stage tarball for Docker build
131123
run: |
132-
cmake -S . -B _build --preset default \
133-
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
134-
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
135-
-DCMAKE_PREFIX_PATH="$(cat .scratch/cmake_prefix_path.txt)" \
136-
-DBUILD_TESTING=OFF
137-
138-
- name: Build
139-
run: cmake --build _build -j$(getconf _NPROCESSORS_ONLN)
140-
141-
- name: Install
142-
run: cmake --install _build --prefix "$GITHUB_WORKSPACE/install"
124+
mkdir -p .docker-deps
125+
cp -a .scratch/moxygen-install .docker-deps/moxygen
143126
144127
- name: Log in to GHCR
145128
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
@@ -190,6 +173,9 @@ jobs:
190173
id: package
191174
run: |
192175
ARTIFACT="o-rly-bookworm-amd64.tar.gz"
176+
docker cp "$(docker create --name extract ghcr.io/${{ github.repository }}:latest):/usr/local/bin/o-rly" .
177+
docker rm extract
178+
mkdir -p install/bin && mv o-rly install/bin/
193179
tar czf "$ARTIFACT" -C install .
194180
echo "artifact=$ARTIFACT" >> "$GITHUB_OUTPUT"
195181

deps/moxygen

docker/Dockerfile

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,41 @@
1+
# ── Build stage: compile o-rly inside bookworm against moxygen tarball ───
2+
FROM debian:bookworm AS builder
3+
4+
RUN apt-get update && apt-get install -y --no-install-recommends \
5+
build-essential ninja-build git ca-certificates python3-pip \
6+
libssl-dev libunwind-dev libgoogle-glog-dev libgflags-dev \
7+
libdouble-conversion-dev libevent-dev libsodium-dev libzstd-dev \
8+
libboost-all-dev libfmt-dev zlib1g-dev libc-ares-dev libdwarf-dev \
9+
&& pip install --break-system-packages cmake \
10+
&& rm -rf /var/lib/apt/lists/*
11+
12+
WORKDIR /src
13+
14+
# Moxygen tarball (pre-extracted bookworm build)
15+
COPY .docker-deps/moxygen /opt/moxygen
16+
17+
# O-rly source — only what cmake needs
18+
COPY CMakeLists.txt CMakePresets.json ./
19+
COPY cmake/ cmake/
20+
COPY src/ src/
21+
COPY include/ include/
22+
COPY deps/moxygen/build/fbcode_builder/CMake deps/moxygen/build/fbcode_builder/CMake
23+
24+
RUN cmake -S . -B _build --preset default \
25+
-DCMAKE_PREFIX_PATH=/opt/moxygen \
26+
-DBUILD_TESTING=OFF -DORLY_BUILD_TESTS=OFF \
27+
&& cmake --build _build -j$(nproc) \
28+
&& cmake --install _build --prefix /install
29+
30+
# ── Runtime stage: minimal image with just the binary ────────────────────
131
FROM debian:bookworm-slim
32+
233
RUN apt-get update && apt-get install -y --no-install-recommends \
334
libunwind8 \
435
&& rm -rf /var/lib/apt/lists/*
5-
COPY install/bin/o_rly /usr/local/bin/o-rly
36+
37+
COPY --from=builder /install/bin/o_rly /usr/local/bin/o-rly
638
COPY docker/entrypoint.sh /usr/local/bin/entrypoint.sh
739
RUN chmod +x /usr/local/bin/entrypoint.sh
40+
841
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]

scripts/setup-deps-tarball.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ detect_platform() {
6060
fi
6161
}
6262

63-
PLATFORM=$(detect_platform)
63+
PLATFORM="${ORLY_PLATFORM:-$(detect_platform)}"
6464
echo "==> Platform: $PLATFORM"
6565

6666
# ── Find publish run matching submodule SHA ───────────────────────────────────

0 commit comments

Comments
 (0)