Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Read <eread@gitlab.com>2023-11-20 04:33:05 +0300
committerEvan Read <eread@gitlab.com>2023-11-20 04:33:05 +0300
commitcafb8b6cf0803081d29ec5140b27d354d9ccf659 (patch)
tree3ed29c4a2bdea6633c70b6cc3925aea6055cf0f3
parentde2c1d21e0e70bca2febc90085c4ada6ca7c34a9 (diff)
parentfdc4e365c397d098002839084a3e98b54f146058 (diff)
Merge branch 'axil-fix-docker-single-test' into 'main'
Fix stable Docker image See merge request https://gitlab.com/gitlab-org/gitlab-docs/-/merge_requests/4399 Merged-by: Evan Read <eread@gitlab.com> Approved-by: Evan Read <eread@gitlab.com> Reviewed-by: Achilleas Pipinellis <axil@gitlab.com> Co-authored-by: Achilleas Pipinellis <axil@gitlab.com>
-rw-r--r--.gitlab/ci/docker-images.gitlab-ci.yml12
-rw-r--r--dockerfiles/single.Dockerfile22
-rwxr-xr-xscripts/normalize-links.sh6
3 files changed, 32 insertions, 8 deletions
diff --git a/.gitlab/ci/docker-images.gitlab-ci.yml b/.gitlab/ci/docker-images.gitlab-ci.yml
index 969f1f02..1eabe88d 100644
--- a/.gitlab/ci/docker-images.gitlab-ci.yml
+++ b/.gitlab/ci/docker-images.gitlab-ci.yml
@@ -178,8 +178,13 @@ image:docs-single:
#
# Test the GitLab docs single version Docker image if changes made to its Dockerfile
+# We need to specify an output (similar to --push), otherwise the build result
+# will only remain in the build cache. We use --load to load the image into
+# Docker.
#
test:image:docs-single:
+ tags:
+ - saas-linux-medium-amd64
extends:
- .docker_prepare
- .rules_docker_single_images_tests
@@ -197,6 +202,10 @@ test:image:docs-single:
--build-arg SEARCH_BACKEND="google"
--tag $IMAGE_NAME
--file $DOCKERFILE .
+ --load
+ - version=$(docker run --rm $IMAGE_NAME ls -1 /usr/share/nginx/html/ | grep -v html)
+ - echo $version
+ - if [ "$version" = "$GITLAB_VERSION" ]; then echo "OK"; else exit 1 ; fi
#
# Final Docker image containing a single version with lunr.js enabled
@@ -233,6 +242,8 @@ image:docs-single-lunrjs:
# if changes made to its Dockerfile
#
test:image:docs-single-lunrjs:
+ tags:
+ - saas-linux-medium-amd64
extends:
- .docker_prepare
- .rules_docker_single_images_tests
@@ -251,6 +262,7 @@ test:image:docs-single-lunrjs:
--build-arg SEARCH_BACKEND="lunr"
--tag $IMAGE_NAME
--file $DOCKERFILE .
+ --load
- make check-lunr-index
#
diff --git a/dockerfiles/single.Dockerfile b/dockerfiles/single.Dockerfile
index e171e601..7ede19ee 100644
--- a/dockerfiles/single.Dockerfile
+++ b/dockerfiles/single.Dockerfile
@@ -71,10 +71,17 @@ RUN if [ "$SEARCH_BACKEND" = "lunr" ]; then make build-lunr-index; fi
# while omitting the trainling slash will copy the directory as well.
# We want the trailing slash. More info:
# https://github.com/tdewolff/minify/blob/master/cmd/minify/README.md#directories
+# 3. We move the end result to dest/<version>/, because of the way COPY works
+# in the next stage. If source is a directory, the entire contents of the
+# directory are copied, including filesystem metadata. The directory itself
+# is not copied, just its contents.
+# More info: https://docs.docker.com/engine/reference/builder/#copy
#
-RUN scripts/normalize-links.sh public $VER \
- && mkdir dest/ \
- && scripts/minify-assets.sh dest/ public/
+RUN scripts/normalize-links.sh public $VER \
+ && mkdir $VER \
+ && scripts/minify-assets.sh $VER/ public/ \
+ && mkdir dest \
+ && mv $VER dest/
#- End of builder build stage -#
@@ -84,10 +91,13 @@ RUN scripts/normalize-links.sh public $VER \
# to an NGINX Docker image.
FROM nginx:stable-alpine
-# Clean out any existing HTML files, and copy the HTML from the builder stage
-# to the default location for NGINX.
+# Clean out any existing HTML files
RUN rm -rf /usr/share/nginx/html/*
-COPY --from=builder /source/dest /usr/share/nginx/html/${VER}
+
+# Copy the HTML from the builder stage to the default location for NGINX.
+# The trailing slashes of the source and destination directories matter.
+# https://docs.docker.com/engine/reference/builder/#copy
+COPY --from=builder /source/dest/ /usr/share/nginx/html/
# Make an index.html and 404.html which will redirect / to /${VER}/
RUN echo "<html><head><title>Redirect for ${VER}</title><meta http-equiv=\"refresh\" content=\"0;url='/${VER}/'\" /></head><body><p>If you are not redirected automatically, click <a href=\"/${VER}/\">here</a>.</p></body></html>" > /usr/share/nginx/html/index.html \
diff --git a/scripts/normalize-links.sh b/scripts/normalize-links.sh
index 31a33427..95d8aa28 100755
--- a/scripts/normalize-links.sh
+++ b/scripts/normalize-links.sh
@@ -51,7 +51,8 @@ fi
# shellcheck disable=2059
printf "${COLOR_GREEN}INFO: Replacing relative URLs in $INPUT for HTML files...${COLOR_RESET}\n"
-find "${INPUT}" -type f -name '*.html' -print0 | xargs -0 "$SED" -i -e 's|href="/ee/|href="/'"$VER"'/ee/|g' \
+find "${INPUT}" -type f -name '*.html' -print0 | xargs -0 -n 2 -P 0 "$SED" -i \
+ -e 's|href="/ee/|href="/'"$VER"'/ee/|g' \
-e 's|href="/runner/|href="/'"$VER"'/runner/|g' \
-e 's|href="/omnibus/|href="/'"$VER"'/omnibus/|g' \
-e 's|href="/charts/|href="/'"$VER"'/charts/|g' \
@@ -79,7 +80,8 @@ find "${INPUT}" -type f -name '*.js' -print0 | xargs -0 "$SED" -i -e 's|/search/
#
# shellcheck disable=2059
printf "${COLOR_GREEN}INFO: Replacing full URLs in $INPUT for HTML files...${COLOR_RESET}\n"
-find "${INPUT}" -type f -name '*.html' -print0 | xargs -0 "$SED" -i -e '/\(rel="canonical"\|property="og:url"\)/! s|href="https://docs.gitlab.com/ee/|href="/'"$VER"'/ee/|g' \
+find "${INPUT}" -type f -name '*.html' -print0 | xargs -0 -n 2 -P 0 "$SED" -i \
+ -e '/\(rel="canonical"\|property="og:url"\)/! s|href="https://docs.gitlab.com/ee/|href="/'"$VER"'/ee/|g' \
-e '/\(rel="canonical"\|property="og:url"\)/! s|href="https://docs.gitlab.com/runner/|href="/'"$VER"'/runner/|g' \
-e '/\(rel="canonical"\|property="og:url"\)/! s|href="https://docs.gitlab.com/omnibus/|href="/'"$VER"'/omnibus/|g' \
-e '/\(rel="canonical"\|property="og:url"\)/! s|href="https://docs.gitlab.com/charts/|href="/'"$VER"'/charts/|g' \