From c8b335c3b81400dfd9fd50392327ddeee3fc977c Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 21 Feb 2020 10:44:25 +0100 Subject: [PATCH] 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 --- Dockerfile | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4b8d882a07..ee0d6860d7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -91,6 +91,19 @@ RUN jekyll build -d ${TARGET} 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 +# This stage only contains the generated files. It can be used to host 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. +# +# To build current docs, including archives: +# DOCKER_BUILDKIT=1 docker build --target=deploy-source --output=./_site . +# +# To build without archives: +# DOCKER_BUILDKIT=1 docker build --target=deploy-source --build-arg ENABLE_ARCHIVES=false --output=./_site . +FROM archives AS deploy-source +COPY --from=current /usr/share/nginx/html / + # Final stage, which includes nginx, and, depending on ENABLE_ARCHIVES, either # current docs and archived versions (ENABLE_ARCHIVES=true), or only the current # docs (ENABLE_ARCHIVES=false). @@ -101,5 +114,5 @@ RUN find ${TARGET} -type f -name '*.html' | grep -vE "v[0-9]+\." | while read i; # To build without archives: # DOCKER_BUILDKIT=1 docker build -t docs --build-arg ENABLE_ARCHIVES=false . FROM deploybase AS deploy -COPY --from=archives / ${TARGET} -COPY --from=current ${TARGET} ${TARGET} +WORKDIR $TARGET +COPY --from=deploy-source / .