Skip to content

Commit 6832baf

Browse files
Restore native ARM Docker builds, cargo-chef, and workflow_run gate
1 parent fe2ec2d commit 6832baf

5 files changed

Lines changed: 128 additions & 26 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
- 'Cargo.toml'
1010
- 'Cargo.lock'
1111
- '.github/workflows/**'
12+
- 'rust-toolchain.toml'
13+
- 'Dockerfile'
1214
pull_request:
1315
branches: [main]
1416

.github/workflows/main-image.yml

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,74 @@
11
name: Main Image
22

33
on:
4-
push:
4+
workflow_run:
5+
workflows: [CI]
6+
types: [completed]
57
branches: [main]
68

79
permissions:
810
packages: write
911

12+
env:
13+
IMAGE: ghcr.io/context-graph-ai/contextdb-server
14+
1015
jobs:
11-
push-main:
12-
runs-on: ubuntu-latest
16+
build:
17+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
18+
strategy:
19+
matrix:
20+
include:
21+
- platform: linux/amd64
22+
runner: ubuntu-latest
23+
- platform: linux/arm64
24+
runner: ubuntu-24.04-arm
25+
runs-on: ${{ matrix.runner }}
1326
steps:
1427
- uses: actions/checkout@v4
15-
- uses: docker/setup-qemu-action@v3
1628
- uses: docker/setup-buildx-action@v3
1729
- uses: docker/login-action@v3
1830
with:
1931
registry: ghcr.io
2032
username: ${{ github.actor }}
2133
password: ${{ secrets.GITHUB_TOKEN }}
22-
- uses: docker/build-push-action@v6
34+
- name: Build and push digest
35+
id: build
36+
uses: docker/build-push-action@v6
2337
with:
2438
context: .
25-
platforms: linux/amd64,linux/arm64
39+
platforms: ${{ matrix.platform }}
2640
push: true
27-
tags: ghcr.io/context-graph-ai/contextdb-server:main
28-
cache-from: type=gha
29-
cache-to: type=gha,mode=max
41+
tags: ${{ env.IMAGE }}
42+
cache-from: type=gha,scope=${{ matrix.platform }}
43+
cache-to: type=gha,scope=${{ matrix.platform }},mode=max
44+
outputs: type=image,push-by-digest=true,name-canonical=true
45+
- name: Export digest
46+
run: |
47+
mkdir -p /tmp/digests
48+
digest="${{ steps.build.outputs.digest }}"
49+
touch "/tmp/digests/${digest#sha256:}"
50+
- uses: actions/upload-artifact@v4
51+
with:
52+
name: digest-${{ strategy.job-index }}
53+
path: /tmp/digests/*
54+
55+
merge:
56+
needs: build
57+
runs-on: ubuntu-latest
58+
steps:
59+
- uses: docker/setup-buildx-action@v3
60+
- uses: docker/login-action@v3
61+
with:
62+
registry: ghcr.io
63+
username: ${{ github.actor }}
64+
password: ${{ secrets.GITHUB_TOKEN }}
65+
- uses: actions/download-artifact@v4
66+
with:
67+
path: /tmp/digests
68+
pattern: digest-*
69+
merge-multiple: true
70+
- name: Create manifest and push
71+
run: |
72+
cd /tmp/digests
73+
docker buildx imagetools create -t ${{ env.IMAGE }}:main \
74+
$(printf '${{ env.IMAGE }}@sha256:%s ' *)

.github/workflows/release-dry-run.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,25 @@ jobs:
3535
3636
dry-run-docker:
3737
needs: check
38-
runs-on: ubuntu-latest
38+
strategy:
39+
matrix:
40+
include:
41+
- platform: linux/amd64
42+
runner: ubuntu-latest
43+
- platform: linux/arm64
44+
runner: ubuntu-24.04-arm
45+
runs-on: ${{ matrix.runner }}
3946
steps:
4047
- uses: actions/checkout@v4
41-
- uses: docker/setup-qemu-action@v3
4248
- uses: docker/setup-buildx-action@v3
43-
- name: Build multi-arch image (no push)
49+
- name: Build image (no push)
4450
uses: docker/build-push-action@v6
4551
with:
4652
context: .
47-
platforms: linux/amd64,linux/arm64
53+
platforms: ${{ matrix.platform }}
4854
push: false
55+
cache-from: type=gha,scope=${{ matrix.platform }}
56+
cache-to: type=gha,scope=${{ matrix.platform }},mode=max
4957

5058
dry-run-binaries:
5159
needs: check

.github/workflows/release.yml

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
env:
88
CARGO_TERM_COLOR: always
99
CARGO_INCREMENTAL: 0
10+
IMAGE: ghcr.io/context-graph-ai/contextdb-server
1011

1112
permissions:
1213
contents: write
@@ -42,29 +43,67 @@ jobs:
4243
sleep 30
4344
done
4445
45-
publish-docker:
46+
build-docker:
4647
needs: verify-version
47-
runs-on: ubuntu-latest
48+
strategy:
49+
matrix:
50+
include:
51+
- platform: linux/amd64
52+
runner: ubuntu-latest
53+
- platform: linux/arm64
54+
runner: ubuntu-24.04-arm
55+
runs-on: ${{ matrix.runner }}
4856
steps:
4957
- uses: actions/checkout@v4
50-
- uses: docker/setup-qemu-action@v3
5158
- uses: docker/setup-buildx-action@v3
5259
- uses: docker/login-action@v3
5360
with:
5461
registry: ghcr.io
5562
username: ${{ github.actor }}
5663
password: ${{ secrets.GITHUB_TOKEN }}
57-
- name: Build and push multi-arch image
64+
- name: Build and push digest
65+
id: build
5866
uses: docker/build-push-action@v6
5967
with:
6068
context: .
61-
platforms: linux/amd64,linux/arm64
69+
platforms: ${{ matrix.platform }}
6270
push: true
63-
tags: |
64-
ghcr.io/context-graph-ai/contextdb-server:${{ github.ref_name }}
65-
ghcr.io/context-graph-ai/contextdb-server:latest
66-
cache-from: type=gha
67-
cache-to: type=gha,mode=max
71+
tags: ${{ env.IMAGE }}
72+
cache-from: type=gha,scope=${{ matrix.platform }}
73+
cache-to: type=gha,scope=${{ matrix.platform }},mode=max
74+
outputs: type=image,push-by-digest=true,name-canonical=true
75+
- name: Export digest
76+
run: |
77+
mkdir -p /tmp/digests
78+
digest="${{ steps.build.outputs.digest }}"
79+
touch "/tmp/digests/${digest#sha256:}"
80+
- uses: actions/upload-artifact@v4
81+
with:
82+
name: docker-digest-${{ strategy.job-index }}
83+
path: /tmp/digests/*
84+
85+
publish-docker:
86+
needs: build-docker
87+
runs-on: ubuntu-latest
88+
steps:
89+
- uses: docker/setup-buildx-action@v3
90+
- uses: docker/login-action@v3
91+
with:
92+
registry: ghcr.io
93+
username: ${{ github.actor }}
94+
password: ${{ secrets.GITHUB_TOKEN }}
95+
- uses: actions/download-artifact@v4
96+
with:
97+
path: /tmp/digests
98+
pattern: docker-digest-*
99+
merge-multiple: true
100+
- name: Create manifest and push
101+
run: |
102+
cd /tmp/digests
103+
docker buildx imagetools create \
104+
-t $IMAGE:${{ github.ref_name }} \
105+
-t $IMAGE:latest \
106+
$(printf '$IMAGE@sha256:%s ' *)
68107
69108
build-binaries:
70109
needs: verify-version
@@ -139,7 +178,7 @@ jobs:
139178
- uses: actions/checkout@v4
140179
- uses: actions-rust-lang/setup-rust-toolchain@v1
141180
- name: Install mdBook
142-
run: cargo install mdbook
181+
run: cargo install mdbook --version 0.5.2
143182
- name: Build docs
144183
run: mdbook build
145184
- name: Dispatch to website repo

Dockerfile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
FROM rust:1-bookworm AS builder
2-
1+
FROM rust:1.94.0-bookworm AS chef
2+
RUN cargo install cargo-chef --version 0.1.77
33
WORKDIR /src
4+
5+
FROM chef AS planner
6+
COPY . .
7+
RUN cargo chef prepare --recipe-path recipe.json
8+
9+
FROM chef AS builder
10+
COPY --from=planner /src/recipe.json recipe.json
11+
RUN cargo chef cook --release --recipe-path recipe.json -p contextdb-server
412
COPY . .
513
RUN cargo build --release -p contextdb-server \
614
&& strip target/release/contextdb-server

0 commit comments

Comments
 (0)