Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAchilleas Pipinellis <axilleas@axilleas.me>2017-09-08 18:04:03 +0300
committerAchilleas Pipinellis <axil@gitlab.com>2018-02-15 15:00:19 +0300
commitf8501806242e4425b531e97e67f842ebb351a8f6 (patch)
treee18f4f7062a8f024478ed6d06d76a0458853895d /dockerfiles
parent785008677aaa61a1db50540d800dd4fd306f6877 (diff)
Add Dockerfiles that will help build a versioned website
Diffstat (limited to 'dockerfiles')
-rw-r--r--dockerfiles/Dockerfile.bootstrap35
-rw-r--r--dockerfiles/Dockerfile.builder.onbuild28
-rw-r--r--dockerfiles/Dockerfile.nginx.onbuild19
-rw-r--r--dockerfiles/README.md30
-rw-r--r--dockerfiles/nginx-overrides.conf9
5 files changed, 121 insertions, 0 deletions
diff --git a/dockerfiles/Dockerfile.bootstrap b/dockerfiles/Dockerfile.bootstrap
new file mode 100644
index 00000000..ae776e46
--- /dev/null
+++ b/dockerfiles/Dockerfile.bootstrap
@@ -0,0 +1,35 @@
+#
+# This is the Nanoc boostrap Dockerfile which builds an image that contains
+# all Nanoc's runtime dependencies and gems.
+#
+
+FROM ruby:2.5-alpine
+
+# Install packages needed at build and run time
+RUN apk add --no-cache --virtual build-deps \
+ build-base \
+ ruby-dev \
+ libxslt-dev
+
+# Do not install rdoc to save some space
+RUN echo 'gem: --no-document' >> /etc/gemrc
+
+# Copy scripts used for static HTML post-processing
+COPY scripts /scripts/
+
+# Copy only Gemfile and Gemfile.lock
+COPY /Gemfile* /source/
+WORKDIR /source
+
+# Install gems
+RUN NOKOGIRI_USE_SYSTEM_LIBRARIES=1 bundle install --jobs 4
+
+# Cleanup
+RUN apk del build-deps \
+ && rm -rf /usr/lib/ruby/gems/*/cache/*.gem \
+ && rm -rf /usr/src/Gemfile*
+
+# Install packages needed at build and run time
+RUN apk add --no-cache libxslt libcurl openssl git grep bash
+
+CMD echo "Nothing to do here. This is the bootstrap image that contains all dependencies to build the docs site."
diff --git a/dockerfiles/Dockerfile.builder.onbuild b/dockerfiles/Dockerfile.builder.onbuild
new file mode 100644
index 00000000..02606155
--- /dev/null
+++ b/dockerfiles/Dockerfile.builder.onbuild
@@ -0,0 +1,28 @@
+# Get Nanoc bootstrap
+FROM registry.gitlab.com/gitlab-com/gitlab-docs:bootstrap
+
+# Make the variables of the archive Dockerfiles accessible to this build-stage
+ONBUILD ARG VER
+ONBUILD ARG BRANCH_EE
+ONBUILD ARG BRANCH_CE
+ONBUILD ARG BRANCH_OMNIBUS
+ONBUILD ARG BRANCH_RUNNER
+
+# Build the docs from this branch
+ONBUILD COPY . /source/
+ONBUILD RUN bundle exec rake setup_git default
+ONBUILD RUN bundle exec nanoc compile -VV
+
+# Move generated HTML to /site
+ONBUILD RUN mkdir /site
+ONBUILD RUN mv /source/public /site/${VER}
+
+# Remove tmp dir to save some space
+ONBUILD RUN rm -rf /source/tmp
+
+# Do some HTML post-processing on the archive
+ONBUILD RUN /scripts/normalize-links.sh /site ${VER}
+
+# Make an index.html and 404.html which will redirect / to /${VER}/
+ONBUILD RUN echo "<html><head><title>Redirect for ${VER}</title><meta http-equiv=\"refresh\" content=\"0;url='/${VER}/'\" /></head><body><p>If you are not redirected automatically, click <a href=\"/${VER}/\">here</a>.</p></body></html>" > /site/index.html
+ONBUILD RUN echo "<html><head><title>Redirect for ${VER}</title><meta http-equiv=\"refresh\" content=\"0;url='/${VER}/'\" /></head><body><p>If you are not redirected automatically, click <a href=\"/${VER}/\">here</a>.</p></body></html>" > /site/404.html
diff --git a/dockerfiles/Dockerfile.nginx.onbuild b/dockerfiles/Dockerfile.nginx.onbuild
new file mode 100644
index 00000000..34ebb7c8
--- /dev/null
+++ b/dockerfiles/Dockerfile.nginx.onbuild
@@ -0,0 +1,19 @@
+# Base image to use for building documentation archives
+# this image uses "ONBUILD" to perform all required steps in the archives
+# and relies upon its parent image having a layer called `builder`.
+
+FROM nginx:alpine
+
+# Make the version accessible to this build-stage, and copy it to an ENV so that it persists in the final image
+ONBUILD ARG VER
+ONBUILD ENV VER=$VER
+
+# Clean out any existing HTML files, and copy the HTML from the builder stage to the default location for Nginx
+ONBUILD RUN rm -rf /usr/share/nginx/html/*
+ONBUILD COPY --from=builder /site /usr/share/nginx/html
+
+# Copy the Nginx config
+COPY dockerfiles/nginx-overrides.conf /etc/nginx/conf.d/default.conf
+
+# Start Nginx to serve the archive at / (which will redirect to the version-specific dir)
+CMD echo -e "GitLab docs are viewable at:\nhttp://0.0.0.0:4000"; exec nginx -g 'daemon off;'
diff --git a/dockerfiles/README.md b/dockerfiles/README.md
new file mode 100644
index 00000000..3e8b2b4e
--- /dev/null
+++ b/dockerfiles/README.md
@@ -0,0 +1,30 @@
+# Dockerfiles used to build the docs site
+
+This directory contains all needed Dockerfiles to build and deploy the website.
+It is heavily inspired by Docker's [publish tools](https://github.com/docker/docker.github.io/tree/publish-tools).
+
+## When to update the Dockerfiles
+
+| Dockerfile | Docker image | Description |
+| ---------- | ------------ | ----------- |
+| `Dockerfile.bootstrap` | `gitlab-docs:bootstrap` | This image contains all the dependencies that are needed to build the website. If the gems are updated and `Gemfile{,.lock}` changes, the image must be rebuilt. |
+
+## How to build the images
+
+For each image, there's a manual job under the `images` stage in
+[`.gitlab-ci.yml`](../.gitlab-ci.yml).
+
+Build and tag all tooling images:
+
+```sh
+docker build -t registry.gitlab.com/gitlab-com/gitlab-docs:bootstrap -f Dockerfile.bootstrap ../
+docker build -t registry.gitlab.com/gitlab-com/gitlab-docs:builder-onbuild -f Dockerfile.builder.onbuild ../
+docker build -t registry.gitlab.com/gitlab-com/gitlab-docs:nginx-onbuild -f Dockerfile.nginx.onbuild ../
+```
+
+For each archive branch, build the archive's image:
+
+```
+git checkout 10-4-stable
+docker build -t registry.gitlab.com/gitlab-com/gitlab-docs/docs:10.4 .
+```
diff --git a/dockerfiles/nginx-overrides.conf b/dockerfiles/nginx-overrides.conf
new file mode 100644
index 00000000..7564d0c9
--- /dev/null
+++ b/dockerfiles/nginx-overrides.conf
@@ -0,0 +1,9 @@
+server {
+ port_in_redirect off;
+ listen 4000;
+ error_page 403 404 /404.html;
+ location / {
+ root /usr/share/nginx/html;
+ index index.html index.htm;
+ }
+} \ No newline at end of file