build: migrate from Dapper to single-Dockerfile build system#276
Open
bk201 wants to merge 2 commits into
Open
Conversation
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>
There was a problem hiding this comment.
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
Dockerfilewith dedicated stages for build/validate/test/generate outputs and local extraction via--output type=local. - Rewrote the
Makefileto orchestrate the new Docker build targets, BuildKit caches, and agen-version-envprerequisite. - Updated version/package scripts and ignore files to support
.git-less container builds and track the generatedscripts/.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) becausereturnfails 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 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 |
| 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>
Contributor
Author
|
@tserong can you review and take over the PR? I've done my best, but there may still be some missing pieces. |
Member
|
Sure @bk201, will do. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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>viadocker build --target.Solution:
go env GOHOSTARCHwithuname -mfor host-side use; write .version_env after each normal (non-CI) invocationDeleted: 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