浏览代码

test/integration: Download the registry binary

We used to have to clone and build the registry v2 but now that we have
updated the version we can directtly copy the binary from the official
distribution/distribution image.

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
Djordje Lukic 1 年之前
父节点
当前提交
78828f9b58
共有 1 个文件被更改,包括 14 次插入9 次删除
  1. 14 9
      Dockerfile

+ 14 - 9
Dockerfile

@@ -19,6 +19,12 @@ ARG SYSTEMD="false"
 ARG DEBIAN_FRONTEND=noninteractive
 ARG DEBIAN_FRONTEND=noninteractive
 ARG DOCKER_STATIC=1
 ARG DOCKER_STATIC=1
 
 
+# REGISTRY_VERSION specifies the version of the registry to download from
+# https://hub.docker.com/r/distribution/distribution. This version of
+# the registry is used to test schema 2 manifests. Generally,  the version
+# specified here should match a current release.
+ARG REGISTRY_VERSION=2.8.2
+
 # cross compilation helper
 # cross compilation helper
 FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
 FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
 
 
@@ -56,11 +62,7 @@ RUN git init . && git remote add origin "https://github.com/distribution/distrib
 
 
 FROM base AS registry
 FROM base AS registry
 WORKDIR /go/src/github.com/docker/distribution
 WORKDIR /go/src/github.com/docker/distribution
-# REGISTRY_VERSION specifies the version of the registry to build and install
-# from the https://github.com/docker/distribution repository. This version of
-# the registry is used to test both schema 1 and schema 2 manifests. Generally,
-# the version specified here should match a current release.
-ARG REGISTRY_VERSION=v2.8.2
+
 # REGISTRY_VERSION_SCHEMA1 specifies the version of the registry to build and
 # REGISTRY_VERSION_SCHEMA1 specifies the version of the registry to build and
 # install from the https://github.com/docker/distribution repository. This is
 # install from the https://github.com/docker/distribution repository. This is
 # an older (pre v2.3.0) version of the registry that only supports schema1
 # an older (pre v2.3.0) version of the registry that only supports schema1
@@ -73,11 +75,10 @@ RUN --mount=from=registry-src,src=/usr/src/registry,rw \
     --mount=type=cache,target=/go/pkg/mod \
     --mount=type=cache,target=/go/pkg/mod \
     --mount=type=tmpfs,target=/go/src <<EOT
     --mount=type=tmpfs,target=/go/src <<EOT
   set -ex
   set -ex
-  git fetch -q --depth 1 origin "${REGISTRY_VERSION}" +refs/tags/*:refs/tags/*
-  git checkout -q FETCH_HEAD
   export GOPATH="/go/src/github.com/docker/distribution/Godeps/_workspace:$GOPATH"
   export GOPATH="/go/src/github.com/docker/distribution/Godeps/_workspace:$GOPATH"
-  CGO_ENABLED=0 xx-go build -o /build/registry-v2 -v ./cmd/registry
-  xx-verify /build/registry-v2
+  # Make the /build directory no matter what so that it doesn't fail on arm64 or
+  # any other platform where we don't build this registry
+  mkdir /build
   case $TARGETPLATFORM in
   case $TARGETPLATFORM in
     linux/amd64|linux/arm/v7|linux/ppc64le|linux/s390x)
     linux/amd64|linux/arm/v7|linux/ppc64le|linux/s390x)
       git fetch -q --depth 1 origin "${REGISTRY_VERSION_SCHEMA1}" +refs/tags/*:refs/tags/*
       git fetch -q --depth 1 origin "${REGISTRY_VERSION_SCHEMA1}" +refs/tags/*:refs/tags/*
@@ -88,6 +89,9 @@ RUN --mount=from=registry-src,src=/usr/src/registry,rw \
   esac
   esac
 EOT
 EOT
 
 
+FROM distribution/distribution:$REGISTRY_VERSION AS registry-v2
+RUN mkdir /build && mv /bin/registry /build/registry-v2
+
 # go-swagger
 # go-swagger
 FROM base AS swagger-src
 FROM base AS swagger-src
 WORKDIR /usr/src/swagger
 WORKDIR /usr/src/swagger
@@ -449,6 +453,7 @@ COPY --link --from=tomll         /build/ /usr/local/bin/
 COPY --link --from=gowinres      /build/ /usr/local/bin/
 COPY --link --from=gowinres      /build/ /usr/local/bin/
 COPY --link --from=tini          /build/ /usr/local/bin/
 COPY --link --from=tini          /build/ /usr/local/bin/
 COPY --link --from=registry      /build/ /usr/local/bin/
 COPY --link --from=registry      /build/ /usr/local/bin/
+COPY --link --from=registry-v2   /build/ /usr/local/bin/
 
 
 # Skip the CRIU stage for now, as the opensuse package repository is sometimes
 # Skip the CRIU stage for now, as the opensuse package repository is sometimes
 # unstable, and we're currently not using it in CI.
 # unstable, and we're currently not using it in CI.