Skip to content

Commit c8b335c

Browse files
committed
Dockerfile: add target to output the generated HTML
This patch adds a stage that only contains the generated files. It can be used to export the generated HTML for hosting the documentation on a non-containerised service (e.g. to deploy to an s3 bucket). When using BuildKit, use the `--output` option to build the files and to copy them to your local filesystem. For example, to build current docs, including archives: DOCKER_BUILDKIT=1 docker build --target=deploy-source --output=./_site . And to build without archives: DOCKER_BUILDKIT=1 docker build --target=deploy-source --build-arg ENABLE_ARCHIVES=false --output=./_site . Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 136a8d3 commit c8b335c

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

Dockerfile

+15-2
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,19 @@ RUN jekyll build -d ${TARGET}
9191
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
9292

9393

94+
# This stage only contains the generated files. It can be used to host the
95+
# documentation on a non-containerised service (e.g. to deploy to an s3 bucket).
96+
# When using BuildKit, use the '--output' option to build the files and to copy
97+
# them to your local filesystem.
98+
#
99+
# To build current docs, including archives:
100+
# DOCKER_BUILDKIT=1 docker build --target=deploy-source --output=./_site .
101+
#
102+
# To build without archives:
103+
# DOCKER_BUILDKIT=1 docker build --target=deploy-source --build-arg ENABLE_ARCHIVES=false --output=./_site .
104+
FROM archives AS deploy-source
105+
COPY --from=current /usr/share/nginx/html /
106+
94107
# Final stage, which includes nginx, and, depending on ENABLE_ARCHIVES, either
95108
# current docs and archived versions (ENABLE_ARCHIVES=true), or only the current
96109
# docs (ENABLE_ARCHIVES=false).
@@ -101,5 +114,5 @@ RUN find ${TARGET} -type f -name '*.html' | grep -vE "v[0-9]+\." | while read i;
101114
# To build without archives:
102115
# DOCKER_BUILDKIT=1 docker build -t docs --build-arg ENABLE_ARCHIVES=false .
103116
FROM deploybase AS deploy
104-
COPY --from=archives / ${TARGET}
105-
COPY --from=current ${TARGET} ${TARGET}
117+
WORKDIR $TARGET
118+
COPY --from=deploy-source / .

0 commit comments

Comments
 (0)