diff --git a/Dockerfile b/Dockerfile index 2f42486c19..ea9311d396 100644 --- a/Dockerfile +++ b/Dockerfile @@ -63,6 +63,15 @@ COPY --from=docs/docker.github.io:v17.09 ${TARGET} ${TARGET} COPY --from=docs/docker.github.io:v17.12 ${TARGET} ${TARGET} COPY --from=docs/docker.github.io:v18.03 ${TARGET} ${TARGET} +# Fetch library samples (documentation from official images on Docker Hub) +# Only add the files that are needed to build these reference docs, so that +# these docs are only rebuilt if changes were made to the configuration. +# @todo find a way to build HTML in this stage, and still have them included in the navigation tree +FROM builderbase AS library-samples +COPY ./_scripts/fetch-library-samples.sh ./_scripts/ +COPY ./_samples/boilerplate.txt ./_samples/ +RUN bash ./_scripts/fetch-library-samples.sh + # Fetch upstream resources (reference documentation) # Only add the files that are needed to build these reference docs, so that # these docs are only rebuilt if changes were made to the configuration. @@ -70,16 +79,15 @@ FROM builderbase AS upstream-resources COPY ./_scripts/fetch-upstream-resources.sh ./_scripts/ COPY ./_config.yml . COPY ./_data/toc.yaml ./_data/ -COPY ./_samples/boilerplate.txt ./_samples/ RUN bash ./_scripts/fetch-upstream-resources.sh . # Build the current docs from the checked out branch FROM builderbase AS current COPY . . +COPY --from=library-samples /usr/src/app/md_source/. ./ COPY --from=upstream-resources /usr/src/app/md_source/. ./ - # Build the static HTML, now that everything is in place RUN jekyll build -d ${TARGET} diff --git a/_scripts/fetch-library-samples.sh b/_scripts/fetch-library-samples.sh new file mode 100755 index 0000000000..e8b1d2c6ec --- /dev/null +++ b/_scripts/fetch-library-samples.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +# Get the Library docs +svn co https://github.com/docker-library/docs/trunk ./_samples/library || (echo "Failed library download" && exit 1) +# Remove symlinks to maintainer.md because they break jekyll and we don't use em +find ./_samples/library -maxdepth 9 -type l -delete +# Loop through the README.md files, turn them into rich index.md files +FILES=$(find ./_samples/library -type f -name 'README.md') +for f in ${FILES} +do + curdir=$(dirname "${f}") + justcurdir="${curdir##*/}" + if [ -e ${curdir}/README-short.txt ] + then + # shortrm=$(<${curdir}/README-short.txt) + shortrm=$(cat ${curdir}/README-short.txt) + fi + echo "Adding front-matter to ${f} ..." + echo --- >> ${curdir}/front-matter.txt + echo title: "${justcurdir}" >> ${curdir}/front-matter.txt + echo keywords: library, sample, ${justcurdir} >> ${curdir}/front-matter.txt + echo repo: "${justcurdir}" >> ${curdir}/front-matter.txt + echo layout: docs >> ${curdir}/front-matter.txt + echo permalink: /samples/library/${justcurdir}/ >> ${curdir}/front-matter.txt + echo redirect_from: >> ${curdir}/front-matter.txt + echo - /samples/${justcurdir}/ >> ${curdir}/front-matter.txt + echo description: \| >> ${curdir}/front-matter.txt + echo \ \ ${shortrm} >> ${curdir}/front-matter.txt + echo --- >> ${curdir}/front-matter.txt + echo >> ${curdir}/front-matter.txt + echo ${shortrm} >> ${curdir}/front-matter.txt + echo >> ${curdir}/front-matter.txt + if [ -e ${curdir}/github-repo ] + then + # gitrepo=$(<${curdir}/github-repo) + gitrepo=$(cat ${curdir}/github-repo) + echo >> ${curdir}/front-matter.txt + echo GitHub repo: \["${gitrepo}"\]\("${gitrepo}"\)\{: target="_blank"\} >> ${curdir}/front-matter.txt + echo >> ${curdir}/front-matter.txt + fi + cat ${curdir}/front-matter.txt ./_samples/boilerplate.txt > ${curdir}/header.txt + echo {% raw %} >> ${curdir}/header.txt + cat ${curdir}/header.txt ${curdir}/README.md > ${curdir}/index.md + echo {% endraw %} >> ${curdir}/index.md + rm -rf ${curdir}/front-matter.txt + rm -rf ${curdir}/header.txt +done + +rm ./_samples/library/index.md diff --git a/_scripts/fetch-upstream-resources.sh b/_scripts/fetch-upstream-resources.sh index 344b5576b9..81ffff7e4b 100755 --- a/_scripts/fetch-upstream-resources.sh +++ b/_scripts/fetch-upstream-resources.sh @@ -63,52 +63,6 @@ svn co https://github.com/docker/docker-ce/"$ENGINE_SVN_BRANCH"/components/engin svn co https://github.com/docker/distribution/"$DISTRIBUTION_SVN_BRANCH"/docs/spec ./registry/spec || (echo "Failed registry/spec download" && exit 1) svn co https://github.com/docker/compliance/trunk/docs/compliance ./compliance || (echo "Failed docker/compliance download" && exit 1) -# Get the Library docs -svn co https://github.com/docker-library/docs/trunk ./_samples/library || (echo "Failed library download" && exit 1) -# Remove symlinks to maintainer.md because they break jekyll and we don't use em -find ./_samples/library -maxdepth 9 -type l -delete -# Loop through the README.md files, turn them into rich index.md files -FILES=$(find ./_samples/library -type f -name 'README.md') -for f in $FILES -do - curdir=$(dirname "${f}") - justcurdir="${curdir##*/}" - if [ -e ${curdir}/README-short.txt ] - then - # shortrm=$(<${curdir}/README-short.txt) - shortrm=$(cat ${curdir}/README-short.txt) - fi - echo "Adding front-matter to ${f} ..." - echo --- >> ${curdir}/front-matter.txt - echo title: "${justcurdir}" >> ${curdir}/front-matter.txt - echo keywords: library, sample, ${justcurdir} >> ${curdir}/front-matter.txt - echo repo: "${justcurdir}" >> ${curdir}/front-matter.txt - echo layout: docs >> ${curdir}/front-matter.txt - echo permalink: /samples/library/${justcurdir}/ >> ${curdir}/front-matter.txt - echo redirect_from: >> ${curdir}/front-matter.txt - echo - /samples/${justcurdir}/ >> ${curdir}/front-matter.txt - echo description: \| >> ${curdir}/front-matter.txt - echo \ \ ${shortrm} >> ${curdir}/front-matter.txt - echo --- >> ${curdir}/front-matter.txt - echo >> ${curdir}/front-matter.txt - echo ${shortrm} >> ${curdir}/front-matter.txt - echo >> ${curdir}/front-matter.txt - if [ -e ${curdir}/github-repo ] - then - # gitrepo=$(<${curdir}/github-repo) - gitrepo=$(cat ${curdir}/github-repo) - echo >> ${curdir}/front-matter.txt - echo GitHub repo: \["${gitrepo}"\]\("${gitrepo}"\)\{: target="_blank"\} >> ${curdir}/front-matter.txt - echo >> ${curdir}/front-matter.txt - fi - cat ${curdir}/front-matter.txt ./_samples/boilerplate.txt > ${curdir}/header.txt - echo {% raw %} >> ${curdir}/header.txt - cat ${curdir}/header.txt ${curdir}/README.md > ${curdir}/index.md - echo {% endraw %} >> ${curdir}/index.md - rm -rf ${curdir}/front-matter.txt - rm -rf ${curdir}/header.txt -done - # Get the Engine APIs that are in Swagger # Be careful with the locations on Github for these # When you change this you need to make sure to copy the previous @@ -143,4 +97,3 @@ wget --quiet --directory-prefix=./registry/ https://raw.gith rm ./registry/spec/api.md.tmpl rm -rf ./apidocs/cloud-api-source rm -rf ./tests -rm ./_samples/library/index.md