From ea940ae4bb5ece487f339bbbc2593f5ebc91f18c Mon Sep 17 00:00:00 2001
From: Perreal Guillaume <guillaume.perreal@irstea.fr>
Date: Fri, 4 Oct 2019 16:29:11 +0200
Subject: [PATCH] =?UTF-8?q?Dockerisation=20+=20ajout=20de=20param=C3=A8tre?=
 =?UTF-8?q?s.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .dockerignore |  4 ++++
 Dockerfile    | 26 ++++++++++++++++++++++++++
 Gruntfile.js  | 18 ++++++++++++------
 3 files changed, 42 insertions(+), 6 deletions(-)
 create mode 100644 .dockerignore
 create mode 100644 Dockerfile

diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..317dee2
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,4 @@
+/src/
+/dist/
+/node_modules/
+/.?*
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..12be6d7
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,26 @@
+FROM node
+
+RUN mkdir -p /src /dist /reveal_js
+RUN ln -snf /src /reveal_js/src
+RUN ln -snf /dist /reveal_js/dist
+
+COPY package*.json /reveal_js/
+
+WORKDIR /reveal_js
+
+RUN npm install
+
+ARG PANDOC_VERSION=2.7.3
+
+ADD https://github.com/jgm/pandoc/releases/download/${PANDOC_VERSION}/pandoc-${PANDOC_VERSION}-linux.tar.gz /tmp/pandoc.tar.gz
+
+RUN tar xvfz /tmp/pandoc.tar.gz -C /usr/local --strip-components=1 \
+    && rm /tmp/pandoc.tar.gz
+
+COPY . /reveal_js
+
+EXPOSE 80/tcp 8899/tcp
+
+ENTRYPOINT ["/reveal_js/node_modules/.bin/grunt"]
+
+CMD ["serve"]
diff --git a/Gruntfile.js b/Gruntfile.js
index 222e27e..14988e6 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -1,8 +1,12 @@
 const { readdirSync } = require("fs");
 
 module.exports = grunt => {
-  const host = "127.0.0.1";
-  const liveReloadPort = 8899;
+  const PUBLIC_HOST = process.env.PUBLIC_HOST || "localhost";
+  const BIND_IP = process.env.BIND_IP || "0.0.0.0";
+  const BIND_PORT = 0 + process.env.BIND_PORT || 80;
+  const LIVERELOAD_PORT = 0 + process.env.LIVERELOAD_PORT || 8899;
+  const SLIDE_LEVEL = 0 + process.env.SLIDE_LEVEL || 2;
+  const TOC_DEPTH = 0 + process.env.TOC_DEPTH || SLIDE_LEVEL;
 
   const revealJsSources = ["js/**/*.js", "css/**/*.css", "lib/**", "plugin/**"];
 
@@ -11,7 +15,8 @@ module.exports = grunt => {
 
     "http-server": {
       dev: {
-        host,
+        host: BIND_IP,
+        port: BIND_PORT,
         root: "dist",
         runInBackground: true,
         openBrowser: true
@@ -29,7 +34,7 @@ module.exports = grunt => {
           debounceDelay: 1000,
           event: ["add", "change"],
           spawn: false,
-          livereload: liveReloadPort
+          livereload: LIVERELOAD_PORT
         }
       },
       revealjs: {
@@ -52,11 +57,12 @@ module.exports = grunt => {
             `--output=./${pres}${env !== "prod" ? "-" + env : ""}.html`,
             "--standalone",
             "--toc",
-            "--slide-level=2",
+            `--toc-depth=${TOC_DEPTH}`,
+            `--slide-level=${SLIDE_LEVEL}`,
             "--variable=theme:irstea",
             "--variable=history:true",
             env === "dev" &&
-              `--variable=header-includes='<script src="//${host}:${liveReloadPort}/livereload.js"></script>'`
+              `--variable=header-includes='<script src="//${PUBLIC_HOST}:${LIVERELOAD_PORT}/livereload.js"></script>'`
           ]
             .filter(v => !!v)
             .join(" "),
-- 
GitLab