Skip to content

Commit c5dd29d

Browse files
authored
Create Docker image pipeline for aiden-runner (#16)
* Add aiden-runner Dockerfile and image workflow Agent-Logs-Url: https://github.com/stackgenhq/homebrew-stackgen/sessions/b05362ea-97f6-4934-af21-3fd6a34aea8c
1 parent ab443d8 commit c5dd29d

2 files changed

Lines changed: 137 additions & 0 deletions

File tree

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 aiden-runner.rb file
2+
name: aiden-runner
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'aiden-runner.rb'
9+
- aiden-runner/Dockerfile
10+
- .github/workflows/aiden-runner.yaml
11+
env:
12+
REGISTRY: ghcr.io
13+
IMAGE_NAME: stackgenhq/aiden-runner
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+
aiden-runner
40+
aiden-runner.rb
41+
- name: Get aiden-runner version
42+
id: version
43+
run: |
44+
VERSION="$(awk '$1 == \"version\" { print $2; exit }' aiden-runner.rb | tr -d '\"')"
45+
test -n "$VERSION" || { echo "Error: Failed to extract version from aiden-runner.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: ./aiden-runner
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+
AIDEN_RUNNER_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

aiden-runner/Dockerfile

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

0 commit comments

Comments
 (0)