diff options
author | Achilleas Pipinellis <axil@gitlab.com> | 2023-05-12 20:15:57 +0300 |
---|---|---|
committer | Achilleas Pipinellis <axil@gitlab.com> | 2023-05-12 22:10:54 +0300 |
commit | f01310e9aa6f000163c68125165620f6177f7fd2 (patch) | |
tree | 9977636e3bba57d0f3b009a5a59bffa1096a61dd | |
parent | 726cae78ea35b602f00112403223769219b4e0ca (diff) |
Change test of Docker archives jobaxil-change-test-archives-docker
Instead of building the archives image to test the archives image job,
use `docker manifest inspect "$image"` to query the registry to see if
the images are present. We don't need to pull the images to verify the
archives job, just making sure they're there is enough.
This will eliminate the somewhat duplicate job (build the archives
image twice, one in the test job and one in the actual job), and make
the test significantly faster. The archives image build takes over
60 minutes.
-rw-r--r-- | .gitlab/ci/docker-images.gitlab-ci.yml | 3 | ||||
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | dockerfiles/archives.Dockerfile | 6 | ||||
-rwxr-xr-x | scripts/check-docker-archives.sh | 24 |
4 files changed, 34 insertions, 3 deletions
diff --git a/.gitlab/ci/docker-images.gitlab-ci.yml b/.gitlab/ci/docker-images.gitlab-ci.yml index a567d878..f112f1ee 100644 --- a/.gitlab/ci/docker-images.gitlab-ci.yml +++ b/.gitlab/ci/docker-images.gitlab-ci.yml @@ -318,4 +318,5 @@ test:image:docs-archives: DOCKERFILE: dockerfiles/archives.Dockerfile needs: [] script: - - docker build -t $IMAGE_NAME -f $DOCKERFILE . + - apk add bash curl make + - make check-docker-archives @@ -216,6 +216,10 @@ check-danger: @printf "\n$(INFO)INFO: Checking for Danger errors and warnings...$(END)\n" @scripts/check-danger.sh ; exit $$? +check-docker-archives: + @printf "\n$(INFO)INFO: Checking if the Docker images defined in 'archives.Dockerfile' are present...$(END)\n" + @scripts/check-docker-archives.sh + add-gitlab-fonts: @printf "\n$(INFO)INFO: Copying GitLab fonts...$(END)\n" cp -v node_modules/@gitlab/fonts/gitlab-sans/GitLabSans.woff2 public/assets/fonts diff --git a/dockerfiles/archives.Dockerfile b/dockerfiles/archives.Dockerfile index baaa6a11..7d04a331 100644 --- a/dockerfiles/archives.Dockerfile +++ b/dockerfiles/archives.Dockerfile @@ -2,6 +2,9 @@ FROM nginx:stable-alpine ENV TARGET=/usr/share/nginx/html +## Remove default NGINX files +RUN rm -rf ${TARGET}/*.html + ## Get all the archive static HTML and put it into place ## Copy all the GitLab versions, except from the last one, ## which is still supported and online in docs.gitlab.com. @@ -41,8 +44,6 @@ COPY --from=registry.gitlab.com/gitlab-org/gitlab-docs:15.3 ${TARGET} ${TARGET} COPY --from=registry.gitlab.com/gitlab-org/gitlab-docs:15.4 ${TARGET} ${TARGET} # Don't add any more versions here. See the end of this file. -RUN rm -rf ${TARGET}/*.html - ## When we start pushing the lunrjs images under the archives repository, ## the Registry repository will change to 'archives:X.Y'. ## The first supported version is 15.5. @@ -50,3 +51,4 @@ RUN rm -rf ${TARGET}/*.html COPY --from=registry.gitlab.com/gitlab-org/gitlab-docs/archives:15.5 ${TARGET} ${TARGET} COPY --from=registry.gitlab.com/gitlab-org/gitlab-docs/archives:15.6 ${TARGET} ${TARGET} COPY --from=registry.gitlab.com/gitlab-org/gitlab-docs/archives:15.7 ${TARGET} ${TARGET} +COPY --from=registry.gitlab.com/gitlab-org/gitlab-docs/archives:15.8 ${TARGET} ${TARGET} diff --git a/scripts/check-docker-archives.sh b/scripts/check-docker-archives.sh new file mode 100755 index 00000000..26f4b303 --- /dev/null +++ b/scripts/check-docker-archives.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +# +# Check if the archived Docker images are present in the registry repository +# + +COLOR_RED="\e[31m" +COLOR_GREEN="\e[32m" +COLOR_RESET="\e[39m" + +DOCKERFILE='dockerfiles/archives.Dockerfile' + +IMAGES=$(grep 'COPY' "$DOCKERFILE" | awk '{print $2}' | cut -d '=' -f 2) + +for image in $IMAGES; do + if docker manifest inspect "$image" &>/dev/null; then + # shellcheck disable=2059 + printf "${COLOR_GREEN}INFO: Found Docker image: $image ${COLOR_RESET}\n" + else + # shellcheck disable=2059 + printf "${COLOR_RED}ERROR: Couldn't find Docker image: $image ${COLOR_RESET}\n" + exit 1 + fi +done |