Skip to content

Commit 52bb5ce

Browse files
committed
feat: Switch to Chainguard rust images, support linux-x86/arm64 and macOS-M series only
- Dockerfile: cgr.dev/chainguard/rust:latest-dev (build) + cgr.dev/chainguard/rust:latest (runtime) - Release binaries: linux-x86_64, linux-aarch64, macos-aarch64 (M-series) - Remove macOS x86_64 (Intel) and musl targets - Docker: multi-arch linux/amd64 + linux/arm64 via QEMU - Add linux aarch64 cross-compilation with gcc-aarch64-linux-gnu
1 parent 71e2e29 commit 52bb5ce

2 files changed

Lines changed: 47 additions & 84 deletions

File tree

.github/workflows/release.yml

Lines changed: 27 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,12 @@ jobs:
6464
include:
6565
- os: ubuntu-latest
6666
target: x86_64-unknown-linux-gnu
67-
artifact_name: streamforge
6867
asset_name: streamforge-linux-x86_64
69-
- os: macos-13
70-
target: x86_64-apple-darwin
71-
artifact_name: streamforge
72-
asset_name: streamforge-macos-x86_64
68+
- os: ubuntu-latest
69+
target: aarch64-unknown-linux-gnu
70+
asset_name: streamforge-linux-aarch64
7371
- os: macos-latest
7472
target: aarch64-apple-darwin
75-
artifact_name: streamforge
7673
asset_name: streamforge-macos-aarch64
7774

7875
steps:
@@ -92,6 +89,17 @@ jobs:
9289
clang \
9390
libclang-dev
9491
92+
- name: Install cross-compiler (Linux aarch64)
93+
if: matrix.target == 'aarch64-unknown-linux-gnu'
94+
run: |
95+
sudo apt-get install -y \
96+
gcc-aarch64-linux-gnu \
97+
libsasl2-dev:arm64 \
98+
libssl-dev:arm64 \
99+
libzstd-dev:arm64 \
100+
libcurl4-openssl-dev:arm64 || true
101+
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
102+
95103
- name: Install dependencies (macOS)
96104
if: runner.os == 'macOS'
97105
run: |
@@ -110,26 +118,28 @@ jobs:
110118
- name: Build release binary
111119
run: cargo build --release --locked --target ${{ matrix.target }}
112120

113-
- name: Strip binary
114-
run: strip target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
121+
- name: Strip binary (Linux x86_64 and macOS)
122+
if: matrix.target != 'aarch64-unknown-linux-gnu'
123+
run: strip target/${{ matrix.target }}/release/streamforge
115124

116125
- name: Upload binary to release
117126
env:
118127
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
119128
run: |
120129
TAG="${{ github.event.inputs.tag || github.ref_name }}"
121-
cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} ${{ matrix.asset_name }}
130+
cp target/${{ matrix.target }}/release/streamforge ${{ matrix.asset_name }}
122131
gh release upload "$TAG" ${{ matrix.asset_name }} --clobber
123132
124133
build-docker-images:
125134
name: Build and Push Docker Images
126135
runs-on: ubuntu-latest
127136
continue-on-error: true
128-
env:
129-
REGISTRY: ghcr.io
130137
steps:
131138
- uses: actions/checkout@v4
132139

140+
- name: Set up QEMU (for multi-arch)
141+
uses: docker/setup-qemu-action@v3
142+
133143
- name: Set up Docker Buildx
134144
uses: docker/setup-buildx-action@v3
135145

@@ -146,12 +156,13 @@ jobs:
146156
TAG="${{ github.event.inputs.tag || github.ref_name }}"
147157
echo "VERSION=${TAG#v}" >> $GITHUB_OUTPUT
148158
149-
- name: Build and push Docker image
159+
- name: Build and push multi-arch Docker image
150160
uses: docker/build-push-action@v5
151161
with:
152162
context: .
153163
file: ./Dockerfile
154164
push: true
165+
platforms: linux/amd64,linux/arm64
155166
tags: |
156167
ghcr.io/${{ github.repository }}:${{ steps.version.outputs.VERSION }}
157168
ghcr.io/${{ github.repository }}:latest
@@ -165,6 +176,9 @@ jobs:
165176
steps:
166177
- uses: actions/checkout@v4
167178

179+
- name: Set up QEMU (for multi-arch)
180+
uses: docker/setup-qemu-action@v3
181+
168182
- name: Set up Docker Buildx
169183
uses: docker/setup-buildx-action@v3
170184

@@ -187,43 +201,9 @@ jobs:
187201
context: .
188202
file: ./operator/Dockerfile
189203
push: true
204+
platforms: linux/amd64,linux/arm64
190205
tags: |
191206
ghcr.io/${{ github.repository }}-operator:${{ steps.version.outputs.VERSION }}
192207
ghcr.io/${{ github.repository }}-operator:latest
193208
cache-from: type=gha
194209
cache-to: type=gha,mode=max
195-
196-
build-ui-image:
197-
name: Build and Push UI Image
198-
runs-on: ubuntu-latest
199-
continue-on-error: true
200-
steps:
201-
- uses: actions/checkout@v4
202-
203-
- name: Set up Docker Buildx
204-
uses: docker/setup-buildx-action@v3
205-
206-
- name: Log in to GitHub Container Registry
207-
uses: docker/login-action@v3
208-
with:
209-
registry: ghcr.io
210-
username: ${{ github.actor }}
211-
password: ${{ secrets.GITHUB_TOKEN }}
212-
213-
- name: Extract version
214-
id: version
215-
run: |
216-
TAG="${{ github.event.inputs.tag || github.ref_name }}"
217-
echo "VERSION=${TAG#v}" >> $GITHUB_OUTPUT
218-
219-
- name: Build and push UI image
220-
uses: docker/build-push-action@v5
221-
with:
222-
context: ./ui
223-
file: ./ui/Dockerfile
224-
push: true
225-
tags: |
226-
ghcr.io/${{ github.repository }}-ui:${{ steps.version.outputs.VERSION }}
227-
ghcr.io/${{ github.repository }}-ui:latest
228-
cache-from: type=gha
229-
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 20 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,43 @@
1-
# Multi-stage Dockerfile with Debian bookworm
2-
# Stage 1: Builder - Compile the Rust application
3-
FROM rust:1.85-bookworm AS builder
4-
5-
# Install build dependencies
6-
RUN apt-get update && apt-get install -y \
7-
libsasl2-dev \
8-
libssl-dev \
9-
libzstd-dev \
10-
pkg-config \
1+
# Multi-stage build using Chainguard hardened images
2+
# Stage 1: Build
3+
FROM cgr.dev/chainguard/rust:latest-dev AS builder
4+
5+
USER root
6+
7+
# Install build dependencies (Wolfi/Alpine package names)
8+
RUN apk add --no-cache \
9+
cyrus-sasl-dev \
10+
openssl-dev \
11+
zstd-dev \
12+
curl-dev \
1113
cmake \
1214
clang \
13-
libclang-dev \
14-
&& rm -rf /var/lib/apt/lists/*
15+
llvm-dev \
16+
pkgconf
1517

16-
# Set working directory
1718
WORKDIR /build
1819

19-
# Copy dependency manifests first (for layer caching)
20+
# Copy dependency manifests for layer caching
2021
COPY Cargo.toml Cargo.lock ./
2122
COPY benches ./benches
2223

23-
# Create a dummy main.rs to cache dependencies
24+
# Cache dependencies with dummy binary
2425
RUN mkdir -p src && \
2526
echo "fn main() {}" > src/main.rs && \
2627
cargo build --release --bin streamforge && \
2728
rm -rf src
2829

29-
# Copy actual source code
30+
# Copy source and build
3031
COPY src ./src
31-
32-
# Build the real application
33-
# Touch main.rs to force rebuild after dummy
3432
RUN touch src/main.rs && \
3533
cargo build --release --locked --bin streamforge
3634

37-
# Stage 2: Runtime - Minimal Debian runtime image
38-
FROM debian:bookworm-slim
39-
40-
# Install runtime dependencies
41-
RUN apt-get update && apt-get install -y \
42-
libsasl2-2 \
43-
libssl3 \
44-
ca-certificates \
45-
&& rm -rf /var/lib/apt/lists/*
35+
# Stage 2: Runtime
36+
FROM cgr.dev/chainguard/rust:latest
4637

47-
# Create non-root user
48-
RUN useradd -m -u 65532 nonroot
49-
50-
# Copy the compiled binary from builder stage
38+
# Copy binary from builder
5139
COPY --from=builder /build/target/release/streamforge /usr/local/bin/streamforge
5240

53-
USER nonroot
54-
WORKDIR /home/nonroot
55-
56-
# Set environment variables
5741
ENV RUST_LOG=info
5842

59-
# Run the application
6043
ENTRYPOINT ["/usr/local/bin/streamforge"]

0 commit comments

Comments
 (0)