Skip to content

Commit

Permalink
Move to GHP 112, nginx-based server, docs-base (docker#1515)
Browse files Browse the repository at this point in the history
* Moves to GHP 112, nginx-based server

* Import official nginx instructions per @thaJeztah

* Reordering of commands per @thaJeztah

* Reordering of commands per @thaJeztah

* Make sure that at the end of each layer we only keep the one directory

* Forgot to use md_source when resolving conflicts

* Update Dockerfile

* Use base image, clean up cruft from docsarchive folder

* Update docs-base to be self-browseable, conf source of truth
  • Loading branch information
johndmulhausen authored Feb 10, 2017
1 parent a1a1f93 commit 69f622b
Show file tree
Hide file tree
Showing 22 changed files with 124 additions and 240 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
.gitignore
Dockerfile
docker-compose.yml
_site
82 changes: 37 additions & 45 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,53 +1,45 @@
FROM starefossen/github-pages
FROM docs/docs-base

ENV VERSIONS="v1.4 v1.5 v1.6 v1.7 v1.8 v1.9 v1.10 v1.11 v1.12"
# docs-base contains: GitHub Pages, nginx, and the docs archives, running on
# Debian Jesse. See the Dockerfile for docs-base at:
# _data/docsarchive/docs-base in the docs repo

# Create archive; check out each version, create HTML, tweak links
RUN git clone https://www.github.com/docker/docker.github.io temp; \
for VER in $VERSIONS; do \
git --git-dir=./temp/.git --work-tree=./temp checkout ${VER} \
&& mkdir -p allvbuild/${VER} \
&& jekyll build -s temp -d allvbuild/${VER} \
&& find allvbuild/${VER} -type f -name '*.html' -print0 | xargs -0 sed -i 's#href="/#href="/'"$VER"'/#g' \
&& find allvbuild/${VER} -type f -name '*.html' -print0 | xargs -0 sed -i 's#src="/#src="/'"$VER"'/#g' \
&& find allvbuild/${VER} -type f -name '*.html' -print0 | xargs -0 sed -i 's#href="https://docs.docker.com/#href="/'"$VER"'/#g'; \
done; \
rm -rf temp
# Copy master into target directory (skipping files / folders in .dockerignore)
# These files represent the current docs
COPY . md_source

COPY . allv
# Move built html into md_source directory so we can reuse the target directory
# to hold the static output.
# Pull reference docs from upstream locations, then build the master docs
# into static HTML in the "target" directory using Jekyll
# then nuke the md_source directory.

## Branch to pull from, per ref doc
ENV ENGINE_BRANCH="1.13.x"
ENV DISTRIBUTION_BRANCH="release/2.5"

# The statements below pull reference docs from upstream locations,
# then build the whole site to static HTML using Jekyll

RUN svn co https://github.com/docker/docker/branches/$ENGINE_BRANCH/docs/extend allv/engine/extend \
&& wget -O allv/engine/api/v1.18.md https://raw.githubusercontent.com/docker/docker/$ENGINE_BRANCH/docs/api/v1.18.md \
&& wget -O allv/engine/api/v1.19.md https://raw.githubusercontent.com/docker/docker/$ENGINE_BRANCH/docs/api/v1.19.md \
&& wget -O allv/engine/api/v1.20.md https://raw.githubusercontent.com/docker/docker/$ENGINE_BRANCH/docs/api/v1.20.md \
&& wget -O allv/engine/api/v1.21.md https://raw.githubusercontent.com/docker/docker/$ENGINE_BRANCH/docs/api/v1.21.md \
&& wget -O allv/engine/api/v1.22.md https://raw.githubusercontent.com/docker/docker/$ENGINE_BRANCH/docs/api/v1.22.md \
&& wget -O allv/engine/api/v1.23.md https://raw.githubusercontent.com/docker/docker/$ENGINE_BRANCH/docs/api/v1.23.md \
&& wget -O allv/engine/api/v1.24.md https://raw.githubusercontent.com/docker/docker/$ENGINE_BRANCH/docs/api/v1.24.md \
&& wget -O allv/engine/api/version-history.md https://raw.githubusercontent.com/docker/docker/$ENGINE_BRANCH/docs/api/version-history.md \
&& wget -O allv/engine/reference/glossary.md https://raw.githubusercontent.com/docker/docker/$ENGINE_BRANCH/docs/reference/glossary.md \
&& wget -O allv/engine/reference/builder.md https://raw.githubusercontent.com/docker/docker/$ENGINE_BRANCH/docs/reference/builder.md \
&& wget -O allv/engine/reference/run.md https://raw.githubusercontent.com/docker/docker/$ENGINE_BRANCH/docs/reference/run.md \
&& wget -O allv/engine/reference/commandline/cli.md https://raw.githubusercontent.com/docker/docker/$ENGINE_BRANCH/docs/reference/commandline/cli.md \
&& wget -O allv/engine/deprecated.md https://raw.githubusercontent.com/docker/docker/$ENGINE_BRANCH/docs/deprecated.md \
&& svn co https://github.com/docker/distribution/branches/$DISTRIBUTION_BRANCH/docs/spec allv/registry/spec \
&& rm allv/registry/spec/api.md.tmpl \
&& wget -O allv/registry/configuration.md https://raw.githubusercontent.com/docker/distribution/$DISTRIBUTION_BRANCH/docs/configuration.md \
&& rm -rf allv/apidocs/cloud-api-source \
&& rm -rf allv/tests \
&& wget -O allv/engine/api/v1.25/swagger.yaml https://raw.githubusercontent.com/docker/docker/v1.13.0/api/swagger.yaml \
&& wget -O allv/engine/api/v1.26/swagger.yaml https://raw.githubusercontent.com/docker/docker/$ENGINE_BRANCH/api/swagger.yaml \
&& jekyll build -s allv -d allvbuild \
&& rm -rf allvbuild/apidocs/layouts \
&& find allvbuild -type f -name '*.html' -print0 | xargs -0 sed -i 's#href="https://docs.docker.com/#href="/#g' \
&& rm -rf allv

# Serve the site, which is now all static HTML
CMD jekyll serve -s /usr/src/app/allvbuild --no-watch -H 0.0.0.0 -P 4000
RUN svn co https://github.com/docker/docker/branches/$ENGINE_BRANCH/docs/extend md_source/engine/extend \
&& wget -O md_source/engine/api/v1.18.md https://raw.githubusercontent.com/docker/docker/$ENGINE_BRANCH/docs/api/v1.18.md \
&& wget -O md_source/engine/api/v1.19.md https://raw.githubusercontent.com/docker/docker/$ENGINE_BRANCH/docs/api/v1.19.md \
&& wget -O md_source/engine/api/v1.20.md https://raw.githubusercontent.com/docker/docker/$ENGINE_BRANCH/docs/api/v1.20.md \
&& wget -O md_source/engine/api/v1.21.md https://raw.githubusercontent.com/docker/docker/$ENGINE_BRANCH/docs/api/v1.21.md \
&& wget -O md_source/engine/api/v1.22.md https://raw.githubusercontent.com/docker/docker/$ENGINE_BRANCH/docs/api/v1.22.md \
&& wget -O md_source/engine/api/v1.23.md https://raw.githubusercontent.com/docker/docker/$ENGINE_BRANCH/docs/api/v1.23.md \
&& wget -O md_source/engine/api/v1.24.md https://raw.githubusercontent.com/docker/docker/$ENGINE_BRANCH/docs/api/v1.24.md \
&& wget -O md_source/engine/api/version-history.md https://raw.githubusercontent.com/docker/docker/$ENGINE_BRANCH/docs/api/version-history.md \
&& wget -O md_source/engine/reference/glossary.md https://raw.githubusercontent.com/docker/docker/$ENGINE_BRANCH/docs/reference/glossary.md \
&& wget -O md_source/engine/reference/builder.md https://raw.githubusercontent.com/docker/docker/$ENGINE_BRANCH/docs/reference/builder.md \
&& wget -O md_source/engine/reference/run.md https://raw.githubusercontent.com/docker/docker/$ENGINE_BRANCH/docs/reference/run.md \
&& wget -O md_source/engine/reference/commandline/cli.md https://raw.githubusercontent.com/docker/docker/$ENGINE_BRANCH/docs/reference/commandline/cli.md \
&& wget -O md_source/engine/deprecated.md https://raw.githubusercontent.com/docker/docker/$ENGINE_BRANCH/docs/deprecated.md \
&& svn co https://github.com/docker/distribution/branches/$DISTRIBUTION_BRANCH/docs/spec md_source/registry/spec \
&& rm md_source/registry/spec/api.md.tmpl \
&& wget -O md_source/registry/configuration.md https://raw.githubusercontent.com/docker/distribution/$DISTRIBUTION_BRANCH/docs/configuration.md \
&& rm -rf md_source/apidocs/cloud-api-source \
&& rm -rf md_source/tests \
&& wget -O md_source/engine/api/v1.25/swagger.yaml https://raw.githubusercontent.com/docker/docker/v1.13.0/api/swagger.yaml \
&& wget -O md_source/engine/api/v1.26/swagger.yaml https://raw.githubusercontent.com/docker/docker/$ENGINE_BRANCH/api/swagger.yaml \
&& jekyll build -s md_source -d target \
&& rm -rf target/apidocs/layouts \
&& find target -type f -name '*.html' -print0 | xargs -0 sed -i 's#href="https://docs.docker.com/#href="/#g' \
&& rm -rf md_source
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source "https://rubygems.org"

gem "github-pages", "105" #Update me once in a while: https://github.com/github/pages-gem/releases
gem "github-pages", "112" #Update me once in a while: https://github.com/github/pages-gem/releases
Empty file removed _data/docsarchive/archive.yml
Empty file.
51 changes: 51 additions & 0 deletions _data/docsarchive/docs-base/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
FROM starefossen/github-pages:112

# This is the source for docs/docs-base. Push to that location to ensure that
# the production image gets your update :)

# Install nginx

ENV NGINX_VERSION 1.11.9-1~jessie

RUN apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 \
&& echo "deb http://nginx.org/packages/mainline/debian/ jessie nginx" >> /etc/apt/sources.list \
&& apt-get update \
&& apt-get install --no-install-recommends --no-install-suggests -y \
ca-certificates \
nginx=${NGINX_VERSION} \
&& rm -rf /var/lib/apt/lists/*

# Forward nginx request and error logs to docker log collector

RUN ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log

COPY nginx.conf /etc/nginx/nginx.conf

## At the end of each layer, everything we need to pass on to the next layer
## should be in the "target" directory and we should have removed all temporary files

# Create archive; check out each version, create HTML under target/$VER, tweak links
# Nuke the archive_source directory. Only keep the target directory.

ENV VERSIONS="v1.4 v1.5 v1.6 v1.7 v1.8 v1.9 v1.10 v1.11 v1.12"

RUN git clone https://www.github.com/docker/docker.github.io archive_source; \
for VER in $VERSIONS; do \
git --git-dir=./archive_source/.git --work-tree=./archive_source checkout ${VER} \
&& mkdir -p target/${VER} \
&& jekyll build -s archive_source -d target/${VER} \
&& find target/${VER} -type f -name '*.html' -print0 | xargs -0 sed -i 's#href="/#href="/'"$VER"'/#g' \
&& find target/${VER} -type f -name '*.html' -print0 | xargs -0 sed -i 's#src="/#src="/'"$VER"'/#g' \
&& find target/${VER} -type f -name '*.html' -print0 | xargs -0 sed -i 's#href="https://docs.docker.com/#href="/'"$VER"'/#g'; \
done; \
rm -rf archive_source

# This index file gets overwritten, but it serves a sort-of useful purpose in
# making the docs/docs-base image browsable:

COPY index.html target

# Serve the site (target), which is now all static HTML

CMD echo "Docker docs are viewable at:" && echo "http://0.0.0.0:4000" && exec nginx
16 changes: 16 additions & 0 deletions _data/docsarchive/docs-base/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<html>
<body>
<h1>Docs archive</h1>
<ul>
<li><a href="/v1.4">v1.4</a></li>
<li><a href="/v1.5">v1.5</a></li>
<li><a href="/v1.6">v1.6</a></li>
<li><a href="/v1.7">v1.7</a></li>
<li><a href="/v1.8">v1.8</a></li>
<li><a href="/v1.9">v1.9</a></li>
<li><a href="/v1.10">v1.10</a></li>
<li><a href="/v1.11">v1.11</a></li>
<li><a href="/v1.12">v1.12</a></li>
</ul>
</body>
</html>
16 changes: 16 additions & 0 deletions _data/docsarchive/docs-base/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
worker_processes 1;
daemon off;

events {
worker_connections 1024;
}

http {
server {
root /usr/src/app/target;
location / {
include /etc/nginx/mime.types;
}
listen 4000;
}
}
15 changes: 0 additions & 15 deletions _data/docsarchive/v1.10/Dockerfile

This file was deleted.

15 changes: 0 additions & 15 deletions _data/docsarchive/v1.11/Dockerfile

This file was deleted.

15 changes: 0 additions & 15 deletions _data/docsarchive/v1.4/Dockerfile

This file was deleted.

15 changes: 0 additions & 15 deletions _data/docsarchive/v1.5/Dockerfile

This file was deleted.

15 changes: 0 additions & 15 deletions _data/docsarchive/v1.6/Dockerfile

This file was deleted.

15 changes: 0 additions & 15 deletions _data/docsarchive/v1.7/Dockerfile

This file was deleted.

15 changes: 0 additions & 15 deletions _data/docsarchive/v1.8/Dockerfile

This file was deleted.

15 changes: 0 additions & 15 deletions _data/docsarchive/v1.9/Dockerfile

This file was deleted.

12 changes: 0 additions & 12 deletions _data/docsarchive/vnext-compose/Dockerfile

This file was deleted.

12 changes: 0 additions & 12 deletions _data/docsarchive/vnext-distribution/Dockerfile

This file was deleted.

12 changes: 0 additions & 12 deletions _data/docsarchive/vnext-engine/Dockerfile

This file was deleted.

12 changes: 0 additions & 12 deletions _data/docsarchive/vnext-kitematic/Dockerfile

This file was deleted.

12 changes: 0 additions & 12 deletions _data/docsarchive/vnext-machine/Dockerfile

This file was deleted.

12 changes: 0 additions & 12 deletions _data/docsarchive/vnext-toolbox/Dockerfile

This file was deleted.

Loading

0 comments on commit 69f622b

Please sign in to comment.