1
- FROM docs/docker.github.io:docs-base
1
+ # This Dockerfile builds the docs for https://docs.docker.com/
2
+ # from the master branch of https://github.com/docker/docker.github.io
3
+ #
4
+ # Here is the sequence:
5
+ # 1. Set up the build
6
+ # 2. Fetch upstream resources
7
+ # 3. Build master
8
+ # 4. Copy static HTML from already-built archive images
9
+ # 5. Copy Nginx config
10
+ #
11
+ # When the image is run, it starts Nginx and serves the docs at port 4000
2
12
3
- # docs-base contains: GitHub Pages, nginx, wget, svn, and the docs archives,
4
- # running on Alpine. See the contents of docs-base at:
5
- # https://github.com/docker/docker.github.io/tree/docs-base
13
+ # Get basic configs and Jekyll env
14
+ FROM docs/docker.github.io:docs-builder AS builder
6
15
7
- # First, build non-edge (all of this is duplicated later -- that is on purpose)
16
+ # Set the target again
17
+ ENV TARGET=/usr/share/nginx/html
8
18
9
- # Copy master into target directory (skipping files / folders in .dockerignore)
10
- # These files represent the current docs
11
- COPY . md_source
19
+ # Set the source directory to md_source
20
+ ENV SOURCE=md_source
12
21
13
- # Move built html into md_source directory so we can reuse the target directory
14
- # to hold the static output.
15
- # Pull reference docs from upstream locations, then build the master docs
16
- # into static HTML in the "target" directory using Jekyll
17
- # then nuke the md_source directory.
22
+ # Get the current docs from the checked out branch
23
+ # ${SOURCE} will contain a directory for each archive
24
+ COPY . ${SOURCE}
18
25
26
+ # ###### START UPSTREAM RESOURCES ########
27
+ # Set vars used by fetch-upstream-resources.sh script
19
28
# # Branch to pull from, per ref doc
20
29
# # To get master from svn the svn branch needs to be 'trunk'. To get a branch from svn it needs to be 'branches/branchname'
21
30
22
31
# Engine
23
- ENV ENGINE_SVN_BRANCH="branches/17.06 .x"
24
- ENV ENGINE_BRANCH="17.06 .x"
32
+ ENV ENGINE_SVN_BRANCH="branches/17.09 .x"
33
+ ENV ENGINE_BRANCH="17.09 .x"
25
34
26
35
# Distribution
27
36
ENV DISTRIBUTION_SVN_BRANCH="branches/release/2.6"
28
37
ENV DISTRIBUTION_BRANCH="release/2.6"
29
38
30
- RUN /sbin/apk --update add bash \
31
- && bash ./md_source/_scripts/fetch-upstream-resources.sh \
32
- && jekyll build -s md_source -d target --config md_source/_config.yml \
33
- && rm -rf target/apidocs/layouts \
34
- && find target -type f -name '*.html' -print0 | xargs -0 sed -i 's#href="https://docs.docker.com/#href="/#g' \
35
- && rm -rf md_source
39
+ # Fetch upstream resources
40
+ RUN bash ./${SOURCE}/_scripts/fetch-upstream-resources.sh ${SOURCE}
41
+ # ###### END UPSTREAM RESOURCES ########
42
+
43
+
44
+ # Build the static HTML, now that everything is in place
45
+
46
+ RUN jekyll build -s ${SOURCE} -d ${TARGET} --config ${SOURCE}/_config.yml
47
+
48
+ # Fix up some links, don't touch the archives
49
+ 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
50
+
51
+ # BUILD OF MASTER DOCS IS NOW DONE!
52
+ # Reset to alpine so we don't get any docs source or extra apps
53
+ FROM nginx:alpine
54
+
55
+ # Set the target again
56
+ ENV TARGET=/usr/share/nginx/html
57
+
58
+ # Get the built docs output from the previous step
59
+ COPY --from=builder ${TARGET} ${TARGET}
60
+
61
+ # Get all the archive static HTML and put it into place
62
+ # To add a new archive, add it here
63
+ # AND ALSO edit _data/docsarchives/archives.yaml to add it to the drop-down
64
+ COPY --from=docs/docker.github.io:v1.4 ${TARGET} ${TARGET}
65
+ COPY --from=docs/docker.github.io:v1.5 ${TARGET} ${TARGET}
66
+ COPY --from=docs/docker.github.io:v1.6 ${TARGET} ${TARGET}
67
+ COPY --from=docs/docker.github.io:v1.7 ${TARGET} ${TARGET}
68
+ COPY --from=docs/docker.github.io:v1.8 ${TARGET} ${TARGET}
69
+ COPY --from=docs/docker.github.io:v1.9 ${TARGET} ${TARGET}
70
+ COPY --from=docs/docker.github.io:v1.10 ${TARGET} ${TARGET}
71
+ COPY --from=docs/docker.github.io:v1.11 ${TARGET} ${TARGET}
72
+ COPY --from=docs/docker.github.io:v1.12 ${TARGET} ${TARGET}
73
+ COPY --from=docs/docker.github.io:v1.13 ${TARGET} ${TARGET}
74
+ COPY --from=docs/docker.github.io:v17.03 ${TARGET} ${TARGET}
75
+ COPY --from=docs/docker.github.io:v17.06 ${TARGET} ${TARGET}
76
+
77
+ # The archives are self-browseable and each come with an index.html. This creates
78
+ # a conflict with the index.html and 404.html from the master build. The easiest
79
+ # solution is to just overwrite them again here.
80
+ COPY --from=builder ${TARGET}/index.html ${TARGET}/index.html
81
+ COPY --from=builder ${TARGET}/404.html ${TARGET}/404.html
82
+
83
+ # Get the nginx config from the nginx-onbuild image
84
+ COPY --from=docs/docker.github.io:nginx-onbuild /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf
85
+
86
+ # Serve the site (target), which is now all static HTML
87
+ CMD echo -e "Docker docs are viewable at:\n http://0.0.0.0:4000" ; exec nginx -g 'daemon off;'
0 commit comments