Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ jobs:
permissions:
contents: read
packages: write
outputs:
# The bare short SHA tag, consumed by the downstream deployment test.
image_tag: ${{ steps.tag.outputs.value }}

steps:
- name: Checkout
Expand All @@ -35,6 +38,10 @@ jobs:
type=raw,value=latest,enable={{is_default_branch}}
type=sha,prefix=

- name: Derive the short SHA tag
id: tag
run: echo "value=$(echo ${{ github.sha }} | cut -c1-7)" >> "$GITHUB_OUTPUT"

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4

Expand All @@ -50,10 +57,27 @@ jobs:
uses: docker/build-push-action@v7
with:
context: .
# linux/amd64 only until now, which broke Apple Silicon and ARM
# runners. Buildx was already set up; the platforms list was simply
# never passed.
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max


# Verify the freshly published image actually deploys. Without this, a change
# here that breaks the deployment manifests stays invisible until somebody
# happens to touch the deploy repo.
deployment-test:
name: Deployment test
needs: build
if: github.event_name != 'pull_request'
uses: kube-workspaces/deploy/.github/workflows/deployment-test.yaml@main
with:
component: controller
# docker/metadata-action is configured with type=sha,prefix= so the tag is
# the bare short SHA. Take it from the build job rather than reconstructing
# it here, so the two cannot drift.
image_tag: ${{ needs.build.outputs.image_tag }}
12 changes: 10 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
FROM golang:1.24-alpine AS builder
# --platform=$BUILDPLATFORM keeps the toolchain running natively; the target
# architecture is passed to the compiler instead. Without this, a multi-arch
# build emulates the whole Go compile under QEMU, which is an order of magnitude
# slower and occasionally flaky.
FROM --platform=$BUILDPLATFORM golang:1.24-alpine AS builder

ARG TARGETOS
ARG TARGETARCH

WORKDIR /workspace
COPY go.mod go.sum ./
RUN go mod download

COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -a -o manager ./cmd/main.go
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} \
go build -a -o manager ./cmd/main.go

FROM gcr.io/distroless/static:nonroot
LABEL org.opencontainers.image.source="https://github.com/kube-workspaces/controller"
Expand Down
Loading