115fa86023
Lets a caller point at a non-default Dockerfile while keeping the build context broader. Needed for repos with multiple binaries sharing internal packages (api/Dockerfile + worker/Dockerfile, build context at repo root). Empty default preserves prior behavior. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
57 lines
1.8 KiB
YAML
57 lines
1.8 KiB
YAML
name: Build Image
|
|
description: Build a container image locally with buildx and optionally run a smoke test. Does not push to registry.
|
|
inputs:
|
|
image:
|
|
description: Full image name without tag (e.g. code.fritzlab.net/fritzlab/chrony)
|
|
required: true
|
|
context:
|
|
description: Docker build context path
|
|
required: false
|
|
default: .
|
|
dockerfile:
|
|
description: |
|
|
Path to the Dockerfile, relative to the context (or absolute under
|
|
$GITHUB_WORKSPACE). Defaults to "Dockerfile" inside the context.
|
|
Use this for monorepos where the build context is the repo root but
|
|
the Dockerfile lives in a subdir (e.g. dockerfile: api/Dockerfile).
|
|
required: false
|
|
default: ''
|
|
build-args:
|
|
description: Multiline KEY=VALUE pairs passed to docker build
|
|
required: false
|
|
smoke-test:
|
|
description: |
|
|
Shell command run after build. The image is exposed as $IMAGE
|
|
(e.g. "docker run --rm --entrypoint /usr/sbin/chronyd $IMAGE -v").
|
|
Empty = no test.
|
|
required: false
|
|
default: ''
|
|
outputs:
|
|
tag:
|
|
description: Numeric tag assigned to the built image (= github.run_number)
|
|
value: ${{ github.run_number }}
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- name: Build (load to local docker)
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: ${{ inputs.context }}
|
|
file: ${{ inputs.dockerfile }}
|
|
push: false
|
|
load: true
|
|
provenance: false
|
|
network: host
|
|
build-args: ${{ inputs.build-args }}
|
|
tags: ${{ inputs.image }}:${{ github.run_number }}
|
|
|
|
- name: Smoke test
|
|
if: ${{ inputs.smoke-test != '' }}
|
|
shell: bash
|
|
env:
|
|
IMAGE: ${{ inputs.image }}:${{ github.run_number }}
|
|
run: |
|
|
set -euo pipefail
|
|
echo "+ ${{ inputs.smoke-test }}"
|
|
${{ inputs.smoke-test }}
|