From 41183693b0104fc19939a73c89c2f3a9f6f946b7 Mon Sep 17 00:00:00 2001 From: Ramkumar Chinchani <45800463+rchincha@users.noreply.github.com> Date: Sun, 3 Aug 2025 08:58:30 -0700 Subject: [PATCH] feat(freebsd): add support native freebsd container images (#3256) * feat(freebsd): add support native freebsd container images Fixes issue #1663 freebsd is now building and releasing official freebsd OCI container images https://hub.docker.com/r/freebsd/freebsd-runtime/tags Signed-off-by: Ramkumar Chinchani * fix: add freebsd support in publish workflow Signed-off-by: Ramkumar Chinchani * fix: bump stacker version Signed-off-by: Ramkumar Chinchani * fix: disable non-functional darwin OCI image builds darwin OCI images are non-functional until we get a usable base image. Remove them. Signed-off-by: Ramkumar Chinchani * fix: set freebsd-static as base image for FreeBSD images Signed-off-by: Ramkumar Chinchani --------- Signed-off-by: Ramkumar Chinchani --- .github/workflows/publish.yaml | 20 ++++++++++++++++++-- Makefile | 23 +++++++++++++++++------ build/Dockerfile | 3 ++- build/Dockerfile-conformance | 3 ++- build/Dockerfile-minimal | 3 ++- build/Dockerfile-zb | 3 ++- build/Dockerfile-zxp | 3 ++- build/multiarch-zb.json | 6 +++--- build/multiarch-zot-minimal.json | 6 +++--- build/multiarch-zot.json | 6 +++--- build/multiarch-zxp.json | 6 +++--- build/stacker-conformance.yaml | 2 +- build/stacker-minimal.yaml | 2 +- build/stacker-zb.yaml | 2 +- build/stacker-zxp.yaml | 2 +- build/stacker.yaml | 2 +- 16 files changed, 62 insertions(+), 30 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 36b023d8..892701db 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -15,9 +15,17 @@ jobs: packages: write strategy: matrix: - os: [linux, darwin] + os: [linux, freebsd] arch: [amd64, arm64] steps: + - name: Setup base image + run: | + if [ ${{ matrix.os }} = 'freebsd' ]; then + echo "BASE_IMAGE=freebsd/freebsd-static:14.3" >> "$GITHUB_ENV" + else + ARCH=${{ matrix.arch }} + echo "BASE_IMAGE=gcr.io/distroless/base-debian12:latest-${ARCH}" >> "$GITHUB_ENV" + fi - name: Check out the repo uses: actions/checkout@v4 - name: Log in to GitHub Docker Registry @@ -29,6 +37,7 @@ jobs: - name: Build and push zot container image uses: project-stacker/stacker-build-push-action@main with: + version: v1.1.0-rc3 file: 'build/stacker.yaml' build-args: | RELEASE_TAG=${{ github.event.release.tag_name }} @@ -36,6 +45,7 @@ jobs: OS=${{ matrix.os }} ARCH=${{ matrix.arch }} REPO_NAME=zot-${{ matrix.os }}-${{ matrix.arch }} + BASE_IMAGE=${{ env.BASE_IMAGE }} url: docker://ghcr.io/${{ github.repository_owner }} tags: ${{ github.event.release.tag_name }} latest username: ${{ github.actor }} @@ -43,6 +53,7 @@ jobs: - name: Build and push zot-minimal container image uses: project-stacker/stacker-build-push-action@main with: + version: v1.1.0-rc3 file: 'build/stacker-minimal.yaml' build-args: | RELEASE_TAG=${{ github.event.release.tag_name }} @@ -51,6 +62,7 @@ jobs: ARCH=${{ matrix.arch }} EXT=-minimal REPO_NAME=zot-minimal-${{ matrix.os }}-${{ matrix.arch }} + BASE_IMAGE=${{ env.BASE_IMAGE }} url: docker://ghcr.io/${{ github.repository_owner }} tags: ${{ github.event.release.tag_name }} latest username: ${{ github.actor }} @@ -58,6 +70,7 @@ jobs: - name: Build and push zot-exporter container image uses: project-stacker/stacker-build-push-action@main with: + version: v1.1.0-rc3 file: 'build/stacker-zxp.yaml' build-args: | RELEASE_TAG=${{ github.event.release.tag_name }} @@ -65,6 +78,7 @@ jobs: OS=${{ matrix.os }} ARCH=${{ matrix.arch }} REPO_NAME=zxp-${{ matrix.os }}-${{ matrix.arch }} + BASE_IMAGE=${{ env.BASE_IMAGE }} url: docker://ghcr.io/${{ github.repository_owner }} tags: ${{ github.event.release.tag_name }} latest username: ${{ github.actor }} @@ -72,6 +86,7 @@ jobs: - name: Build and push zb container image uses: project-stacker/stacker-build-push-action@main with: + version: v1.1.0-rc3 file: 'build/stacker-zb.yaml' build-args: | RELEASE_TAG=${{ github.event.release.tag_name }} @@ -79,6 +94,7 @@ jobs: OS=${{ matrix.os }} ARCH=${{ matrix.arch }} REPO_NAME=zb-${{ matrix.os }}-${{ matrix.arch }} + BASE_IMAGE=${{ env.BASE_IMAGE }} url: docker://ghcr.io/${{ github.repository_owner }} tags: ${{ github.event.release.tag_name }} latest username: ${{ github.actor }} @@ -209,7 +225,7 @@ jobs: packages: read strategy: matrix: - os: [linux, darwin] + os: [linux, freebsd] arch: [amd64, arm64] steps: - name: Log in to GitHub Docker Registry diff --git a/Makefile b/Makefile index ae351e6e..66b7372f 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ ZUI_REPO_OWNER := project-zot ZUI_REPO_NAME := zui SWAGGER_VERSION := v1.16.2 STACKER := $(TOOLSDIR)/bin/stacker -STACKER_VERSION := v0.40.5 +STACKER_VERSION := v1.1.0-rc3 BATS := $(TOOLSDIR)/bin/bats TESTDATA := $(TOP_LEVEL)/test/data OS ?= $(shell go env GOOS) @@ -61,8 +61,10 @@ UI_DEPENDENCIES := search,mgmt,userprefs # freebsd is not supported for pie builds if CGO is disabled # see supported platforms at https://cs.opensource.google/go/go/+/master:src/internal/platform/supported.go;l=222-231;drc=d7fcb5cf80953f1d63246f1ae9defa60c5ce2d76 BUILDMODE_FLAGS := -buildmode=pie +BASE_IMAGE=gcr.io/distroless/base-debian12:latest-$(ARCH) ifeq ($(OS),freebsd) BUILDMODE_FLAGS= + BASE_IMAGE=freebsd/freebsd-static:14.3 endif BIN_EXT := ifeq ($(OS),windows) @@ -440,7 +442,9 @@ verify-gql-committed: .PHONY: binary-container binary-container: - ${CONTAINER_RUNTIME} build ${BUILD_ARGS} -f build/Dockerfile -t zot-build:latest . + ${CONTAINER_RUNTIME} build ${BUILD_ARGS} \ + --build-arg BASE_IMAGE=$(BASE_IMAGE) \ + -f build/Dockerfile -t zot-build:latest . .PHONY: run-container run-container: @@ -449,7 +453,9 @@ run-container: .PHONY: binary-minimal-container binary-minimal-container: - ${CONTAINER_RUNTIME} build ${BUILD_ARGS} -f build/Dockerfile-minimal -t zot-minimal:latest . + ${CONTAINER_RUNTIME} build ${BUILD_ARGS} \ + --build-arg BASE_IMAGE=$(BASE_IMAGE) \ + -f build/Dockerfile-minimal -t zot-minimal:latest . .PHONY: run-minimal-container run-minimal-container: @@ -458,7 +464,9 @@ run-minimal-container: .PHONY: binary-exporter-container binary-exporter-container: - ${CONTAINER_RUNTIME} build ${BUILD_ARGS} -f build/Dockerfile-zxp -t zxp:latest . + ${CONTAINER_RUNTIME} build ${BUILD_ARGS} \ + --build-arg BASE_IMAGE=$(BASE_IMAGE) \ + -f build/Dockerfile-zxp -t zxp:latest . .PHONY: run-exporter-container run-exporter-container: @@ -472,11 +480,14 @@ oci-image: $(STACKER) --substitute ARCH=$(ARCH) \ --substitute OS=$(OS) \ --substitute RELEASE_TAG=$(RELEASE_TAG) \ - --substitute REPO_NAME=zot-$(OS)-$(ARCH) + --substitute REPO_NAME=zot-$(OS)-$(ARCH) \ + --substitute BASE_IMAGE=$(BASE_IMAGE) .PHONY: docker-image docker-image: - ${CONTAINER_RUNTIME} buildx build --platform $(OS)/$(ARCH) -f build/Dockerfile . + ${CONTAINER_RUNTIME} buildx build --platform $(OS)/$(ARCH) \ + --build-arg BASE_IMAGE=$(BASE_IMAGE) \ + -f build/Dockerfile . $(BATS): rm -rf bats-core; \ diff --git a/build/Dockerfile b/build/Dockerfile index dc1d046d..f7dfdb57 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -28,7 +28,8 @@ RUN echo '{\n\ # --- # Stage 2: Final image with nothing but certs, binary, and default config file # --- -FROM gcr.io/distroless/base-debian12 AS final +ARG BASE_IMAGE +FROM $BASE_IMAGE AS final ARG TARGETOS ARG TARGETARCH COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt diff --git a/build/Dockerfile-conformance b/build/Dockerfile-conformance index f95cd477..efa7d4b1 100644 --- a/build/Dockerfile-conformance +++ b/build/Dockerfile-conformance @@ -24,7 +24,8 @@ storage:\n\ # --- # Stage 2: Final image with nothing but certs, binary, and default config file # --- -FROM gcr.io/distroless/base-debian12 AS final +ARG BASE_IMAGE +FROM $BASE_IMAGE AS final ARG TARGETOS ARG TARGETARCH COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt diff --git a/build/Dockerfile-minimal b/build/Dockerfile-minimal index 15e1a819..964401e8 100644 --- a/build/Dockerfile-minimal +++ b/build/Dockerfile-minimal @@ -27,7 +27,8 @@ RUN echo '{\n\ # --- # Stage 2: Final image with nothing but certs, binary, and default config file # --- -FROM gcr.io/distroless/base-debian12 AS final +ARG BASE_IMAGE +FROM $BASE_IMAGE AS final ARG TARGETOS ARG TARGETARCH COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt diff --git a/build/Dockerfile-zb b/build/Dockerfile-zb index 5ad577b5..138d0c87 100644 --- a/build/Dockerfile-zb +++ b/build/Dockerfile-zb @@ -15,7 +15,8 @@ RUN make COMMIT=$COMMIT OS=$TARGETOS ARCH=$TARGETARCH clean bench # --- # Stage 2: Final image with nothing but certs, binary, and default config file # --- -FROM gcr.io/distroless/base-debian12 AS final +ARG BASE_IMAGE +FROM BASE_IMAGE AS final ARG TARGETOS ARG TARGETARCH COPY --from=builder /go/src/github.com/project-zot/zot/bin/zb-$TARGETOS-$TARGETARCH /usr/bin/zb diff --git a/build/Dockerfile-zxp b/build/Dockerfile-zxp index 19d037c9..bd0c5645 100644 --- a/build/Dockerfile-zxp +++ b/build/Dockerfile-zxp @@ -28,7 +28,8 @@ RUN echo '{\n\ # --- # Stage 2: Final image with nothing but binary and default config file # --- -FROM gcr.io/distroless/base-debian12 AS final +ARG BASE_IMAGE +FROM $BASE_IMAGE AS final ARG TARGETOS ARG TARGETARCH COPY --from=builder /go/src/github.com/project-zot/zot/bin/zxp-$TARGETOS-$TARGETARCH /zxp diff --git a/build/multiarch-zb.json b/build/multiarch-zb.json index 3be7e108..ee85e6d2 100644 --- a/build/multiarch-zb.json +++ b/build/multiarch-zb.json @@ -3,7 +3,7 @@ "source_repos": [ "zb-linux-amd64", "zb-linux-arm64", - "zb-darwin-amd64", - "zb-darwin-arm64" + "zb-freebsd-amd64", + "zb-freebsd-arm64" ] -} \ No newline at end of file +} diff --git a/build/multiarch-zot-minimal.json b/build/multiarch-zot-minimal.json index 8ea4f08b..c549f6e7 100644 --- a/build/multiarch-zot-minimal.json +++ b/build/multiarch-zot-minimal.json @@ -3,7 +3,7 @@ "source_repos": [ "zot-minimal-linux-amd64", "zot-minimal-linux-arm64", - "zot-minimal-darwin-amd64", - "zot-minimal-darwin-arm64" + "zot-minimal-freebsd-amd64", + "zot-minimal-freebsd-arm64" ] -} \ No newline at end of file +} diff --git a/build/multiarch-zot.json b/build/multiarch-zot.json index 604fc204..cdeecbcf 100644 --- a/build/multiarch-zot.json +++ b/build/multiarch-zot.json @@ -3,7 +3,7 @@ "source_repos": [ "zot-linux-amd64", "zot-linux-arm64", - "zot-darwin-amd64", - "zot-darwin-arm64" + "zot-freebsd-amd64", + "zot-freebsd-arm64" ] -} \ No newline at end of file +} diff --git a/build/multiarch-zxp.json b/build/multiarch-zxp.json index d1832e36..13845ca9 100644 --- a/build/multiarch-zxp.json +++ b/build/multiarch-zxp.json @@ -3,7 +3,7 @@ "source_repos": [ "zxp-linux-amd64", "zxp-linux-arm64", - "zxp-darwin-amd64", - "zxp-darwin-arm64" + "zxp-freebsd-amd64", + "zxp-freebsd-arm64" ] -} \ No newline at end of file +} diff --git a/build/stacker-conformance.yaml b/build/stacker-conformance.yaml index be9721ca..8875f89d 100644 --- a/build/stacker-conformance.yaml +++ b/build/stacker-conformance.yaml @@ -48,7 +48,7 @@ build: arch: ${{ARCH}} from: type: docker - url: docker://gcr.io/distroless/base-debian12:latest-${{ARCH}} + url: docker://${{BASE_IMAGE}} overlay_dirs: - source: ../.build/${{REPO_NAME}}/binary dest: /usr/local/bin diff --git a/build/stacker-minimal.yaml b/build/stacker-minimal.yaml index 14672e13..a30c60a8 100644 --- a/build/stacker-minimal.yaml +++ b/build/stacker-minimal.yaml @@ -47,7 +47,7 @@ build: arch: ${{ARCH}} from: type: docker - url: docker://gcr.io/distroless/base-debian12:latest-${{ARCH}} + url: docker://${{BASE_IMAGE}} overlay_dirs: - source: ../.build/${{REPO_NAME}}/binary dest: /usr/local/bin diff --git a/build/stacker-zb.yaml b/build/stacker-zb.yaml index ee0fd6f0..4eae6193 100644 --- a/build/stacker-zb.yaml +++ b/build/stacker-zb.yaml @@ -26,7 +26,7 @@ build: arch: ${{ARCH}} from: type: docker - url: docker://gcr.io/distroless/base-debian12:latest-${{ARCH}} + url: docker://${{BASE_IMAGE}} overlay_dirs: - source: ../.build/${{REPO_NAME}}/binary dest: /usr/local/bin diff --git a/build/stacker-zxp.yaml b/build/stacker-zxp.yaml index 68f930b6..bb40cb53 100644 --- a/build/stacker-zxp.yaml +++ b/build/stacker-zxp.yaml @@ -46,7 +46,7 @@ build: arch: ${{ARCH}} from: type: docker - url: docker://gcr.io/distroless/base-debian12:latest-${{ARCH}} + url: docker://${{BASE_IMAGE}} overlay_dirs: - source: ../.build/${{REPO_NAME}}/binary dest: /usr/local/bin diff --git a/build/stacker.yaml b/build/stacker.yaml index f4e05a6a..126eff20 100644 --- a/build/stacker.yaml +++ b/build/stacker.yaml @@ -62,7 +62,7 @@ build: arch: ${{ARCH}} from: type: docker - url: docker://gcr.io/distroless/base-debian12:latest-${{ARCH}} + url: docker://${{BASE_IMAGE}} overlay_dirs: - source: ../.build/${{REPO_NAME}}/binary dest: /usr/local/bin