Skip to content

Commit 782fbab

Browse files
skscursoragent
andauthored
Add CCE container image workflow and Dockerfile. (#18)
Build multi-arch ghcr.io/stackgenhq/cce images from release binaries when cce.rb is updated, following the same pattern as stackgen and aiden-runner. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent ac0234c commit 782fbab

2 files changed

Lines changed: 139 additions & 0 deletions

File tree

.github/workflows/cce.yaml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# a pipeline to create container image on changes to cce.rb file
2+
name: cce
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'cce.rb'
9+
- cce/Dockerfile
10+
- .github/workflows/cce.yaml
11+
env:
12+
REGISTRY: ghcr.io
13+
IMAGE_NAME: stackgenhq/cce
14+
jobs:
15+
build:
16+
outputs:
17+
image_tag: ${{ steps.meta.outputs.tags }}
18+
version: ${{ steps.version.outputs.VERSION }}
19+
permissions:
20+
contents: read
21+
packages: write
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
include:
26+
- platform: linux/amd64
27+
runner: ubuntu-latest
28+
tag-suffix: -amd64
29+
- platform: linux/arm64
30+
runner: ubuntu-22.04-arm
31+
tag-suffix: -arm64
32+
runs-on: ${{ matrix.runner }}
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v4
36+
with:
37+
fetch-depth: 1
38+
sparse-checkout: |
39+
cce
40+
cce.rb
41+
- name: Get cce version
42+
id: version
43+
run: |
44+
VERSION="$(awk '$1 == "version" { print $2; exit }' cce.rb | tr -d '"')"
45+
test -n "$VERSION" || { echo "Error: Failed to extract version from cce.rb"; exit 1; }
46+
echo "$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$' || { echo "Error: Extracted version is not valid semver: $VERSION"; exit 1; }
47+
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
48+
- name: Set up QEMU
49+
uses: docker/setup-qemu-action@v3
50+
- name: Set up Docker Buildx
51+
uses: docker/setup-buildx-action@v3
52+
- name: Extract metadata (tags, labels) for Docker
53+
id: meta
54+
uses: docker/metadata-action@v5
55+
with:
56+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
57+
tags: |
58+
type=raw,value=${{ steps.version.outputs.VERSION }}
59+
type=raw,value=latest
60+
flavor: |
61+
suffix=${{ matrix.tag-suffix }},onlatest=false
62+
- name: Log in to the Container registry
63+
uses: docker/login-action@v3
64+
with:
65+
registry: ${{ env.REGISTRY }}
66+
username: ${{ github.actor }}
67+
password: ${{ secrets.GITHUB_TOKEN }}
68+
- name: Docker Build and push
69+
uses: docker/build-push-action@v6
70+
with:
71+
context: ./cce
72+
platforms: ${{ matrix.platform }}
73+
tags: ${{ steps.meta.outputs.tags }}
74+
push: true
75+
provenance: false
76+
labels: ${{ steps.meta.outputs.labels }}
77+
build-args: |-
78+
CCE_VERSION=${{ steps.version.outputs.VERSION }}
79+
80+
create_manifest:
81+
name: Create manifest
82+
runs-on: ubuntu-22.04
83+
needs: build
84+
permissions:
85+
contents: read
86+
packages: write
87+
steps:
88+
- name: Set up Docker Buildx
89+
uses: docker/setup-buildx-action@v3
90+
- name: Log in to the Container registry
91+
uses: docker/login-action@v3
92+
with:
93+
registry: ${{ env.REGISTRY }}
94+
username: ${{ github.actor }}
95+
password: ${{ secrets.GITHUB_TOKEN }}
96+
- name: Create manifest
97+
run: |
98+
docker buildx imagetools create \
99+
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \
100+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-amd64 \
101+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-arm64
102+
103+
docker buildx imagetools create \
104+
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.build.outputs.version }} \
105+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.build.outputs.version }}-amd64 \
106+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.build.outputs.version }}-arm64

cce/Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
FROM alpine AS download_binary
2+
3+
ARG CCE_VERSION
4+
ARG TARGETOS
5+
ARG TARGETARCH
6+
7+
RUN apk update && \
8+
apk add --no-cache curl && \
9+
rm -rf /var/cache/apk/*
10+
11+
RUN URL="https://releases.stackgen.com/binaries/cce/v${CCE_VERSION}/cce_${CCE_VERSION}_${TARGETOS}_${TARGETARCH}.tar.gz" && \
12+
curl -fsSL -o cce.tar.gz "$URL" || { echo "Error: failed to download cce from $URL" >&2; exit 1; } && \
13+
tar -xzf cce.tar.gz && \
14+
test -f cce || { echo "Error: extracted archive does not contain cce binary" >&2; exit 1; } && \
15+
mv cce /tmp/cce && \
16+
chmod +x /tmp/cce && \
17+
rm -f cce.tar.gz
18+
19+
FROM alpine:latest
20+
21+
RUN apk update && \
22+
apk add --no-cache ca-certificates git && \
23+
rm -rf /var/cache/apk/* && \
24+
addgroup -S stackgen && adduser -S stackgen -G stackgen -u 1000 -h /home/stackgen
25+
26+
COPY --from=download_binary --chown=stackgen:stackgen /tmp/cce /usr/local/bin/cce
27+
28+
USER stackgen
29+
30+
WORKDIR /work
31+
32+
ENTRYPOINT ["/usr/local/bin/cce"]
33+
CMD ["-help"]

0 commit comments

Comments
 (0)