Skip to content

Container Workflow

The .github/workflows/container.yml workflow builds a multi-arch container image and pushes it to ghcr.io/plexsphere/plexd when a version tag is pushed or code is merged to main. It uses Docker Buildx to produce a single manifest list covering linux/amd64 and linux/arm64 in one invocation.

Trigger Events

EventFilterDescription
pushtags: ['v*']Runs when a tag matching v* is pushed
pushbranches: [main]Runs on every push to the main branch

The workflow does not trigger on pull requests or tags that do not match the v* pattern.

Permissions

The workflow declares a minimal permissions block:

ScopeAccessReason
packageswriteRequired for pushing container images to ghcr.io
contentsreadRequired for repository checkout

No other permission scopes are granted. The workflow uses GITHUB_TOKEN (not personal access tokens).

Job: build-and-push

Single job on ubuntu-latest with timeout-minutes: 30. No matrix strategy — Buildx handles multi-platform builds natively.

StepAction / CommandPurpose
Checkoutactions/checkout@v4Clone repository at the triggered commit
Setup Buildxdocker/setup-buildx-action@v3Install Docker Buildx for multi-platform builds
Login to ghcr.iodocker/login-action@v3Authenticate to GitHub Container Registry
Extract metadatadocker/metadata-action@v5Generate image tags and labels from git context
Build and pushdocker/build-push-action@v6Build multi-arch image and push to registry

Login

Authenticates to ghcr.io using:

  • registry: ghcr.io
  • username: ${{ github.actor }}
  • password: ${{ secrets.GITHUB_TOKEN }}

Metadata

The metadata step (id: meta) configures image name and tag rules:

  • images: ghcr.io/plexsphere/plexd

Build and Push

  • context: . (repository root)
  • file: deploy/docker/Dockerfile
  • platforms: linux/amd64,linux/arm64
  • push: true
  • tags: ${{ steps.meta.outputs.tags }}
  • labels: ${{ steps.meta.outputs.labels }}

Image Tagging Strategy

TriggerTag RuleExample InputExample Tags
Tag push v1.2.3type=semver,pattern={{version}}v1.2.31.2.3
Tag push v1.2.3type=semver,pattern={{major}}.{{minor}}v1.2.31.2
Tag push v1.2.3type=semver,pattern={{major}}v1.2.31
Tag push v1.2.3(automatic)v1.2.3latest
Main pushtype=raw,value=dev,enable={{is_default_branch}}(any)dev

For non-prerelease semver tags, metadata-action automatically adds a latest tag (default behavior). Main-branch pushes produce only the dev tag — no semver tags and no latest.

Build Arguments

The build step passes version metadata as Docker build arguments, matching the ARG declarations in deploy/docker/Dockerfile:

Build ArgSourceDockerfile Default
VERSION${{ github.ref_name }} (tag name on tag push, main on branch push)dev
COMMIT${{ github.sha }}none
DATE${{ github.event.head_commit.timestamp || github.event.repository.updated_at }}unknown

These are injected into the binary via -ldflags targeting main.version, main.commit, and main.date.

Platforms

The image is built as a multi-arch manifest covering:

  • linux/amd64
  • linux/arm64

Docker Buildx sets TARGETOS and TARGETARCH automatically for each platform. The Dockerfile uses these to cross-compile the Go binary without modification.

Dockerfile

The workflow builds from deploy/docker/Dockerfile, a multi-stage image:

  1. Builder stage (golang:1.24-alpine): downloads modules, cross-compiles the plexd binary with version ldflags
  2. Runtime stage (gcr.io/distroless/static-debian12): copies the binary to /usr/local/bin/plexd, runs as non-root (UID 65534)

DaemonSet Relationship

The Kubernetes DaemonSet at deploy/kubernetes/daemonset.yaml references:

yaml
image: ghcr.io/plexsphere/plexd:latest

The metadata-action images field is set to ghcr.io/plexsphere/plexd, matching this reference. The latest tag points to the most recent non-prerelease semver tag, ensuring the DaemonSet pulls release builds. The multi-arch manifest allows scheduling on both amd64 and arm64 nodes without image name changes.

Action Versions

All actions are pinned to full SHA hashes for supply-chain hardening. The checkout pin matches ci.yml.

ActionVersionSHAPurpose
actions/checkoutv4.3.134e114876b0b11c390a56381ad16ebd13914f8d5Repository checkout
docker/setup-buildx-actionv3.12.08d2750c68a42422c14e847fe6c8ac0403b4cbd6fInstall Docker Buildx
docker/login-actionv3.7.0c94ce9fb468520275223c153574b00df6fe4bcc9Authenticate to container registry
docker/metadata-actionv5.10.0c299e40c65443455700f0fdfc63efafe5b349051Generate tags and labels from git
docker/build-push-actionv6.19.210e90e3645eae34f1e60eeb005ba3a3d33f178e8Build and push multi-platform image