Skip to content

Commit 619d2c3

Browse files
Add publish-sandbox workflow
1 parent 3a75e58 commit 619d2c3

3 files changed

Lines changed: 116 additions & 0 deletions

File tree

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Publish Sandbox Docker Image
2+
3+
on:
4+
push:
5+
tags:
6+
- 'sandbox-v\d+\.\d+\.\d+*' # Matches sandbox specific semver tags in the format of sandbox-v1.2.3, sandbox-v1.2.3-beta.1, etc.
7+
8+
env:
9+
IMAGE_NAME: ghcr.io/usherlabs/fiet-sandbox/cex-broker
10+
11+
permissions:
12+
contents: read
13+
packages: write
14+
15+
jobs:
16+
build:
17+
name: Build (${{ matrix.arch }})
18+
runs-on: ${{ matrix.runner }}
19+
strategy:
20+
matrix:
21+
include:
22+
- arch: amd64
23+
runner: ubuntu-latest
24+
- arch: arm64
25+
runner: [self-hosted, linux, arm64]
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
30+
- name: Set up Docker Buildx
31+
uses: docker/setup-buildx-action@v3
32+
33+
- name: Log in to GitHub Container Registry
34+
uses: docker/login-action@v3
35+
with:
36+
registry: ghcr.io
37+
username: ${{ github.actor }}
38+
password: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- name: Extract metadata
41+
id: meta
42+
uses: docker/metadata-action@v5
43+
with:
44+
images: ${{ env.IMAGE_NAME }}
45+
tags: |
46+
type=match,pattern=sandbox-v(\d+\.\d+\.\d+.*),group=1
47+
48+
- name: Build and push Docker image
49+
uses: docker/build-push-action@v6
50+
with:
51+
context: .
52+
file: ./.sandbox/Dockerfile
53+
platforms: linux/${{ matrix.arch }}
54+
push: true
55+
tags: |
56+
${{ env.IMAGE_NAME }}:${{ fromJSON(steps.meta.outputs.json).tag-names[0] }}-${{ matrix.arch }}
57+
${{ env.IMAGE_NAME }}:latest-${{ matrix.arch }}
58+
cache-from: type=gha,scope=${{ matrix.arch }}
59+
cache-to: type=gha,mode=max,scope=${{ matrix.arch }}
60+
61+
manifest:
62+
name: Publish multi-arch manifest
63+
runs-on: ubuntu-latest
64+
needs: build
65+
steps:
66+
- name: Log in to GitHub Container Registry
67+
uses: docker/login-action@v3
68+
with:
69+
registry: ghcr.io
70+
username: ${{ github.actor }}
71+
password: ${{ secrets.GITHUB_TOKEN }}
72+
73+
- name: Set up Docker Buildx
74+
uses: docker/setup-buildx-action@v3
75+
76+
- name: Extract metadata
77+
id: meta
78+
uses: docker/metadata-action@v5
79+
with:
80+
images: ${{ env.IMAGE_NAME }}
81+
tags: |
82+
type=match,pattern=sandbox-v(\d+\.\d+\.\d+.*),group=1
83+
84+
- name: Create and push manifest
85+
run: |
86+
docker buildx imagetools create \
87+
--tag "${{ env.IMAGE_NAME }}:${{ fromJSON(steps.meta.outputs.json).tag-names[0] }}" \
88+
--tag "${{ env.IMAGE_NAME }}:latest" \
89+
"${{ env.IMAGE_NAME }}:${{ fromJSON(steps.meta.outputs.json).tag-names[0] }}-amd64" \
90+
"${{ env.IMAGE_NAME }}:${{ fromJSON(steps.meta.outputs.json).tag-names[0] }}-arm64"
91+
92+
docker buildx imagetools inspect "${{ env.IMAGE_NAME }}:${{ fromJSON(steps.meta.outputs.json).tag-names[0] }}"
93+
docker buildx imagetools inspect "${{ env.IMAGE_NAME }}:latest"

.sandbox/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM oven/bun:1.3
2+
3+
WORKDIR /app
4+
5+
RUN apt-get update -y \
6+
&& apt-get install -y --no-install-recommends ca-certificates curl \
7+
&& rm -rf /var/lib/apt/lists/*
8+
9+
RUN bun install --global @usherlabs/cex-broker@0.1.20
10+
11+
COPY --chmod=0755 ./.sandbox/entrypoint.sh /entrypoint.sh
12+
ENTRYPOINT ["/entrypoint.sh"]
13+
14+
CMD ["cex-broker"]

.sandbox/entrypoint.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env sh
2+
set -eu
3+
4+
INSTALL_URL="http://local-ca/install.sh"
5+
6+
# Run the local CA installer, then exec the provided command.
7+
curl -fsSL --retry 60 --retry-all-errors --retry-delay 1 "$INSTALL_URL" | sh
8+
9+
exec "$@"

0 commit comments

Comments
 (0)