Skip to content

Commit 90c1ac4

Browse files
committed
feat: Docker images use pre-built binaries — fast multi-arch without QEMU compilation
- Add Dockerfile.release: copies pre-built amd64/arm64 binaries into Chainguard wolfi-base - Binary jobs upload artifacts so Docker job can download them - Docker build takes seconds (copy binary) instead of hours (QEMU Rust compile) - build-docker-images now depends on build-release-binaries (needs) - Also consolidate Linux system deps into single runner.os == Linux condition
1 parent 5a7bcf6 commit 90c1ac4

2 files changed

Lines changed: 59 additions & 31 deletions

File tree

.github/workflows/release.yml

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,17 @@ jobs:
6565
- os: ubuntu-latest
6666
target: x86_64-unknown-linux-gnu
6767
asset_name: streamforge-linux-x86_64
68+
docker_arch: amd64
6869

6970
- os: ubuntu-24.04-arm
7071
target: aarch64-unknown-linux-gnu
7172
asset_name: streamforge-linux-aarch64
73+
docker_arch: arm64
7274

7375
- os: macos-latest
7476
target: aarch64-apple-darwin
7577
asset_name: streamforge-macos-aarch64
78+
docker_arch: ""
7679

7780
steps:
7881
- uses: actions/checkout@v4
@@ -85,22 +88,8 @@ jobs:
8588
- name: Cache cargo
8689
uses: Swatinem/rust-cache@v2
8790

88-
- name: Install system dependencies (Linux x86_64)
89-
if: matrix.target == 'x86_64-unknown-linux-gnu'
90-
run: |
91-
sudo apt-get update
92-
sudo apt-get install -y \
93-
libsasl2-dev \
94-
libssl-dev \
95-
libzstd-dev \
96-
libcurl4-openssl-dev \
97-
cmake \
98-
pkg-config \
99-
clang \
100-
libclang-dev
101-
102-
- name: Install system dependencies (Linux aarch64)
103-
if: matrix.target == 'aarch64-unknown-linux-gnu'
91+
- name: Install system dependencies (Linux)
92+
if: runner.os == 'Linux'
10493
run: |
10594
sudo apt-get update
10695
sudo apt-get install -y \
@@ -120,16 +109,11 @@ jobs:
120109
echo "OPENSSL_DIR=$(brew --prefix openssl@3)" >> $GITHUB_ENV
121110
echo "PKG_CONFIG_PATH=$(brew --prefix openssl@3)/lib/pkgconfig:$(brew --prefix cyrus-sasl)/lib/pkgconfig" >> $GITHUB_ENV
122111
123-
- name: Build (native — x86_64 and macOS)
124-
if: matrix.target != 'aarch64-unknown-linux-gnu'
112+
- name: Build release binary
125113
run: cargo build --release --locked --target ${{ matrix.target }}
126114

127-
- name: Build (Linux aarch64 — native ARM64 runner)
128-
if: matrix.target == 'aarch64-unknown-linux-gnu'
129-
run: cargo build --release --locked --target ${{ matrix.target }}
130-
131-
- name: Strip binary (native only)
132-
if: matrix.target != 'aarch64-unknown-linux-gnu'
115+
- name: Strip binary (Linux only)
116+
if: runner.os == 'Linux'
133117
run: strip target/${{ matrix.target }}/release/streamforge
134118

135119
- name: Upload binary to release
@@ -140,8 +124,17 @@ jobs:
140124
cp target/${{ matrix.target }}/release/streamforge ${{ matrix.asset_name }}
141125
gh release upload "$TAG" ${{ matrix.asset_name }} --clobber
142126
127+
- name: Upload Linux binary as artifact for Docker (Linux only)
128+
if: matrix.docker_arch != ''
129+
uses: actions/upload-artifact@v4
130+
with:
131+
name: streamforge-linux-${{ matrix.docker_arch }}
132+
path: ${{ matrix.asset_name }}
133+
retention-days: 1
134+
143135
build-docker-images:
144136
name: Build and Push Docker Images
137+
needs: build-release-binaries
145138
runs-on: ubuntu-latest
146139
continue-on-error: true
147140
permissions:
@@ -150,7 +143,22 @@ jobs:
150143
steps:
151144
- uses: actions/checkout@v4
152145

153-
- name: Set up QEMU (for multi-arch)
146+
- name: Download amd64 binary
147+
uses: actions/download-artifact@v4
148+
with:
149+
name: streamforge-linux-amd64
150+
151+
- name: Download arm64 binary
152+
uses: actions/download-artifact@v4
153+
with:
154+
name: streamforge-linux-arm64
155+
156+
- name: Rename binaries for Dockerfile.release
157+
run: |
158+
mv streamforge-linux-x86_64 streamforge-linux-amd64
159+
mv streamforge-linux-aarch64 streamforge-linux-arm64
160+
161+
- name: Set up QEMU (for multi-arch manifest only)
154162
uses: docker/setup-qemu-action@v3
155163

156164
- name: Set up Docker Buildx
@@ -163,7 +171,7 @@ jobs:
163171
username: ${{ github.actor }}
164172
password: ${{ secrets.GITHUB_TOKEN }}
165173

166-
- name: Extract metadata (tags and labels)
174+
- name: Extract metadata
167175
id: meta
168176
uses: docker/metadata-action@v5
169177
with:
@@ -172,17 +180,15 @@ jobs:
172180
type=semver,pattern={{version}},value=${{ github.event.inputs.tag || github.ref_name }}
173181
type=raw,value=latest
174182
175-
- name: Build and push multi-arch Docker image
183+
- name: Build and push multi-arch Docker image (pre-built binaries)
176184
uses: docker/build-push-action@v5
177185
with:
178186
context: .
179-
file: ./Dockerfile
187+
file: ./Dockerfile.release
180188
push: true
181189
platforms: linux/amd64,linux/arm64
182190
tags: ${{ steps.meta.outputs.tags }}
183191
labels: ${{ steps.meta.outputs.labels }}
184-
cache-from: type=gha
185-
cache-to: type=gha,mode=max
186192

187193
build-operator-image:
188194
name: Build and Push Operator Image
@@ -194,7 +200,7 @@ jobs:
194200
steps:
195201
- uses: actions/checkout@v4
196202

197-
- name: Set up QEMU (for multi-arch)
203+
- name: Set up QEMU
198204
uses: docker/setup-qemu-action@v3
199205

200206
- name: Set up Docker Buildx

Dockerfile.release

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Release Dockerfile — copies pre-built binary into minimal Chainguard runtime image.
2+
# No compilation; the binary is built natively by the CI binary release jobs.
3+
# Build context must contain: streamforge-linux-amd64 and streamforge-linux-arm64
4+
FROM cgr.dev/chainguard/wolfi-base AS runtime
5+
6+
# Install only runtime libraries that streamforge links against dynamically
7+
RUN apk add --no-cache \
8+
openssl \
9+
cyrus-sasl \
10+
libzstd1 \
11+
libcurl4
12+
13+
LABEL org.opencontainers.image.source="https://github.com/rahulbsw/streamforge"
14+
LABEL org.opencontainers.image.description="High-performance Kafka streaming toolkit"
15+
LABEL org.opencontainers.image.licenses="Apache-2.0"
16+
17+
ARG TARGETARCH
18+
COPY streamforge-linux-${TARGETARCH} /usr/local/bin/streamforge
19+
RUN chmod +x /usr/local/bin/streamforge
20+
21+
ENV RUST_LOG=info
22+
ENTRYPOINT ["/usr/local/bin/streamforge"]

0 commit comments

Comments
 (0)