Skip to content

Docker Images

Docker Images #34

Workflow file for this run

name: Docker Images
on:
# Manual trigger: build dev images from any branch for K8s testing
workflow_dispatch:
# Automatic trigger: fires after the Release workflow completes a version tag
workflow_run:
workflows: ["Release"]
types:
- completed
permissions:
contents: read
jobs:
# --------------------------------------------------------------------------
# Determine context: dev (manual) vs release (automatic)
# --------------------------------------------------------------------------
prepare:
name: Determine build context
runs-on: ubuntu-latest
if: >-
github.repository == 'schardosin/astonish' &&
(github.event_name == 'workflow_dispatch' ||
(github.event.workflow_run.conclusion == 'success' &&
startsWith(github.event.workflow_run.head_branch, 'v')))
outputs:
is_release: ${{ steps.ctx.outputs.is_release }}
version_tag: ${{ steps.ctx.outputs.version_tag }}
astonish_tags: ${{ steps.ctx.outputs.astonish_tags }}
incus_tags: ${{ steps.ctx.outputs.incus_tags }}
sandbox_base_tags: ${{ steps.ctx.outputs.sandbox_base_tags }}
sandbox_openshell_tags: ${{ steps.ctx.outputs.sandbox_openshell_tags }}
steps:
- name: Determine context
id: ctx
env:
EVENT_NAME: ${{ github.event_name }}
WORKFLOW_HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}
run: |
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
echo "is_release=false" >> "$GITHUB_OUTPUT"
echo "version_tag=dev" >> "$GITHUB_OUTPUT"
echo "astonish_tags=schardosin/astonish:dev" >> "$GITHUB_OUTPUT"
echo "incus_tags=schardosin/astonish-incus:dev" >> "$GITHUB_OUTPUT"
echo "sandbox_base_tags=schardosin/astonish-sandbox-base:dev" >> "$GITHUB_OUTPUT"
echo "sandbox_openshell_tags=schardosin/astonish-sandbox-openshell:dev" >> "$GITHUB_OUTPUT"
else
TAG="$WORKFLOW_HEAD_BRANCH"
echo "is_release=true" >> "$GITHUB_OUTPUT"
echo "version_tag=$TAG" >> "$GITHUB_OUTPUT"
ASTONISH_TAGS="schardosin/astonish:${TAG}"
ASTONISH_TAGS="${ASTONISH_TAGS},schardosin/astonish:latest"
echo "astonish_tags=$ASTONISH_TAGS" >> "$GITHUB_OUTPUT"
INCUS_TAGS="schardosin/astonish-incus:${TAG}"
INCUS_TAGS="${INCUS_TAGS},schardosin/astonish-incus:latest"
echo "incus_tags=$INCUS_TAGS" >> "$GITHUB_OUTPUT"
SANDBOX_BASE_TAGS="schardosin/astonish-sandbox-base:${TAG}"
SANDBOX_BASE_TAGS="${SANDBOX_BASE_TAGS},schardosin/astonish-sandbox-base:latest"
echo "sandbox_base_tags=$SANDBOX_BASE_TAGS" >> "$GITHUB_OUTPUT"
SANDBOX_OPENSHELL_TAGS="schardosin/astonish-sandbox-openshell:${TAG}"
SANDBOX_OPENSHELL_TAGS="${SANDBOX_OPENSHELL_TAGS},schardosin/astonish-sandbox-openshell:latest"
echo "sandbox_openshell_tags=$SANDBOX_OPENSHELL_TAGS" >> "$GITHUB_OUTPUT"
fi
# --------------------------------------------------------------------------
# Build and push schardosin/astonish (multi-arch)
# Uses the multi-stage Dockerfile which handles cross-compilation internally
# --------------------------------------------------------------------------
build-astonish:
name: Build and push astonish
runs-on: ubuntu-latest
needs: prepare
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
ref: ${{ needs.prepare.outputs.is_release == 'true' && needs.prepare.outputs.version_tag || github.ref }}
# Build frontend natively on the runner (avoids slow/hanging Vite build under QEMU arm64)
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: '24'
cache: 'npm'
cache-dependency-path: web/package-lock.json
- name: Build frontend
run: |
cd web
npm ci
npm run build
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
- name: Cross-compile Linux binaries
env:
VERSION_TAG: ${{ needs.prepare.outputs.version_tag }}
run: |
touch web/embed.go
LDFLAGS="-s -w -X github.com/schardosin/astonish/cmd/astonish.Version=${VERSION_TAG}"
echo "Building linux/amd64..."
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="$LDFLAGS" -o astonish-linux-amd64 .
echo "Building linux/arm64..."
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -ldflags="$LDFLAGS" -o astonish-linux-arm64 .
ls -la astonish-linux-*
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v7
with:
context: .
file: docker/astonish/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ needs.prepare.outputs.astonish_tags }}
build-args: |
VERSION=${{ needs.prepare.outputs.version_tag }}
cache-from: type=gha
cache-to: type=gha,mode=max
# --------------------------------------------------------------------------
# Build and push schardosin/astonish-incus (multi-arch)
# Cross-compiles Go binaries on the runner, then builds the Ubuntu-based image
# --------------------------------------------------------------------------
build-incus:
name: Build and push astonish-incus
runs-on: ubuntu-latest
needs: prepare
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
ref: ${{ needs.prepare.outputs.is_release == 'true' && needs.prepare.outputs.version_tag || github.ref }}
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: '24'
cache: 'npm'
cache-dependency-path: web/package-lock.json
- name: Build frontend
run: |
cd web
npm ci
npm run build
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: 'go.mod'
- name: Cross-compile Linux binaries
env:
VERSION_TAG: ${{ needs.prepare.outputs.version_tag }}
run: |
touch web/embed.go
LDFLAGS="-s -w -X github.com/schardosin/astonish/cmd/astonish.Version=${VERSION_TAG}"
echo "Building linux/amd64..."
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="$LDFLAGS" -o astonish-linux-amd64 .
echo "Building linux/arm64..."
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -ldflags="$LDFLAGS" -o astonish-linux-arm64 .
ls -la astonish-linux-*
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v7
with:
context: .
file: docker/incus/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ needs.prepare.outputs.incus_tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
# --------------------------------------------------------------------------
# Build and push schardosin/astonish-sandbox-base (multi-arch)
# Uses the multi-stage docker/sandbox-base/Dockerfile which compiles the
# entrypoint script generator and astonish binary internally, then produces
# a minimal Debian-slim runtime image with fuse-overlayfs.
# --------------------------------------------------------------------------
build-sandbox-base:
name: Build and push astonish-sandbox-base
runs-on: ubuntu-latest
needs: prepare
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
ref: ${{ needs.prepare.outputs.is_release == 'true' && needs.prepare.outputs.version_tag || github.ref }}
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: '24'
cache: 'npm'
cache-dependency-path: web/package-lock.json
- name: Build frontend
run: |
cd web
npm ci
npm run build
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v7
with:
context: .
file: docker/sandbox-base/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ needs.prepare.outputs.sandbox_base_tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
# --------------------------------------------------------------------------
# Build and push schardosin/astonish-sandbox-openshell (amd64 only)
# Full-featured sandbox for NVIDIA OpenShell backend: CloakBrowser, KasmVNC,
# dev tools. Based on ghcr.io/nvidia/openshell-community/sandboxes/base which
# is amd64-only.
# --------------------------------------------------------------------------
build-sandbox-openshell:
name: Build and push astonish-sandbox-openshell
runs-on: ubuntu-latest
needs: prepare
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
ref: ${{ needs.prepare.outputs.is_release == 'true' && needs.prepare.outputs.version_tag || github.ref }}
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: '24'
cache: 'npm'
cache-dependency-path: web/package-lock.json
- name: Build frontend
run: |
cd web
npm ci
npm run build
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v7
with:
context: .
file: docker/sandbox-openshell/Dockerfile
platforms: linux/amd64
push: true
tags: ${{ needs.prepare.outputs.sandbox_openshell_tags }}
cache-from: type=gha
cache-to: type=gha,mode=max