Skip to content

Commit b7d4d55

Browse files
authored
feat: add aiden-cli container Dockerfile and workflow (#15)
1 parent dcaf9f0 commit b7d4d55

2 files changed

Lines changed: 133 additions & 0 deletions

File tree

.github/workflows/aiden-cli.yaml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# a pipeline to create container image on changes to aiden-cli.rb file
2+
name: aiden-cli
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'aiden-cli.rb'
9+
- aiden-cli/Dockerfile
10+
- .github/workflows/aiden-cli.yaml
11+
env:
12+
REGISTRY: ghcr.io
13+
IMAGE_NAME: stackgenhq/aiden-cli
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: -amd
29+
- platform: linux/arm64
30+
runner: ubuntu-22.04-arm
31+
tag-suffix: -arm
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-cli
40+
aiden-cli.rb
41+
- name: Get aiden-cli version
42+
id: version
43+
run: |
44+
echo "VERSION=$(grep 'version' aiden-cli.rb | awk '{print $NF}' | tr -d '"')" >> $GITHUB_OUTPUT
45+
- name: Set up QEMU
46+
uses: docker/setup-qemu-action@v3
47+
- name: Set up Docker Buildx
48+
uses: docker/setup-buildx-action@v3
49+
- name: Extract metadata (tags, labels) for Docker
50+
id: meta
51+
uses: docker/metadata-action@v5
52+
with:
53+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
54+
tags: |
55+
type=raw,value=${{ steps.version.outputs.VERSION }}
56+
type=raw,value=latest
57+
flavor: |
58+
suffix=${{ matrix.tag-suffix }},onlatest=false
59+
- name: Log in to the Container registry
60+
uses: docker/login-action@v3
61+
with:
62+
registry: ${{ env.REGISTRY }}
63+
username: ${{ github.actor }}
64+
password: ${{ secrets.GITHUB_TOKEN }}
65+
- name: Docker Build and push
66+
uses: docker/build-push-action@v6
67+
with:
68+
context: ./aiden-cli
69+
platforms: ${{ matrix.platform }}
70+
tags: ${{ steps.meta.outputs.tags }}
71+
push: true
72+
provenance: false
73+
labels: ${{ steps.meta.outputs.labels }}
74+
build-args: |-
75+
AIDEN_CLI_VERSION=${{ steps.version.outputs.VERSION }}
76+
77+
create_manifest:
78+
name: Create manifest
79+
runs-on: ubuntu-22.04
80+
needs: build
81+
permissions:
82+
contents: read
83+
packages: write
84+
steps:
85+
- name: Set up Docker Buildx
86+
uses: docker/setup-buildx-action@v3
87+
- name: Log in to the Container registry
88+
uses: docker/login-action@v3
89+
with:
90+
registry: ${{ env.REGISTRY }}
91+
username: ${{ github.actor }}
92+
password: ${{ secrets.GITHUB_TOKEN }}
93+
- name: Create manifest
94+
run: |
95+
docker buildx imagetools create \
96+
-t ghcr.io/stackgenhq/aiden-cli:latest \
97+
ghcr.io/stackgenhq/aiden-cli:latest-amd \
98+
ghcr.io/stackgenhq/aiden-cli:latest-arm
99+
100+
docker buildx imagetools create \
101+
-t ghcr.io/stackgenhq/aiden-cli:${{ needs.build.outputs.version }} \
102+
ghcr.io/stackgenhq/aiden-cli:${{ needs.build.outputs.version }}-amd \
103+
ghcr.io/stackgenhq/aiden-cli:${{ needs.build.outputs.version }}-arm

aiden-cli/Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM alpine AS download_binary
2+
3+
ARG AIDEN_CLI_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 wget -O aiden-cli.tar.gz \
13+
https://releases.stackgen.com/binaries/aios-remote/v${AIDEN_CLI_VERSION}/aiden-cli_${AIDEN_CLI_VERSION}_${TARGETOS}_${TARGETARCH}.tar.gz && \
14+
tar -xzf aiden-cli.tar.gz && \
15+
mv aiden-cli /tmp/aiden-cli
16+
17+
FROM alpine:latest
18+
19+
RUN apk update && \
20+
apk add --no-cache ca-certificates && \
21+
rm -rf /var/cache/apk/* && \
22+
addgroup -S stackgen && adduser -S stackgen -G stackgen -u 1000 -h /home/stackgen
23+
24+
USER stackgen
25+
26+
COPY --from=download_binary --chown=stackgen:stackgen /tmp/aiden-cli /usr/local/bin/aiden-cli
27+
28+
RUN chmod +x /usr/local/bin/aiden-cli
29+
30+
ENTRYPOINT ["/usr/local/bin/aiden-cli"]

0 commit comments

Comments
 (0)