Skip to content

build: migrate from Dapper to single-Dockerfile build system#276

Open
bk201 wants to merge 2 commits into
harvester:masterfrom
bk201:wip-buildx
Open

build: migrate from Dapper to single-Dockerfile build system#276
bk201 wants to merge 2 commits into
harvester:masterfrom
bk201:wip-buildx

Conversation

@bk201
Copy link
Copy Markdown
Contributor

@bk201 bk201 commented May 20, 2026

Problem:

Replace the Dapper-driven build (Dockerfile.dapper + scripts/entry/ci/ default/release) with a single Dockerfile whose stages are driven directly by make <target> via docker build --target.

Solution:

  • Dockerfile: add builder, base, build, validate, validate-ci, test, generate, and generate-manifest stages (with scratch output stages where files need to be extracted to the host)
  • Makefile: rewrite around DOCKER_BUILD, MK_REPO_ID-scoped BuildKit caches, and a gen-version-env prerequisite on every docker build target
  • scripts/version: add .git availability guard with .version_env fallback so container builds work without a .git directory; replace go env GOHOSTARCH with uname -m for host-side use; write .version_env after each normal (non-CI) invocation
  • .dockerignore: exclude .git to keep the build context lean
  • .gitignore: exclude the generated scripts/.version_env artifact

Deleted: Dockerfile.dapper, scripts/ci, scripts/default, scripts/entry, scripts/release (all replaced by Makefile targets).

Related Issue:
harvester/harvester#10608

Test plan:

make should works

Replace the Dapper-driven build (Dockerfile.dapper + scripts/entry/ci/
default/release) with a single Dockerfile whose stages are driven
directly by `make <target>` via `docker build --target`.

- Dockerfile: add builder, base, build, validate, validate-ci, test,
  generate, and generate-manifest stages (with scratch output stages
  where files need to be extracted to the host)
- Makefile: rewrite around DOCKER_BUILD, MK_REPO_ID-scoped BuildKit
  caches, and a gen-version-env prerequisite on every docker build target
- scripts/version: add .git availability guard with .version_env
  fallback so container builds work without a .git directory; replace
  `go env GOHOSTARCH` with `uname -m` for host-side use; write
  .version_env after each normal (non-CI) invocation
- .dockerignore: exclude .git to keep the build context lean
- .gitignore: exclude the generated scripts/.version_env artifact

Deleted: Dockerfile.dapper, scripts/ci, scripts/default, scripts/entry,
scripts/release (all replaced by Makefile targets).

Signed-off-by: Kiefer Chang <kiefer.chang@suse.com>
Copilot AI review requested due to automatic review settings May 20, 2026 03:04
@bk201 bk201 requested review from a team, Vicente-Cheng, Yu-Jack and tserong as code owners May 20, 2026 03:04
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR replaces the previous Dapper-driven build/CI entrypoint scripts with a single multi-stage Dockerfile and a Makefile that drives builds via docker build --target ..., while adding a .version_env fallback to support container builds where .git is excluded from the Docker context.

Changes:

  • Added a new multi-stage Dockerfile with dedicated stages for build/validate/test/generate outputs and local extraction via --output type=local.
  • Rewrote the Makefile to orchestrate the new Docker build targets, BuildKit caches, and a gen-version-env prerequisite.
  • Updated version/package scripts and ignore files to support .git-less container builds and track the generated scripts/.version_env.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
scripts/version Adds .git-availability guard and .version_env fallback; updates arch detection and writes a generated env file.
scripts/package Ensures packaging scripts run from the scripts directory for consistent relative-path behavior.
Makefile Replaces Dapper invocation with docker build --target workflow, BuildKit cache IDs, and new build targets.
Dockerfile Introduces multi-stage build system with cache mounts and output stages for artifacts extraction.
.gitignore Ignores generated scripts/.version_env.
.dockerignore Excludes .git (and adds a few editor/temp patterns) to reduce build context size.
Dockerfile.dapper Removed (superseded by new Dockerfile + Makefile targets).
scripts/release Removed (superseded by Makefile targets).
scripts/entry Removed (no longer needed without Dapper entrypoint pattern).
scripts/default Removed (superseded by Makefile targets).
scripts/ci Removed (superseded by Makefile targets).
Comments suppressed due to low confidence (1)

scripts/version:45

  • if [[ -n ${BUILD_FOR_CI} ]]; then ... return ... isn’t a reliable early-exit when scripts/version is executed (e.g., make gen-version-env) because return fails outside of a sourced context and the script continues. When fixing this (return vs exit), ensure CI still generates scripts/.version_env before Docker builds (since .git is excluded from the build context and container stages may rely on the fallback).
if [[ -n ${BUILD_FOR_CI} ]]; then
    TAG=${COMMIT}
    return 0 2>/dev/null || true
fi

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/version
Comment on lines +9 to +18
if ! git -C "${TOP_DIR}" rev-parse HEAD &>/dev/null 2>&1; then
if [[ -f "${_VERSION_ENV}" ]]; then
# shellcheck source=/dev/null
source "${_VERSION_ENV}"
return 0 2>/dev/null || true
fi
echo "ERROR: git is unavailable and no pre-generated scripts/.version_env was found." >&2
echo "Run 'make gen-version-env' on a host with git access first." >&2
return 1 2>/dev/null || exit 1
fi
Comment thread Makefile
MK_HOST_ARCH := $(shell uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/')
export MK_HOST_ARCH

MK_REPO_ID := $(shell echo -n "$(ROOT)$$(cat /etc/machine-id 2>/dev/null)" | sha256sum | cut -c1-8)
Seems not required in the CI worker.

Signed-off-by: Kiefer Chang <kiefer.chang@suse.com>
@bk201
Copy link
Copy Markdown
Contributor Author

bk201 commented May 20, 2026

@tserong can you review and take over the PR? I've done my best, but there may still be some missing pieces.

@tserong
Copy link
Copy Markdown
Member

tserong commented May 20, 2026

Sure @bk201, will do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants