Skip to content

Commit 944eb75

Browse files
authored
Merge pull request docker#10348 from thaJeztah/fix_engine_env_vars
Simplify use of "ENGINE_BRANCH" and "DISTRIBUTION_BRANCH"
2 parents b7cf4b0 + f2d5f95 commit 944eb75

File tree

2 files changed

+35
-27
lines changed

2 files changed

+35
-27
lines changed

Diff for: Dockerfile

+7-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
# Engine
16-
ARG ENGINE_BRANCH="19.03.x"
16+
ARG ENGINE_BRANCH="19.03"
1717

1818
# Distribution
1919
ARG DISTRIBUTION_BRANCH="release/2.7"
@@ -30,16 +30,13 @@ FROM docs/docker.github.io:docs-builder AS builderbase
3030
ENV TARGET=/usr/share/nginx/html
3131
WORKDIR /usr/src/app/md_source/
3232

33-
# Set vars used by fetch-upstream-resources.sh script
34-
# Branch to pull from, per ref doc. To get master from svn the svn branch needs
35-
# to be 'trunk'. To get a branch from svn it needs to be 'branches/branchname'
33+
# Set vars used by fetch-upstream-resources.sh script as an environment variable,
34+
# so that they are persisted in the image for use in later stages.
3635
ARG ENGINE_BRANCH
3736
ENV ENGINE_BRANCH=${ENGINE_BRANCH}
38-
ENV ENGINE_SVN_BRANCH=branches/${ENGINE_BRANCH}
3937

4038
ARG DISTRIBUTION_BRANCH
4139
ENV DISTRIBUTION_BRANCH=${DISTRIBUTION_BRANCH}
42-
ENV DISTRIBUTION_SVN_BRANCH=branches/${DISTRIBUTION_BRANCH}
4340

4441

4542
# Reset to alpine so we don't get any docs source or extra apps
@@ -77,6 +74,10 @@ FROM archives-${ENABLE_ARCHIVES} AS archives
7774
# these docs are only rebuilt if changes were made to the configuration.
7875
FROM builderbase AS upstream-resources
7976
COPY ./_scripts/fetch-upstream-resources.sh ./_scripts/
77+
# Add the _config.yml and toc.yaml here so that the fetch-upstream-resources
78+
# can extract the latest_engine_api_version value, and substitute the
79+
# "{site.latest_engine_api_version}" in the title for the latest API docs
80+
# TODO find a different mechanism for substituting the API version, to prevent invalidating the cache
8081
COPY ./_config.yml .
8182
COPY ./_data/toc.yaml ./_data/
8283
RUN bash ./_scripts/fetch-upstream-resources.sh .

Diff for: _scripts/fetch-upstream-resources.sh

+28-21
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
# Fetches upstream resources from docker/docker and docker/distribution
44
# before handing off the site to Jekyll to build
5-
# Relies on the following environment variables which are usually set by
6-
# the Dockerfile. Uncomment them here to override for debugging
5+
# Relies on the "ENGINE_BRANCH" and "DISTRIBUTION_BRANCH" environment variables,
6+
# which are usually set by the Dockerfile.
7+
: "${ENGINE_BRANCH?No release branch set for docker/docker and docker/cli}"
8+
: "${DISTRIBUTION_BRANCH?No release branch set for docker/distribution}"
79

8-
# Helper functino to deal with sed differences between osx and Linux
10+
# Helper function to deal with sed differences between osx and Linux
911
# See https://stackoverflow.com/a/38595160
1012
sedi () {
1113
sed --version >/dev/null 2>&1 && sed -i -- "$@" || sed -i "" "$@"
@@ -49,19 +51,24 @@ done < <(cat ./_config.yml |grep '_version:' |grep '^[a-z].*')
4951
# Replace variable in toc.yml with value from above
5052
sedi "s/{{ site.latest_engine_api_version }}/$latest_engine_api_version/g" ./_data/toc.yaml
5153

52-
# Engine stable
53-
ENGINE_SVN_BRANCH="branches/19.03"
54-
ENGINE_BRANCH="19.03"
55-
56-
# Distribution
57-
DISTRIBUTION_SVN_BRANCH="branches/release/2.7"
58-
DISTRIBUTION_BRANCH="release/2.7"
54+
# Translate branches for use by svn
55+
engine_svn_branch="branches/${ENGINE_BRANCH}"
56+
if [ engine_svn_branch = "branches/master" ]; then
57+
engine_svn_branch=trunk
58+
fi
59+
distribution_svn_branch="branches/${DISTRIBUTION_BRANCH}"
60+
if [ distribution_svn_branch = "branches/master" ]; then
61+
distribution_svn_branch=trunk
62+
fi
5963

6064
# Directories to get via SVN. We use this because you can't use git to clone just a portion of a repository
61-
svn co https://github.com/docker/docker-ce/"$ENGINE_SVN_BRANCH"/components/cli/docs/extend ./engine/extend || (echo "Failed engine/extend download" && exit 1)
62-
svn co https://github.com/docker/docker-ce/"$ENGINE_SVN_BRANCH"/components/engine/docs/api ./engine/api || (echo "Failed engine/api download" && exit 1) # This will only get you the old API MD files 1.18 through 1.24
63-
svn co https://github.com/docker/distribution/"$DISTRIBUTION_SVN_BRANCH"/docs/spec ./registry/spec || (echo "Failed registry/spec download" && exit 1)
64-
svn co https://github.com/mirantis/compliance/trunk/docs/compliance ./compliance || (echo "Failed docker/compliance download" && exit 1)
65+
svn co "https://github.com/docker/docker-ce/${engine_svn_branch}/components/cli/docs/extend" ./engine/extend || (echo "Failed engine/extend download" && exit 1)
66+
svn co "https://github.com/docker/docker-ce/${engine_svn_branch}/components/engine/docs/api" ./engine/api || (echo "Failed engine/api download" && exit 1) # This will only get you the old API MD files 1.18 through 1.24
67+
svn co "https://github.com/docker/distribution/${distribution_svn_branch}/docs/spec" ./registry/spec || (echo "Failed registry/spec download" && exit 1)
68+
svn co "https://github.com/mirantis/compliance/trunk/docs/compliance" ./compliance || (echo "Failed docker/compliance download" && exit 1)
69+
70+
# Cleanup svn directories
71+
find . -name .svn -exec rm -rf '{}' \;
6572

6673
# Get the Engine APIs that are in Swagger
6774
# Be careful with the locations on Github for these
@@ -85,13 +92,13 @@ wget --quiet --directory-prefix=./engine/api/v1.38/ https://raw.githubuserconten
8592
wget --quiet --directory-prefix=./engine/api/v1.39/ https://raw.githubusercontent.com/docker/docker-ce/v18.09.9/components/engine/api/swagger.yaml || (echo "Failed 1.39 swagger download" && exit 1)
8693

8794
# Get a few one-off files that we use directly from upstream
88-
wget --quiet --directory-prefix=./engine/api/v"${latest_engine_api_version}"/ https://raw.githubusercontent.com/docker/docker-ce/"$ENGINE_BRANCH"/components/engine/api/swagger.yaml || (echo "Failed ${latest_engine_api_version} swagger download" && exit 1)
89-
wget --quiet --directory-prefix=./engine/ https://raw.githubusercontent.com/docker/docker-ce/"$ENGINE_BRANCH"/components/cli/docs/deprecated.md || (echo "Failed engine/deprecated.md download" && exit 1)
90-
wget --quiet --directory-prefix=./engine/reference/ https://raw.githubusercontent.com/docker/docker-ce/"$ENGINE_BRANCH"/components/cli/docs/reference/builder.md || (echo "Failed engine/reference/builder.md download" && exit 1)
91-
wget --quiet --directory-prefix=./engine/reference/ https://raw.githubusercontent.com/docker/docker-ce/"$ENGINE_BRANCH"/components/cli/docs/reference/run.md || (echo "Failed engine/reference/run.md download" && exit 1)
92-
wget --quiet --directory-prefix=./engine/reference/commandline/ https://raw.githubusercontent.com/docker/docker-ce/"$ENGINE_BRANCH"/components/cli/docs/reference/commandline/cli.md || (echo "Failed engine/reference/commandline/cli.md download" && exit 1)
93-
wget --quiet --directory-prefix=./engine/reference/commandline/ https://raw.githubusercontent.com/docker/docker-ce/"$ENGINE_BRANCH"/components/cli/docs/reference/commandline/dockerd.md || (echo "Failed engine/reference/commandline/dockerd.md download" && exit 1)
94-
wget --quiet --directory-prefix=./registry/ https://raw.githubusercontent.com/docker/distribution/"$DISTRIBUTION_BRANCH"/docs/configuration.md || (echo "Failed registry/configuration.md download" && exit 1)
95+
wget --quiet --directory-prefix=./engine/api/v"${latest_engine_api_version}"/ "https://raw.githubusercontent.com/docker/docker-ce/${ENGINE_BRANCH}/components/engine/api/swagger.yaml" || (echo "Failed ${latest_engine_api_version} swagger download" && exit 1)
96+
wget --quiet --directory-prefix=./engine/ "https://raw.githubusercontent.com/docker/docker-ce/${ENGINE_BRANCH}/components/cli/docs/deprecated.md" || (echo "Failed engine/deprecated.md download" && exit 1)
97+
wget --quiet --directory-prefix=./engine/reference/ "https://raw.githubusercontent.com/docker/docker-ce/${ENGINE_BRANCH}/components/cli/docs/reference/builder.md" || (echo "Failed engine/reference/builder.md download" && exit 1)
98+
wget --quiet --directory-prefix=./engine/reference/ "https://raw.githubusercontent.com/docker/docker-ce/${ENGINE_BRANCH}/components/cli/docs/reference/run.md" || (echo "Failed engine/reference/run.md download" && exit 1)
99+
wget --quiet --directory-prefix=./engine/reference/commandline/ "https://raw.githubusercontent.com/docker/docker-ce/${ENGINE_BRANCH}/components/cli/docs/reference/commandline/cli.md" || (echo "Failed engine/reference/commandline/cli.md download" && exit 1)
100+
wget --quiet --directory-prefix=./engine/reference/commandline/ "https://raw.githubusercontent.com/docker/docker-ce/${ENGINE_BRANCH}/components/cli/docs/reference/commandline/dockerd.md" || (echo "Failed engine/reference/commandline/dockerd.md download" && exit 1)
101+
wget --quiet --directory-prefix=./registry/ "https://raw.githubusercontent.com/docker/distribution/${DISTRIBUTION_BRANCH}/docs/configuration.md" || (echo "Failed registry/configuration.md download" && exit 1)
95102

96103
# Remove things we don't want in the build
97104
rm ./registry/spec/api.md.tmpl

0 commit comments

Comments
 (0)