Skip to content

Modern Docker Management, Designed for Everyone

ci/cd: combined preview workflows

Kyle Mendell52386d9ef285
diff --git a/.github/workflows/build-1.0-agent-preview.yml b/.github/workflows/build-1.0-agent-preview.yml
deleted file mode 100644
index 0dca4b6d5..000000000
--- a/.github/workflows/build-1.0-agent-preview.yml
+++ /dev/null
@@ -1,74 +0,0 @@
-name: Build Agent 1.0 Preview
-
-on:
- push:
- branches:
- - 1.0.0
- workflow_dispatch:
-
-concurrency:
- group: ${{ github.workflow }}-${{ github.ref }}
- cancel-in-progress: true
-
-jobs:
- prerelease:
- runs-on: ubuntu-latest
- permissions:
- contents: read
- packages: write
- id-token: write
- attestations: write
-
- env:
- DOCKER_IMAGE_NAME: ghcr.io/ofkm/arcane-headless
-
- steps:
- - name: Checkout code
- uses: actions/checkout@v5
- with:
- fetch-depth: 1
-
- - name: Set up QEMU
- uses: docker/setup-qemu-action@v3
-
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v3
-
- - name: Lowercase image owner (safe-guard)
- run: echo "DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME,,}" >> "$GITHUB_ENV"
-
- - name: Login to GHCR
- uses: docker/login-action@v3
- with:
- registry: ghcr.io
- username: ${{ github.repository_owner }}
- password: ${{ secrets.GITHUB_TOKEN }}
-
- - name: Compute image tags
- id: tags
- run: |
- SHORT_SHA="$(git rev-parse --short HEAD)"
- echo "SHORT_SHA=${SHORT_SHA}" >> "$GITHUB_ENV"
- echo "IMAGE_STABLE=${DOCKER_IMAGE_NAME}:1.0-preview" >> "$GITHUB_ENV"
- echo "IMAGE_SHA=${DOCKER_IMAGE_NAME}:1.0-preview-${SHORT_SHA}" >> "$GITHUB_ENV"
-
- - name: Build and push agent image
- id: build-push
- uses: docker/build-push-action@v6
- with:
- context: ./
- file: docker/Dockerfile-agent
- platforms: linux/amd64,linux/arm64
- push: true
- tags: |
- ${{ env.IMAGE_STABLE }}
- ${{ env.IMAGE_SHA }}
- cache-from: type=gha,scope=agent-preview
- cache-to: type=gha,scope=agent-preview,mode=max
-
- - name: Container image attestation
- uses: actions/attest-build-provenance@v2
- with:
- subject-name: '${{ env.DOCKER_IMAGE_NAME }}'
- subject-digest: ${{ steps.build-push.outputs.digest }}
- push-to-registry: true
diff --git a/.github/workflows/build-1.0-preview-image.yml b/.github/workflows/build-1.0-preview.yml
similarity index 65%
rename from .github/workflows/build-1.0-preview-image.yml
rename to .github/workflows/build-1.0-preview.yml
index d09a68c11..a27d487b5 100644
--- a/.github/workflows/build-1.0-preview-image.yml
+++ b/.github/workflows/build-1.0-preview.yml
@@ -1,9 +1,10 @@
-name: Build and Publish 1.0 Preview
+name: Build and Publish 1.0 Preview (Manager + Agent)
on:
push:
branches:
- 1.0.0
+ workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
@@ -20,6 +21,7 @@ jobs:
env:
DOCKER_IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/arcane
+ AGENT_IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/arcane-headless
steps:
- name: Checkout code
@@ -27,8 +29,10 @@ jobs:
with:
fetch-depth: 1
- - name: Lowercase image owner
- run: echo "DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME,,}" >> "$GITHUB_ENV"
+ - name: Lowercase image names
+ run: |
+ echo "DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME,,}" >> "$GITHUB_ENV"
+ echo "AGENT_IMAGE_NAME=${AGENT_IMAGE_NAME,,}" >> "$GITHUB_ENV"
- name: Setup PNPM
uses: pnpm/action-setup@v4
@@ -51,8 +55,11 @@ jobs:
with:
go-version-file: backend/go.mod
- - name: Build backend binaries
- run: bash scripts/development/build-binaries.sh
+ - name: Build arcane binaries
+ run: bash scripts/development/build-binaries.sh --docker
+
+ - name: Build agent binaries
+ run: bash scripts/development/build-binaries.sh --docker --agent
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
@@ -74,12 +81,11 @@ jobs:
echo "SHORT_SHA=${SHORT_SHA}" >> "$GITHUB_ENV"
echo "IMAGE_STABLE=${DOCKER_IMAGE_NAME}:1.0-preview" >> "$GITHUB_ENV"
echo "IMAGE_SHA=${DOCKER_IMAGE_NAME}:1.0-preview-${SHORT_SHA}" >> "$GITHUB_ENV"
- # Agent image tags (headless/agent preview)
- echo "AGENT_IMAGE=ghcr.io/${{ github.repository_owner }}/arcane-headless:1.0-preview" >> "$GITHUB_ENV"
- echo "AGENT_IMAGE_SHA=ghcr.io/${{ github.repository_owner }}/arcane-headless:1.0-preview-${SHORT_SHA}" >> "$GITHUB_ENV"
+ echo "AGENT_IMAGE_STABLE=${AGENT_IMAGE_NAME}:1.0-preview" >> "$GITHUB_ENV"
+ echo "AGENT_IMAGE_SHA=${AGENT_IMAGE_NAME}:1.0-preview-${SHORT_SHA}" >> "$GITHUB_ENV"
- - name: Build and push Docker image
- id: build-push
+ - name: Build and push manager image
+ id: build-manager
uses: docker/build-push-action@v6
with:
context: ./
@@ -89,14 +95,35 @@ jobs:
tags: |
${{ env.IMAGE_STABLE }}
${{ env.IMAGE_SHA }}
- cache-from: type=gha,scope=preview
- cache-to: type=gha,scope=preview,mode=max
+ cache-from: type=gha,scope=preview-manager
+ cache-to: type=gha,scope=preview-manager,mode=max
+
+ - name: Build and push agent image
+ id: build-agent
+ uses: docker/build-push-action@v6
+ with:
+ context: ./
+ file: docker/Dockerfile-agent-static
+ platforms: linux/amd64,linux/arm64
+ push: true
+ tags: |
+ ${{ env.AGENT_IMAGE_STABLE }}
+ ${{ env.AGENT_IMAGE_SHA }}
+ cache-from: type=gha,scope=preview-agent
+ cache-to: type=gha,scope=preview-agent,mode=max
- - name: Container image attestation
+ - name: Attest arcane image
uses: actions/attest-build-provenance@v2
with:
subject-name: '${{ env.DOCKER_IMAGE_NAME }}'
- subject-digest: ${{ steps.build-push.outputs.digest }}
+ subject-digest: ${{ steps.build-manager.outputs.digest }}
+ push-to-registry: true
+
+ - name: Attest agent image
+ uses: actions/attest-build-provenance@v2
+ with:
+ subject-name: '${{ env.AGENT_IMAGE_NAME }}'
+ subject-digest: ${{ steps.build-agent.outputs.digest }}
push-to-registry: true
- name: Compute build timestamp (UTC)
@@ -137,25 +164,25 @@ jobs:
Build timestamp (UTC): ${{ env.BUILD_TIMESTAMP }}
- This is an automated build of the 1.0.0 branch.
-
Docker images:
- ${{ env.IMAGE_STABLE }}
- ${{ env.IMAGE_SHA }}
Agent images:
- - ${{ env.AGENT_IMAGE }}
+ - ${{ env.AGENT_IMAGE_STABLE }}
- ${{ env.AGENT_IMAGE_SHA }}
- Digest:
- - ${{ steps.build-push.outputs.digest }}
+ Digests:
+ - Manager: ${{ steps.build-manager.outputs.digest }}
+ - Agent: ${{ steps.build-agent.outputs.digest }}
Commit: ${{ github.sha }}
Branch: ${{ github.ref_name }}
Notes:
- Pre-release builds are for testing only.
- - Binaries below are Linux builds produced by the CI.
+ - Binaries below are builds produced by CI.
+ - Not all functions may work on all platforms.
files: |
backend/.bin/*
env:
diff --git a/docker/Dockerfile-agent-static b/docker/Dockerfile-agent-static
new file mode 100644
index 000000000..435079f40
--- /dev/null
+++ b/docker/Dockerfile-agent-static
@@ -0,0 +1,25 @@
+FROM alpine:3
+
+ARG TARGETARCH
+ARG COMPOSE_VERSION=2.39.2
+
+WORKDIR /app
+RUN apk upgrade && apk --no-cache add ca-certificates tzdata curl su-exec \
+ && (delgroup ping || true) && (apk del iputils || true)
+
+COPY ../scripts/development/download-compose.sh /tmp/download-compose.sh
+RUN set -eux; chmod +x /tmp/download-compose.sh; \
+ /tmp/download-compose.sh "${COMPOSE_VERSION}" "/usr/local/bin/docker-compose" "${TARGETARCH}"
+
+COPY ./backend/.bin/arcane-agent-linux-${TARGETARCH} ./arcane-agent
+
+COPY --chmod=755 ../scripts/docker/entrypoint.sh /usr/local/bin/entrypoint.sh
+
+EXPOSE 3553
+ENV ENVIRONMENT=production \
+ AGENT_MODE=true \
+ GIN_MODE=release \
+ PORT=3553
+
+ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
+CMD ["./arcane-agent"]
\ No newline at end of file
diff --git a/scripts/development/build-binaries.sh b/scripts/development/build-binaries.sh
index 559fa88b2..e67ca231a 100755
--- a/scripts/development/build-binaries.sh
+++ b/scripts/development/build-binaries.sh
@@ -9,39 +9,70 @@ VERSION=$(cat ../.version | sed 's/^\s*\|\s*$//g')
LDFLAGS="-w -s -buildid=${VERSION}"
DOCKER_ONLY=false
+AGENT_BUILD=false
+
for arg in "${@:-}"; do
- if [ "$arg" = "--docker" ]; then
- DOCKER_ONLY=true
- break
- fi
+ case "$arg" in
+ --docker) DOCKER_ONLY=true ;;
+ --agent) AGENT_BUILD=true ;;
+ *) ;;
+ esac
done
+# Decide binary base name and build tags
+BINARY_BASENAME="arcane"
+BUILD_TAGS=""
+if [ "$AGENT_BUILD" = true ]; then
+ BINARY_BASENAME="arcane-agent"
+ BUILD_TAGS="exclude_frontend"
+fi
+
build_platform() {
local target="$1" os="$2" arch="$3" arm_version="${4:-}"
local ext=""
- local output_path=".bin/arcane-${target}${ext}"
+ local output_path=".bin/${BINARY_BASENAME}-${target}${ext}"
+
+ if [ -n "$arm_version" ]; then
+ printf "Building %s (GOOS=%s GOARCH=%s GOARM=%s)%s ... " \
+ "$output_path" "$os" "$arch" "$arm_version" "${BUILD_TAGS:+ tags=$BUILD_TAGS}"
+ else
+ printf "Building %s (GOOS=%s GOARCH=%s)%s ... " \
+ "$output_path" "$os" "$arch" "${BUILD_TAGS:+ tags=$BUILD_TAGS}"
+ fi
- printf "Building %s/%s%s ... " "$os" "$arch" "${arm_version:+ GOARM=$arm_version}"
+ local build_flags=()
+ if [ -n "$BUILD_TAGS" ]; then
+ build_flags=(-tags "$BUILD_TAGS")
+ fi
if [ -n "$arm_version" ]; then
GOARM="$arm_version" CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" \
- go build -ldflags="$LDFLAGS" -trimpath -o "$output_path" ./cmd/main.go
+ go build "${build_flags[@]}" -ldflags="$LDFLAGS" -trimpath -o "$output_path" ./cmd/main.go
else
CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" \
- go build -ldflags="$LDFLAGS" -trimpath -o "$output_path" ./cmd/main.go
+ go build "${build_flags[@]}" -ldflags="$LDFLAGS" -trimpath -o "$output_path" ./cmd/main.go
fi
echo "Done"
}
if [ "$DOCKER_ONLY" = true ]; then
- echo "Building for Docker platforms only (linux/amd64, linux/arm64)..."
+ echo "Version: ${VERSION}"
+ if [ "$AGENT_BUILD" = true ]; then
+ echo "Building agent binaries for Docker platforms only (linux/amd64, linux/arm64)..."
+ else
+ echo "Building binaries for Docker platforms only (linux/amd64, linux/arm64)..."
+ fi
build_platform "linux-amd64" "linux" "amd64"
build_platform "linux-arm64" "linux" "arm64"
else
echo "Version: ${VERSION}"
- echo "Building for all platforms..."
+ if [ "$AGENT_BUILD" = true ]; then
+ echo "Building agent binaries for all platforms..."
+ else
+ echo "Building binaries for all platforms..."
+ fi
build_platform "linux-amd64" "linux" "amd64"
build_platform "linux-386" "linux" "386"
build_platform "linux-arm64" "linux" "arm64"