Skip to content

feat(container): restructure Containerfile with three build targets#3163

Open
ogarcia wants to merge 1 commit into
getzola:masterfrom
ogarcia:container
Open

feat(container): restructure Containerfile with three build targets#3163
ogarcia wants to merge 1 commit into
getzola:masterfrom
ogarcia:container

Conversation

@ogarcia

@ogarcia ogarcia commented May 23, 2026

Copy link
Copy Markdown
Contributor

This change slightly modifies how the Zola container is created so that it supports two variants: one distroless and the other based on Alpine Linux closing #2361

Making this change means that Zola is compiled within the container itself in a separate thread instead of being downloaded from releases. This is done to simplify the overall process of creating containers, and since it is only built in releases, it is not a change that will place an excessive load on the system (only recompiles amd64). It is also necessary because the arm64 target with musl does not compile in Release-build.

Could we explore doing it the other way? Yes, but IMHO this solution is better because it is self-contained and not dependent.

I didn't use the “next” branch because it's separate from the Zola code, and to make sure the build went smoothly, I decided to use a more stable branch.

That said, feel free to tell me to go to hell. 😂

Replace the single Dockerfile with a Containerfile supporting three flavors:

- gh-release (default): downloads a pre-built binary from GitHub releases,
  based on gcr.io/distroless/cc-debian12
- distroless: builds musl-dynamic binary from source, based on scratch
  (includes runtime musl libraries)
- alpine: builds musl-dynamic binary from source, based on alpine:3.21

Usage:
  docker build .                                        # gh-release
  docker build --target distroless .                    # scratch
  docker build --target alpine .                        # alpine
  docker build --target gh-release \
    --build-arg ZOLA_RELEASE_VERSION=v0.22.1 .          # specific release

The old Dockerfile is replaced by a symlink for backward compatibility.
The CI workflow builds both distroless and alpine images on tags.
@ogarcia

ogarcia commented May 23, 2026

Copy link
Copy Markdown
Contributor Author

One small detail I forgot to mention. If you want to see how it works, I ran a test using a hypothetical new version, v0.22.3. The GitHub action run is here, and the result is here.

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.

1 participant