|
| 1 | +# Upstream publishes the Harbor v2.15 component images for amd64 only; its |
| 2 | +# multi-arch build is on main but in no release yet. This rebuilds the pinned |
| 3 | +# release for every platform, one --target per image, following upstream's |
| 4 | +# make/photon/<component>/Dockerfile{,.base} and the compile targets of its |
| 5 | +# top-level Makefile. The portal is built by images/harbor-portal. |
| 6 | +# |
| 7 | +# Temporary: once the vendored chart moves to an upstream release that |
| 8 | +# publishes arm64 (expected 2.16), delete both Dockerfiles, the image target, |
| 9 | +# the image overrides in values.yaml, the build: line in the root Makefile, |
| 10 | +# the portal's ARCH_NEUTRAL entry in hack/image-builders-cross-compile.bats |
| 11 | +# and the harbor rule in .github/renovate.json, and drop the appVersion check |
| 12 | +# from the package's update target, which reads VERSION from this file. |
| 13 | +ARG VERSION=v2.15.1 |
| 14 | +ARG COMMIT=335c05f2b9507b4c7116fe69b84e31ef9f4b91dd |
| 15 | +# REGISTRY_SRC_TAG, REGISTRYVERSION, TRIVYADAPTERVERSION, TRIVYVERSION and |
| 16 | +# SWAGGER_VERSION in upstream's Makefile at VERSION; the source stage fails |
| 17 | +# when they drift. |
| 18 | +ARG DISTRIBUTION_VERSION=v2.8.3-harbor.1-rc.1 |
| 19 | +ARG DISTRIBUTION_COMMIT=086d3c33b3981cf598d0d82336a907fcf5c4c848 |
| 20 | +ARG REGISTRY_VERSION=v2.8.3-patch-redis |
| 21 | +ARG TRIVY_ADAPTER_VERSION=v0.36.0 |
| 22 | +ARG TRIVY_ADAPTER_COMMIT=f76a65660d4f4897a6c9b445ec91cbd76d685b5e |
| 23 | +ARG TRIVY_VERSION=v0.70.0 |
| 24 | +ARG SWAGGER_VERSION=v0.33.1 |
| 25 | + |
| 26 | +# Every Go stage uses this golang image; the source stage checks it against |
| 27 | +# upstream's GOBUILDIMAGE. |
| 28 | +FROM --platform=$BUILDPLATFORM golang:1.25.9@sha256:8a7adc288b77e9b787cd2695029eb54d10ae80571b21d44fed68d067ad0a9c96 AS source |
| 29 | +ARG VERSION |
| 30 | +ARG COMMIT |
| 31 | +ARG DISTRIBUTION_VERSION |
| 32 | +ARG REGISTRY_VERSION |
| 33 | +ARG TRIVY_ADAPTER_VERSION |
| 34 | +ARG TRIVY_VERSION |
| 35 | +ARG SWAGGER_VERSION |
| 36 | +RUN git clone --branch ${VERSION} --depth 1 https://github.com/goharbor/harbor /harbor \ |
| 37 | + && test "$(git -C /harbor rev-parse HEAD)" = "${COMMIT}" |
| 38 | +WORKDIR /harbor |
| 39 | +# A VERSION bump must not pair the new core with the old registry, scanner or |
| 40 | +# toolchain. |
| 41 | +RUN grep -qxF "REGISTRY_SRC_TAG=${DISTRIBUTION_VERSION}" Makefile \ |
| 42 | + && grep -qxF "REGISTRYVERSION=${REGISTRY_VERSION}" Makefile \ |
| 43 | + && grep -qxF "TRIVYADAPTERVERSION=${TRIVY_ADAPTER_VERSION}" Makefile \ |
| 44 | + && grep -qxF "TRIVYVERSION=${TRIVY_VERSION}" Makefile \ |
| 45 | + && grep -qxF "SWAGGER_VERSION=${SWAGGER_VERSION}" Makefile \ |
| 46 | + && grep -qxF "GOBUILDIMAGE=golang:$(go env GOVERSION | sed 's/^go//')" Makefile |
| 47 | +# Upstream's gen_apis: the API server package is generated, not committed. |
| 48 | +RUN go run github.com/go-swagger/go-swagger/cmd/swagger@${SWAGGER_VERSION} generate server \ |
| 49 | + --template-dir=tools/swagger/templates --exclude-main \ |
| 50 | + --additional-initialism=CVE --additional-initialism=GC --additional-initialism=OIDC \ |
| 51 | + -f api/v2.0/swagger.yaml -A harbor --target src/server/v2.0 |
| 52 | +# Upstream's versions_prepare; core serves it as the component versions. |
| 53 | +RUN printf 'VERSION_TAG: %s\nREGISTRY_VERSION: %s\nTRIVY_VERSION: %s\nTRIVY_ADAPTER_VERSION: %s\n' \ |
| 54 | + "${VERSION}" "${REGISTRY_VERSION}" "${TRIVY_VERSION}" "${TRIVY_ADAPTER_VERSION}" > make/photon/prepare/versions |
| 55 | + |
| 56 | +FROM --platform=$BUILDPLATFORM golang:1.25.9@sha256:8a7adc288b77e9b787cd2695029eb54d10ae80571b21d44fed68d067ad0a9c96 AS core-bin |
| 57 | +ARG VERSION |
| 58 | +ARG COMMIT |
| 59 | +ARG TARGETOS |
| 60 | +ARG TARGETARCH |
| 61 | +COPY --from=source /harbor/src /harbor/src |
| 62 | +WORKDIR /harbor/src/core |
| 63 | +RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build \ |
| 64 | + CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -buildvcs=false \ |
| 65 | + -ldflags "-w -s -X github.com/goharbor/harbor/src/pkg/version.GitCommit=$(echo ${COMMIT} | cut -c1-8) -X github.com/goharbor/harbor/src/pkg/version.ReleaseVersion=${VERSION}" \ |
| 66 | + -o /out/harbor_core |
| 67 | + |
| 68 | +FROM --platform=$BUILDPLATFORM golang:1.25.9@sha256:8a7adc288b77e9b787cd2695029eb54d10ae80571b21d44fed68d067ad0a9c96 AS jobservice-bin |
| 69 | +ARG TARGETOS |
| 70 | +ARG TARGETARCH |
| 71 | +COPY --from=source /harbor/src /harbor/src |
| 72 | +WORKDIR /harbor/src/jobservice |
| 73 | +RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build \ |
| 74 | + CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -buildvcs=false -o /out/harbor_jobservice |
| 75 | + |
| 76 | +FROM --platform=$BUILDPLATFORM golang:1.25.9@sha256:8a7adc288b77e9b787cd2695029eb54d10ae80571b21d44fed68d067ad0a9c96 AS registryctl-bin |
| 77 | +ARG TARGETOS |
| 78 | +ARG TARGETARCH |
| 79 | +COPY --from=source /harbor/src /harbor/src |
| 80 | +WORKDIR /harbor/src/registryctl |
| 81 | +RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build \ |
| 82 | + CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -buildvcs=false -o /out/harbor_registryctl |
| 83 | + |
| 84 | +FROM --platform=$BUILDPLATFORM golang:1.25.9@sha256:8a7adc288b77e9b787cd2695029eb54d10ae80571b21d44fed68d067ad0a9c96 AS exporter-bin |
| 85 | +ARG VERSION |
| 86 | +ARG COMMIT |
| 87 | +ARG TARGETOS |
| 88 | +ARG TARGETARCH |
| 89 | +COPY --from=source /harbor/src /harbor/src |
| 90 | +WORKDIR /harbor/src/cmd/exporter |
| 91 | +RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build \ |
| 92 | + CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -buildvcs=false \ |
| 93 | + -ldflags "-w -s -X github.com/goharbor/harbor/src/pkg/version.ReleaseVersion=${VERSION} -X github.com/goharbor/harbor/src/pkg/version.GitCommit=$(echo ${COMMIT} | cut -c1-8)" \ |
| 94 | + -o /out/harbor_exporter |
| 95 | + |
| 96 | +# Harbor's fork of distribution predates Go modules: it builds in GOPATH mode |
| 97 | +# against its vendor/ tree, as upstream's make/photon/registry/Dockerfile.binary. |
| 98 | +FROM --platform=$BUILDPLATFORM golang:1.25.9@sha256:8a7adc288b77e9b787cd2695029eb54d10ae80571b21d44fed68d067ad0a9c96 AS registry-bin |
| 99 | +ARG DISTRIBUTION_VERSION |
| 100 | +ARG DISTRIBUTION_COMMIT |
| 101 | +ARG TARGETOS |
| 102 | +ARG TARGETARCH |
| 103 | +ENV SRC=/go/src/github.com/docker/distribution |
| 104 | +RUN git clone --branch ${DISTRIBUTION_VERSION} --depth 1 https://github.com/goharbor/distribution ${SRC} \ |
| 105 | + && test "$(git -C ${SRC} rev-parse HEAD)" = "${DISTRIBUTION_COMMIT}" |
| 106 | +WORKDIR ${SRC} |
| 107 | +RUN --mount=type=cache,target=/root/.cache/go-build \ |
| 108 | + CGO_ENABLED=0 GO111MODULE=off GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -tags "include_oss include_gcs" \ |
| 109 | + -ldflags "-s -w -X github.com/docker/distribution/version.Version=${DISTRIBUTION_VERSION} -X github.com/docker/distribution/version.Revision=${DISTRIBUTION_COMMIT} -X github.com/docker/distribution/version.Package=github.com/docker/distribution" \ |
| 110 | + -o /out/registry ./cmd/registry |
| 111 | + |
| 112 | +FROM --platform=$BUILDPLATFORM golang:1.25.9@sha256:8a7adc288b77e9b787cd2695029eb54d10ae80571b21d44fed68d067ad0a9c96 AS trivy-bin |
| 113 | +ARG TRIVY_ADAPTER_VERSION |
| 114 | +ARG TRIVY_ADAPTER_COMMIT |
| 115 | +ARG TRIVY_VERSION |
| 116 | +ARG TARGETOS |
| 117 | +ARG TARGETARCH |
| 118 | +RUN git clone --branch ${TRIVY_ADAPTER_VERSION} --depth 1 https://github.com/goharbor/harbor-scanner-trivy /src \ |
| 119 | + && test "$(git -C /src rev-parse HEAD)" = "${TRIVY_ADAPTER_COMMIT}" |
| 120 | +WORKDIR /src |
| 121 | +RUN --mount=type=cache,target=/go/pkg/mod --mount=type=cache,target=/root/.cache/go-build \ |
| 122 | + CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o /out/scanner-trivy ./cmd/scanner-trivy |
| 123 | +# Checksums from the release's trivy_<version>_checksums.txt. |
| 124 | +RUN case "${TARGETARCH}" in \ |
| 125 | + amd64) arch=64bit sum=8b4376d5d6befe5c24d503f10ff136d9e0c49f9127a4279fd110b727929a5aa9 ;; \ |
| 126 | + arm64) arch=ARM64 sum=2f6bb988b553a1bbac6bdd1ce890f5e412439564e17522b88a4541b4f364fc8d ;; \ |
| 127 | + *) echo "unsupported TARGETARCH ${TARGETARCH}" >&2; exit 1 ;; \ |
| 128 | + esac \ |
| 129 | + && curl -sSfL -o /tmp/trivy.tgz https://github.com/aquasecurity/trivy/releases/download/${TRIVY_VERSION}/trivy_${TRIVY_VERSION#v}_Linux-${arch}.tar.gz \ |
| 130 | + && echo "${sum} /tmp/trivy.tgz" | sha256sum -c - \ |
| 131 | + && tar -xzf /tmp/trivy.tgz -C /out trivy |
| 132 | + |
| 133 | +FROM goharbor/photon:5.0@sha256:0e06d58615400bf2a3fe7da1175b889e2827969e3ac42e1c4010010770e6a712 AS harbor-base |
| 134 | +RUN tdnf install -y tzdata shadow >> /dev/null \ |
| 135 | + && tdnf clean all \ |
| 136 | + && groupadd -r -g 10000 harbor && useradd --no-log-init -r -m -g 10000 -u 10000 harbor \ |
| 137 | + && mkdir -p /harbor /etc/registry \ |
| 138 | + && chown -R harbor:harbor /harbor /etc/pki/tls/certs |
| 139 | + |
| 140 | +FROM harbor-base AS harbor-core |
| 141 | +COPY --from=source --chown=harbor:harbor --chmod=755 /harbor/make/photon/common/install_cert.sh /harbor/make/photon/core/entrypoint.sh /harbor/ |
| 142 | +COPY --from=core-bin --chown=harbor:harbor /out/harbor_core /harbor/ |
| 143 | +COPY --from=source --chown=harbor:harbor /harbor/src/core/views /harbor/views |
| 144 | +COPY --from=source --chown=harbor:harbor /harbor/make/migrations /harbor/migrations |
| 145 | +COPY --from=source --chown=harbor:harbor /harbor/icons /harbor/icons |
| 146 | +COPY --from=source --chown=harbor:harbor /harbor/make/photon/prepare/versions /harbor/ |
| 147 | +WORKDIR /harbor/ |
| 148 | +USER harbor |
| 149 | +ENTRYPOINT ["/harbor/entrypoint.sh"] |
| 150 | + |
| 151 | +FROM harbor-base AS harbor-jobservice |
| 152 | +COPY --from=source --chown=harbor:harbor --chmod=755 /harbor/make/photon/common/install_cert.sh /harbor/make/photon/jobservice/entrypoint.sh /harbor/ |
| 153 | +COPY --from=jobservice-bin --chown=harbor:harbor /out/harbor_jobservice /harbor/ |
| 154 | +WORKDIR /harbor/ |
| 155 | +USER harbor |
| 156 | +VOLUME ["/var/log/jobs/"] |
| 157 | +ENTRYPOINT ["/harbor/entrypoint.sh"] |
| 158 | + |
| 159 | +FROM harbor-base AS harbor-exporter |
| 160 | +COPY --from=source --chown=harbor:harbor --chmod=755 /harbor/make/photon/common/install_cert.sh /harbor/make/photon/exporter/entrypoint.sh /harbor/ |
| 161 | +COPY --from=exporter-bin --chown=harbor:harbor /out/harbor_exporter /harbor/ |
| 162 | +WORKDIR /harbor |
| 163 | +USER harbor |
| 164 | +ENTRYPOINT ["/harbor/entrypoint.sh"] |
| 165 | + |
| 166 | +FROM harbor-base AS registry-photon |
| 167 | +COPY --from=source --chown=harbor:harbor --chmod=755 /harbor/make/photon/common/install_cert.sh /harbor/make/photon/registry/entrypoint.sh /home/harbor/ |
| 168 | +COPY --from=registry-bin --chown=harbor:harbor /out/registry /usr/bin/registry_DO_NOT_USE_GC |
| 169 | +USER harbor |
| 170 | +VOLUME ["/storage"] |
| 171 | +ENTRYPOINT ["/home/harbor/entrypoint.sh"] |
| 172 | + |
| 173 | +FROM harbor-base AS harbor-registryctl |
| 174 | +COPY --from=source --chown=harbor:harbor --chmod=755 /harbor/make/photon/common/install_cert.sh /harbor/make/photon/registryctl/start.sh /home/harbor/ |
| 175 | +COPY --from=registryctl-bin --chown=harbor:harbor /out/harbor_registryctl /home/harbor/ |
| 176 | +COPY --from=registry-bin --chown=harbor:harbor /out/registry /usr/bin/registry_DO_NOT_USE_GC |
| 177 | +USER harbor |
| 178 | +VOLUME ["/var/lib/registry"] |
| 179 | +ENTRYPOINT ["/home/harbor/start.sh"] |
| 180 | + |
| 181 | +FROM goharbor/photon:5.0@sha256:0e06d58615400bf2a3fe7da1175b889e2827969e3ac42e1c4010010770e6a712 AS trivy-adapter-photon |
| 182 | +ARG TRIVY_VERSION |
| 183 | +RUN tdnf install -y rpm shadow >> /dev/null \ |
| 184 | + && tdnf clean all \ |
| 185 | + && groupadd -r -g 10000 scanner && useradd --no-log-init -m -r -g 10000 -u 10000 scanner \ |
| 186 | + && chown -R scanner:scanner /etc/pki/tls/certs |
| 187 | +COPY --from=source --chown=scanner:scanner --chmod=755 /harbor/make/photon/common/install_cert.sh /harbor/make/photon/trivy-adapter/entrypoint.sh /home/scanner/ |
| 188 | +COPY --from=trivy-bin --chown=scanner:scanner /out/trivy /usr/local/bin/trivy |
| 189 | +COPY --from=trivy-bin --chown=scanner:scanner /out/scanner-trivy /home/scanner/bin/scanner-trivy |
| 190 | +ENV TRIVY_VERSION=${TRIVY_VERSION} |
| 191 | +USER scanner |
| 192 | +ENTRYPOINT ["/home/scanner/entrypoint.sh"] |
| 193 | + |
| 194 | +FROM goharbor/photon:5.0@sha256:0e06d58615400bf2a3fe7da1175b889e2827969e3ac42e1c4010010770e6a712 AS nginx-photon |
| 195 | +RUN tdnf install -y nginx shadow >> /dev/null \ |
| 196 | + && tdnf clean all \ |
| 197 | + && groupmod -g 10000 nginx && usermod -g 10000 -u 10000 -d /home/nginx -s /bin/bash nginx \ |
| 198 | + && ln -sf /dev/stdout /var/log/nginx/access.log \ |
| 199 | + && ln -sf /dev/stderr /var/log/nginx/error.log |
| 200 | +VOLUME /var/cache/nginx /var/log/nginx /run |
| 201 | +STOPSIGNAL SIGQUIT |
| 202 | +USER nginx |
| 203 | +CMD ["nginx", "-g", "daemon off;"] |
0 commit comments