From 7e14b54e2c4e14fb05f6d45aeaa4abb2b16eb59f Mon Sep 17 00:00:00 2001
From: Gabriel Landais <gabriel.landais@kereval.com>
Date: Mon, 25 Apr 2022 11:45:25 +0200
Subject: [PATCH] Build local website with Docker

---
 .dockerignore      |  1 +
 Dockerfile         | 37 +++++++++++++++++++++++++++++++++++++
 README.md          | 14 ++++++++++++++
 docker-compose.yml |  8 ++++++++
 4 files changed, 60 insertions(+)
 create mode 100644 .dockerignore
 create mode 100644 Dockerfile
 create mode 100644 docker-compose.yml

diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..eb5a316
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1 @@
+target
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..a85cd3d
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,37 @@
+# use an old version of Ruby
+FROM ruby:2.3.1 as builder
+
+USER root
+# non interactive
+ARG DEBIAN_FRONTEND=noninteractive
+# install utilities (gcc, ...)
+RUN apt-get update && apt-get install -y \
+        wget curl sudo build-essential git git-svn \
+        && rm -rf /var/lib/apt/lists/*
+
+# for gem dependencies
+RUN mkdir -p /opt/jekyll-gazelle-documentation
+WORKDIR /opt/jekyll-gazelle-documentation
+# copy only Gemfile/Gemfile.lock
+COPY _templates/jekyll-gazelle-documentation/Gemfile* /opt/jekyll-gazelle-documentation/
+# install bundler with version specified in Gemfile.lock
+RUN gem install bundler -v 1.17.3
+# install gem dependencies provided in Gemfile.lock
+RUN bundle install --deployment
+
+# copy all directory to /opt/gazelle-user-documentation
+RUN mkdir -p /opt/gazelle-user-documentation
+COPY . /opt/gazelle-user-documentation/
+WORKDIR /opt/gazelle-user-documentation/
+
+# build jekyll website
+RUN make jekyll
+
+# simple webserver
+FROM nginx:latest
+# html location
+RUN mkdir -p /usr/share/nginx/html/gazelle-documentation
+# copy jekyll website
+COPY --from=builder /opt/gazelle-user-documentation/target/jekyll-gazelle-documentation/_site /usr/share/nginx/html/gazelle-documentation/
+# create an index.html
+RUN cp /usr/share/nginx/html/gazelle-documentation/index-default.html /usr/share/nginx/html/gazelle-documentation/index.html
diff --git a/README.md b/README.md
index 724a3b9..3d74698 100644
--- a/README.md
+++ b/README.md
@@ -4,6 +4,20 @@ Generate gazelle framework documentation from markdown files.
 
 This project generates pdf, pdf with revision marks and a static  website (using jekyll).
 
+## Build and preview website with Docker
+
+It requires Docker and docker-compose installed.
+
+No local Ruby, Pandoc, tex, ... are required.
+
+To update website and serve it :
+
+```bash
+docker-compose up --build
+```
+
+Document is then available at <http://localhost:1080/gazelle-documentation/>
+
 ## Requirements
 
     sudo apt-get install make git git-svn texlive-xetex pandoc ruby-dev
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..0e92de7
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,8 @@
+version: "3.9"
+services:
+  gazelle-documentation:
+    build:
+      context: .
+      dockerfile: Dockerfile
+    ports:
+      - "127.0.0.1:1080:80"
-- 
GitLab