Skip to content

Commit 136a8d3

Browse files
committed
Dockerfile: allow building docs without archives
This adds a `ENABLE_ARCHIVES` build-arg, which allows building the documentation without archives. Note that currently, the archives drop-down is still added unconditionally (so also included if archives are disabled). Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent a6a470e commit 136a8d3

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

Dockerfile

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ ARG ENGINE_BRANCH="19.03.x"
1818
# Distribution
1919
ARG DISTRIBUTION_BRANCH="release/2.7"
2020

21+
# Set to "false" to build the documentation without archives
22+
ARG ENABLE_ARCHIVES=true
2123

2224
###
2325
# Set up base stages for building and deploying
@@ -52,8 +54,11 @@ COPY --from=docs/docker.github.io:nginx-onbuild /etc/nginx/conf.d/default.conf /
5254
CMD echo -e "Docker docs are viewable at:\nhttp://0.0.0.0:4000"; exec nginx -g 'daemon off;'
5355

5456

55-
# Stage with static HTML for all archives
56-
FROM scratch AS archives
57+
# Empty stage if archives are disabled (ENABLE_ARCHIVES=false)
58+
FROM scratch AS archives-false
59+
60+
# Stage with static HTML for all archives (ENABLE_ARCHIVES=true)
61+
FROM scratch AS archives-true
5762
ENV TARGET=/usr/share/nginx/html
5863
# To add a new archive, add it here and ALSO edit _data/docsarchive/archives.yaml
5964
# to add it to the drop-down
@@ -64,6 +69,8 @@ COPY --from=docs/docker.github.io:v17.12 ${TARGET} /
6469
COPY --from=docs/docker.github.io:v18.03 ${TARGET} /
6570
COPY --from=docs/docker.github.io:v18.09 ${TARGET} /
6671

72+
# Stage either with, or without archives, depending on ENABLE_ARCHIVES
73+
FROM archives-${ENABLE_ARCHIVES} AS archives
6774

6875
# Fetch upstream resources (reference documentation)
6976
# Only add the files that are needed to build these reference docs, so that
@@ -84,7 +91,15 @@ RUN jekyll build -d ${TARGET}
8491
RUN find ${TARGET} -type f -name '*.html' | grep -vE "v[0-9]+\." | while read i; do sed -i 's#href="https://docs.docker.com/#href="/#g' "$i"; done
8592

8693

87-
# Final stage, which includes nginx, current docs, and archived versions
94+
# Final stage, which includes nginx, and, depending on ENABLE_ARCHIVES, either
95+
# current docs and archived versions (ENABLE_ARCHIVES=true), or only the current
96+
# docs (ENABLE_ARCHIVES=false).
97+
#
98+
# To build current docs, including archives:
99+
# DOCKER_BUILDKIT=1 docker build -t docs .
100+
#
101+
# To build without archives:
102+
# DOCKER_BUILDKIT=1 docker build -t docs --build-arg ENABLE_ARCHIVES=false .
88103
FROM deploybase AS deploy
89104
COPY --from=archives / ${TARGET}
90105
COPY --from=current ${TARGET} ${TARGET}

0 commit comments

Comments
 (0)