From 6c683667ba0098c7e08eb72ea778ef148c542b72 Mon Sep 17 00:00:00 2001
From: Jeffrey Phillips Freeman <jeff@scentech-medical.com>
Date: Sat, 28 Jan 2023 15:41:00 +0200
Subject: [PATCH] Made dockerfile modjular

---
 .dockerignore                               |   1 +
 .gitlab-ci.yml                              |   2 +-
 30-add-host-ip-entry.sh                     |   3 +
 CHANGELOG.md                                |   6 +-
 Dockerfile                                  | 106 ++++++++++++++++++--
 README.md                                   |  69 -------------
 docker-compose.yml                          |  36 +------
 docker-entrypoint.sh                        |  35 +++++++
 docker-run.sh                               |  65 ++++++++++++
 pandoc-docker/latex/install-tex-packages.sh |  71 +++++++++++++
 pandoc-docker/latex/install-texlive.sh      |  12 +++
 pandoc-docker/latex/texlive.profile         |  32 ++++++
 proxy.template                              |  26 -----
 redirect.template                           |  28 ------
 run.sh                                      |  76 --------------
 src/puppeteerConfigFile.json                |   7 ++
 16 files changed, 334 insertions(+), 241 deletions(-)
 create mode 100644 .dockerignore
 create mode 100644 30-add-host-ip-entry.sh
 delete mode 100644 README.md
 create mode 100644 docker-entrypoint.sh
 create mode 100644 docker-run.sh
 create mode 100755 pandoc-docker/latex/install-tex-packages.sh
 create mode 100755 pandoc-docker/latex/install-texlive.sh
 create mode 100644 pandoc-docker/latex/texlive.profile
 delete mode 100644 proxy.template
 delete mode 100644 redirect.template
 delete mode 100644 run.sh
 create mode 100644 src/puppeteerConfigFile.json

diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..6c7b69a
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1 @@
+.gitignore
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index b297fc6..aed95f9 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -4,7 +4,7 @@ services:
   - docker:stable-dind
 
 variables:
-  REPOSITORY: "qotoorg/nginx-redirect"
+  REPOSITORY: "modjular/latex-pandoc-mermaid-plantuml"
 
 before_script:
   - echo "${DOCKER_TOKEN}" | docker login --username "${DOCKER_USER}" --password-stdin
diff --git a/30-add-host-ip-entry.sh b/30-add-host-ip-entry.sh
new file mode 100644
index 0000000..50dc6f2
--- /dev/null
+++ b/30-add-host-ip-entry.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+HOST_IP=$(/sbin/ip route|awk '/default/ { print $3 }')
+echo "$HOST_IP host.docker.internal" >> /etc/hosts
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2fbd6b6..31ffd98 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,5 @@
-# Aparapi Docker Image Changelog
+# latex-pandoc-mermaid-plantuml Docker Image Changelog
 
-# 2.0.0-1
+# 1.0.0
 
-* Initial version of the docker images for amdgpu and nvidia.
+* Initial version of the docker image
diff --git a/Dockerfile b/Dockerfile
index 913967b..563500c 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,14 +1,106 @@
-FROM nginx:alpine
+FROM alpine:edge
 
 LABEL maintainer "Jeffrey Phillips Freeman <the@jeffreyfreeman.me>"
 
-ADD run.sh /run.sh
-ADD redirect.template /etc/nginx/redirect.template
-ADD proxy.template /etc/nginx/proxy.template
+ARG UID=1000
+ARG GID=1000
 
-RUN chmod +x /run.sh
+RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
+#RUN apk update && apk upgrade
 
-CMD ["/run.sh"]
+RUN apk add --no-cache \
+    pandoc \
+    graphviz \
+    chromium \
+    nss \
+    freetype \
+    freetype-dev \
+    harfbuzz \
+    ca-certificates \
+    ttf-freefont \
+    font-fira-code \
+    nodejs \
+    yarn \
+    make \
+    plantuml \
+    py3-pip \
+    qpdf
 
-ENV VIRTUAL_PORT 80
+# commands from
 
+# install LaTeX
+# Parts of this file are copied from https://github.com/pandoc/dockerfiles
+RUN apk --no-cache add \
+    freetype \
+    fontconfig \
+    gnupg \
+    gzip \
+    librsvg \
+    perl \
+    tar \
+    wget \
+    xz
+# DANGER: this will vary for different distributions, particularly the
+# `linuxmusl` suffix.  Alpine linux is a musl libc based distribution, for other
+# "more common" distributions, you likely want just `-linux` suffix rather than
+# `-linuxmusl` ------------------------> vvvvvvvvv
+ENV PATH="/opt/texlive/texdir/bin/x86_64-linuxmusl:${PATH}"
+WORKDIR /root
+COPY pandoc-docker/latex/texlive.profile /root/texlive.profile
+COPY pandoc-docker/latex/install-texlive.sh /root/install-texlive.sh
+RUN echo "binary_x86_64-linuxmusl 1" >> /root/texlive.profile
+RUN /root/install-texlive.sh
+COPY pandoc-docker/latex/install-tex-packages.sh /root/install-tex-packages.sh
+RUN /root/install-tex-packages.sh
+RUN rm -f /root/texlive.profile \
+    /root/install-texlive.sh \
+    /root/install-tex-packages.sh
+WORKDIR /data
+
+# Tell Puppeteer to skip installing Chrome. We'll be using the installed package.
+ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
+    PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser \
+    PATH="/data/node_modules/.bin:${PATH}"
+
+ENV PATH="/usr/local/texlive/bin/x86_64-linuxmusl:${PATH}"
+
+# Add user so we don't need --no-sandbox.
+RUN addgroup -S pptruser -g $GID && adduser -S -G pptruser -u $UID pptruser \
+    && mkdir -p /home/pptruser \
+    && chown -R pptruser:pptruser /data \
+    && chmod o+w /opt/texlive/texdir/texmf-var \
+    && chown -R pptruser:pptruser /home/pptruser
+
+# Puppeteer v5.2.1 works with Chromium 85.
+RUN yarn add eslint puppeteer@5.2.1 mermaid-filter
+
+RUN cat /etc/apk/repositories
+
+# Install Tex Gyre Termes font
+RUN tlmgr update --self && tlmgr install tex-gyre tex-gyre-math selnolig
+
+# Install Noto Color Emoji
+RUN mkdir -p /usr/share/fonts/truetype/noto \
+    && cd /usr/share/fonts/truetype/noto \
+    && wget https://raw.githubusercontent.com/googlefonts/noto-emoji/master/fonts/NotoColorEmoji.ttf \
+    && fc-cache -fv
+
+RUN pip install pandoc-plantuml-filter
+RUN pip install pandoc-include
+
+# Allow pptruser to get root via sudo
+RUN apk add --no-cache alpine-sdk sudo \
+    && echo "pptruser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
+
+COPY docker-entrypoint.sh /docker-entrypoint.sh
+COPY 30-add-host-ip-entry.sh /docker-entrypoint.d/30-add-host-ip-entry.sh
+COPY docker-run.sh /docker-run.sh
+RUN mkdir -p /docker-run.d
+
+# Run everything after as non-privileged user.
+USER pptruser
+WORKDIR /home/pptruser
+COPY src/puppeteerConfigFile.json /home/pptruser/.puppeteer.json
+
+ENTRYPOINT [ "/docker-entrypoint.sh" ]
+CMD [ "/docker-run.sh" ]
diff --git a/README.md b/README.md
deleted file mode 100644
index 9908e5f..0000000
--- a/README.md
+++ /dev/null
@@ -1,69 +0,0 @@
-# docker-nginx-redirect
-
-A very simple container to redirect HTTP traffic to another server, based on `nginx`
-
-## Configuration
-
-### Environment variables
-
-Opertes in two modes, `proxy` and `redirect
-
-See also `docker-compose.yml` file.
-
-#### General Options
-
-The following engiernment variables can be set in any mode.
-
-- `SERVER_NAME` - optionally define the server name to listen on eg. `~^www.(?<subdomain>.+).example.com`
-   - useful for capturing variable to use in server_redirect. 
-- `SERVER_ACCESS_LOG` - optionally define the location where nginx will write its access log
-   - if not set /dev/stdout is used
-- `SERVER_ERROR_LOG` - optionally define the location where nginx will write its error log
-   - if not set /dev/stderr is used
-
-#### Proxy Options
-
-- `PROXY_HOST` - The IP or hostname of the destination server to proxy to.  This setting triggers the proxy 
-                 mode. Only the additional variables listed below will will work in proxy mode.
-- `PROXY_PORT` - The destination port to proxy to.
-- `PROXY_SSL_PORT` - An optional argument for a SSL port to redirect to. If left blank ssl will not redirect
-
-#### Redirect Options
-
-- `SERVER_REDIRECT` - server to redirect to, eg. `www.example.com`. This setting triggers redirect mode. Only
-                      the additional variables listed below will wok in redirect mode.
-- `SERVER_REDIRECT_PATH` - optionally define path to redirect all requests eg. `/landingpage`
-   - if not set nginx var `$request_uri` is used
-- `SERVER_REDIRECT_SCHEME` - optionally define scheme to redirect to 
-   - if not set but X-Forwarded-Proto is send as request header with value 'https' this will be used. 
-     In all other cases nginx var `$scheme` is used
-- `SERVER_REDIRECT_CODE` - optionally define the http status code to use for redirection
-   - if not set or not in list of allowed codes 301 is used as default
-   - allowed Codes are: 301, 302, 303, 307, 308
- - `SERVER_REDIRECT_POST_CODE` - optionally define the http code to use for POST redirection
-    - useful if client should not change the request method from POST to GET
-    - if not set or not in allowed Codes `SERVER_REDIRECT_CODE` is used
-    - so per default all requests will be redirected with the same status code
- - `SERVER_REDIRECT_PUT_PATCH_DELETE_CODE` - optionally define the http code to use for PUT, PATCH and DELETE redirection
-    - useful if client should not change the request method from PUT, PATCH and DELETE to GET
-    - if not set or not in allowed Codes `SERVER_REDIRECT_CODE` is used
-    - so per default all requests will be redirected with the same status code
-
-## Usage
-
-With `docker-compose`
-
-````bash
-docker-compose up -d
-````
-    
-With `docker`    
-
-```bash
-docker run -e SERVER_REDIRECT=www.example.com -p 8888:80 qotoorg/nginx-redirect
-docker run -e SERVER_REDIRECT=www.example.com -e SERVER_REDIRECT_PATH=/landingpage -p 8888:80 qotoorg/nginx-redirect
-docker run -e SERVER_REDIRECT=www.example.com -e SERVER_REDIRECT_PATH=/landingpage -e SERVER_REDIRECT_SCHEME=https -p 8888:80 qotoorg/nginx-redirect
-```
-## Resources
-
-This tool was adapted from the original you can get at [Github](https://github.com/schmunk42/docker-nginx-redirect)
diff --git a/docker-compose.yml b/docker-compose.yml
index 947d2b3..263e3cd 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,31 +1,5 @@
-nginx-redirect:
-  image: qotoorg/nginx-redirect
-  ports:
-    - "80"
-  environment:
-    - "SERVER_NAME=swarmpit.qoto.org"
-    - "PROXY_HOST=internal.swarm.qoto.org"
-    - "PROXY_PORT=888"
-    #- SERVER_REDIRECT=www.example.com
-    # optionally define path to redirect all requests
-    # if not set nginx var $request_uri is used
-    #- SERVER_REDIRECT_PATH=/landingpage
-    # optionally define schema to redirect all requests
-    # if not set but X-Forwarded-Proto is send as request header with value 'https' this will be used.
-    # In all other cases nginx var `$scheme` is used
-    #- SERVER_REDIRECT_SCHEME=https
-    # optionally define the http code to use for redirection
-    # allowed Codes are: 301, 302, 303, 307, 308, default is 301
-    #- SERVER_REDIRECT_CODE=301
-    # optionally define the http code to redirect POST requests
-    # if not set or not in allowed Codes, SERVER_REDIRECT_CODE will be used
-    #- SERVER_REDIRECT_POST_CODE=
-    # optionally define the http code to redirect PUT, PATCH and DELETE requests
-    # if not set or not in allowed Codes, SERVER_REDIRECT_CODE will be used
-    #- SERVER_REDIRECT_PUT_PATCH_DELETE_CODE=
-    # optionally define the location for the nginx access log
-    # if not set /dev/stdout is used
-    #- SERVER_ACCESS_LOG=/dev/null
-    # optionally define the location for the nginx error log
-    # if not set /dev/stderr is used
-    #- SERVER_ERROR_LOG=/dev/null
+version: '2'
+services:
+  latex-pandoc-mermaid-plantuml:
+    build: .
+    image: modjular/latex-pandoc-mermaid-plantuml
diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh
new file mode 100644
index 0000000..a2b1a03
--- /dev/null
+++ b/docker-entrypoint.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+set -e
+
+if [ -z "${NGINX_ENTRYPOINT_QUIET_LOGS:-}" ]; then
+    exec 3>&1
+else
+    exec 3>/dev/null
+fi
+
+if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -maxdepth 1 -type f -print -quit 2>/dev/null | read v; then
+    echo >&3 "$0: /docker-entrypoint.d/ is not empty, will attempt to perform configuration"
+
+    echo >&3 "$0: Looking for shell scripts in /docker-entrypoint.d/"
+    find "/docker-entrypoint.d/" -follow -type f -print | sort -n | while read -r f; do
+        case "$f" in
+            *.sh)
+                if [ -x "$f" ]; then
+                    echo >&3 "$0: Launching $f";
+                    "$f"
+                else
+                    # warn on shell scripts without exec bit
+                    echo >&3 "$0: Ignoring $f, not executable";
+                fi
+                ;;
+            *) echo >&3 "$0: Ignoring $f";;
+        esac
+    done
+
+    echo >&3 "$0: Configuration complete; ready for start up"
+else
+    echo >&3 "$0: No files found in /docker-entrypoint.d/, skipping configuration"
+fi
+
+exec "$@"
diff --git a/docker-run.sh b/docker-run.sh
new file mode 100644
index 0000000..b915ee9
--- /dev/null
+++ b/docker-run.sh
@@ -0,0 +1,65 @@
+#!/bin/bash
+# SIGTERM-handler
+term_handler() {
+  for PID in "${PIDS[@]}"
+  do
+    [[ -n "$PID" ]] && kill "$PID"
+  done
+
+  exit 0
+}
+
+trap 'term_handler' INT QUIT TERM
+
+set -e
+
+# Run all the scripts in the docker-run.d directory. If a script stopping should stop the container then
+# the script should export its PID in the PID variable, otherwise it should not export the variable.
+PIDS=()
+if /usr/bin/find "/docker-run.d/" -mindepth 1 -maxdepth 1 -type f -print -quit 2>/dev/null | read v; then
+  echo >&3 "$0: /docker-run.d/ is not empty, will attempt to bring up services"
+
+  echo >&3 "$0: Looking for shell scripts in /docker-run.d/"
+  for f in $(ls /docker-run.d/* | sort -n)
+  do
+    case "$f" in
+      *.sh)
+        if [ -x "$f" ]; then
+          echo >&3 "$0: Launching $f";
+          unset PID
+          source $f
+          PIDS+=( "${PID}" )
+        else
+          # warn on shell scripts without exec bit
+          echo >&3 "$0: Ignoring $f, not executable";
+        fi
+        ;;
+      *) echo >&3 "$0: Ignoring $f";;
+    esac
+  done
+
+
+  echo >&3 "$0: Start up complete, all services are now running."
+else
+  echo >&3 "$0: No files found in /docker-run.d/, nothing to do, will run forever!"
+  while :
+  do
+    sleep 1
+  done
+fi
+
+# Run indefinately until one of the running processes stops
+ALL_RUNNING="true"
+while [[ "$ALL_RUNNING" == "true" ]]; do
+  sleep 1
+  for PID in "${PIDS[@]}"
+  do
+    if [[ ! -e /proc/$PID ]]; then
+      ALL_RUNNING="false"
+      echo "One of the processes shutdown: ${PID}"
+    fi
+  done
+done
+
+# Stop container properly
+term_handler
diff --git a/pandoc-docker/latex/install-tex-packages.sh b/pandoc-docker/latex/install-tex-packages.sh
new file mode 100755
index 0000000..b06a9d7
--- /dev/null
+++ b/pandoc-docker/latex/install-tex-packages.sh
@@ -0,0 +1,71 @@
+#!/bin/sh
+################################################################################
+# Install pandoc latex packages: https://pandoc.org/MANUAL.html#creating-a-pdf #
+################################################################################
+# NOTE: search left hand side on CTAN to see for yourself:
+#       graphicx  -> graphics
+#       grffile   -> oberdiek
+#       longtable -> tools
+tlmgr install amsfonts \
+              amsmath \
+              babel \
+              booktabs \
+              fancyvrb \
+              geometry \
+              graphics \
+              hyperref \
+              iftex \
+              listings \
+              lm \
+              lm-math \
+              logreq \
+              oberdiek \
+              setspace \
+              tools \
+              ulem \
+              unicode-math \
+              xcolor \
+              || exit 1
+
+# Needed for when --highlight-style used with something other than pygments.
+tlmgr install framed || exit 1
+
+################################################################################
+# Install extra packages for XeTex, LuaTex, and BibLaTex.                      #
+################################################################################
+tlmgr install bidi \
+              csquotes \
+              fontspec \
+              luatex \
+              lualatex-math \
+              mathspec \
+              microtype \
+              pdftexcmds \
+              polyglossia \
+              selnolig \
+              upquote \
+              xecjk \
+              xetex \
+              || exit 1
+
+# Make sure all reference backend options are installed
+tlmgr install biber \
+              biblatex \
+              bibtex \
+              natbib \
+              || exit 1
+
+# These packages were identified by the tests, they are likely dependencies of
+# dependencies that are not encoded well.
+tlmgr install footnotehyper \
+              letltxmacro \
+              xurl \
+              || exit 1
+
+################################################################################
+# Trim down (possibly large amounts of) installed artifacts such as docs.      #
+################################################################################
+rm -rf /opt/texlive/texdir/texmf-dist/doc  \
+       /opt/texlive/texdir/readme-html.dir \
+       /opt/texlive/texdir/readme-txt.dir  \
+       /opt/texlive/texdir/install-tl*
diff --git a/pandoc-docker/latex/install-texlive.sh b/pandoc-docker/latex/install-texlive.sh
new file mode 100755
index 0000000..6bdb7a8
--- /dev/null
+++ b/pandoc-docker/latex/install-texlive.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+# Download / extract the install-tl perl script.
+wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz || exit 1
+mkdir -p ./install-tl
+tar --strip-components 1 -zvxf install-tl-unx.tar.gz -C "$PWD/install-tl" || exit 1
+
+# Run the default installation with the specified profile.
+./install-tl/install-tl --profile=/root/texlive.profile
+
+# Cleanup installation artifacts.
+rm -rf ./install-tl ./install-tl-unx.tar.gz
diff --git a/pandoc-docker/latex/texlive.profile b/pandoc-docker/latex/texlive.profile
new file mode 100644
index 0000000..1248071
--- /dev/null
+++ b/pandoc-docker/latex/texlive.profile
@@ -0,0 +1,32 @@
+# texlive.profile written on Tue Feb  5 09:43:07 2019 UTC
+# It will NOT be updated and reflects only the
+# installation profile at installation time.
+#
+# NOTE: see also alpine/latex.Dockerfile which appends
+# `binary_x86_64-linuxmusl 1` to this file, use for non-glibc distributions.
+selected_scheme scheme-small
+TEXDIR         /opt/texlive/texdir
+TEXMFLOCAL     /opt/texlive/texmf-local
+TEXMFSYSVAR    /opt/texlive/texdir/texmf-var
+TEXMFSYSCONFIG /opt/texlive/texdir/texmf-config
+TEXMFVAR       ~/.texlive/texmf-var
+TEXMFCONFIG    ~/.texlive/texmf-config
+TEXMFHOME      ~/texmf
+instopt_adjustpath 0
+instopt_adjustrepo 1
+instopt_letter 0
+instopt_portable 0
+instopt_write18_restricted 1
+tlpdbopt_autobackup 1
+tlpdbopt_backupdir tlpkg/backups
+tlpdbopt_create_formats 1
+tlpdbopt_desktop_integration 1
+tlpdbopt_file_assocs 1
+tlpdbopt_generate_updmap 0
+tlpdbopt_install_docfiles 0
+tlpdbopt_install_srcfiles 0
+tlpdbopt_post_code 1
+tlpdbopt_sys_bin /usr/local/bin
+tlpdbopt_sys_info /usr/local/share/info
+tlpdbopt_sys_man /usr/local/share/man
+tlpdbopt_w32_multi_user 1
diff --git a/proxy.template b/proxy.template
deleted file mode 100644
index 5f598e8..0000000
--- a/proxy.template
+++ /dev/null
@@ -1,26 +0,0 @@
-upstream app_upstream {
-    server ${PROXY_HOST}:${PROXY_PORT};
-}
-##START_SSL_UPSTREAM##
-upstream app_ssl_upstream {
-    server ${PROXY_HOST}:${PROXY_SSL_PORT};
-}
-##END_SSL_UPSTREAM##
-server {
-    listen 80;
-    server_name ${SERVER_NAME};
-
-    location / {
-        proxy_pass http://app_upstream;
-    }
-}
-##START_SSL_SERVER##
-server {
-    listen 443;
-    server_name ${SERVER_NAME};
-
-    location / {
-        proxy_pass https://app_ssl_upstream;
-    }
-}
-##END_SSL_SERVER##
diff --git a/redirect.template b/redirect.template
deleted file mode 100644
index 3e15cbb..0000000
--- a/redirect.template
+++ /dev/null
@@ -1,28 +0,0 @@
-map $http_x_forwarded_proto $redirect_scheme {
-    default $scheme;
-    https https;
-}
-
-server {
-    listen       80;
-    server_name  ${SERVER_NAME};
-
-    # cherry picked from https://github.com/schmunk42/docker-nginx-redirect/pull/8
-    if ($request_method = POST) {
-        return ${SERVER_REDIRECT_POST_CODE} ${SERVER_REDIRECT_SCHEME}://${SERVER_REDIRECT}${SERVER_REDIRECT_PATH};
-    }
-
-    if ($request_method ~ PUT|PATCH|DELETE) {
-        return ${SERVER_REDIRECT_PUT_PATCH_DELETE_CODE} ${SERVER_REDIRECT_SCHEME}://${SERVER_REDIRECT}${SERVER_REDIRECT_PATH};
-    }
-
-    return ${SERVER_REDIRECT_CODE} ${SERVER_REDIRECT_SCHEME}://${SERVER_REDIRECT}${SERVER_REDIRECT_PATH};
-
-    # redirect server error pages to the static page /50x.html
-    #
-    error_page   500 502 503 504  /50x.html;
-    location = /50x.html {
-        root   /usr/share/nginx/html;
-    }
-
-}
diff --git a/run.sh b/run.sh
deleted file mode 100644
index aeadc79..0000000
--- a/run.sh
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/usr/bin/env sh
-
-# set access log location from optional ENV var
-if [ ! -n "$SERVER_ACCESS_LOG" ] ; then
-  SERVER_ACCESS_LOG='/dev/stdout'
-fi
-
-# set error log location from optional ENV var
-if [ ! -n "$SERVER_ERROR_LOG" ] ; then
-  SERVER_ERROR_LOG='/dev/stderr'
-fi
-
-# set server name from optional ENV var
-if [ ! -n "$SERVER_NAME" ] ; then
-  SERVER_NAME='localhost'
-fi
-
-
-if [ -n "$PROXY_HOST" ] ; then
-
-  cp /etc/nginx/proxy.template /etc/nginx/conf.d/default.conf
-  sed -i "s|\${PROXY_HOST}|${PROXY_HOST}|" /etc/nginx/conf.d/default.conf
-  sed -i "s|\${PROXY_SSL_PORT}|${PROXY_SSL_PORT}|" /etc/nginx/conf.d/default.conf
-  sed -i "s|\${PROXY_PORT}|${PROXY_PORT}|" /etc/nginx/conf.d/default.conf
-  sed -i "s|\${SERVER_NAME}|${SERVER_NAME}|" /etc/nginx/conf.d/default.conf
-
-  # Remove the ssl section if a SSL port isnt specified
-  if [ ! -n "$PROXY_SSL_PORT" ] ; then
-    sed -i '/^##START_SSL_UPSTREAM##/,/^##END_SSL_UPSTREAM##/{/^##START_SSL_UPSTREAM##/!{/^##END_SSL_UPSTREAM##/!d}}' /etc/nginx/conf.d/default.conf
-    sed -i '/^##START_SSL_SERVER##/,/^##END_SSL_SERVER##/{/^##START_SSL_SERVER##/!{/^##END_SSL_SERVER##/!d}}' /etc/nginx/conf.d/default.conf
-    sed -i 's/^##[^#]*##$//g' /etc/nginx/conf.d/default.conf
-  else
-    #else lets just remove the comment blocks and make it pretty.
-    sed -i 's/^##[^#]*##$//g' /etc/nginx/conf.d/default.conf
-  fi
-
-fi
-
-if [ -n "$SERVER_REDIRECT" ] ; then
-  # set redirect code from optional ENV var
-  # allowed Status Codes are: 301, 302, 303, 307, 308
-  expr match "$SERVER_REDIRECT_CODE" '30[12378]$' > /dev/null || SERVER_REDIRECT_CODE='301'
-
-  # set redirect code from optional ENV var for POST requests
-  expr match "$SERVER_REDIRECT_POST_CODE" '30[12378]$' > /dev/null || SERVER_REDIRECT_POST_CODE=$SERVER_REDIRECT_CODE
-
-  # set redirect code from optional ENV var for PUT, PATCH and DELETE requests
-  expr match "$SERVER_REDIRECT_PUT_PATCH_DELETE_CODE" '30[12378]$' > /dev/null || SERVER_REDIRECT_PUT_PATCH_DELETE_CODE=$SERVER_REDIRECT_CODE
-
-  # set redirect path from optional ENV var
-  if [ ! -n "$SERVER_REDIRECT_PATH" ] ; then
-    SERVER_REDIRECT_PATH='$request_uri'
-  fi
-
-  # set redirect scheme from optional ENV var
-  if [ ! -n "$SERVER_REDIRECT_SCHEME" ] ; then
-    SERVER_REDIRECT_SCHEME='$redirect_scheme'
-  fi
-
-  cp /etc/nginx/redirect.template /etc/nginx/conf.d/default.conf
-  sed -i "s|\${SERVER_REDIRECT}|${SERVER_REDIRECT}|" /etc/nginx/conf.d/default.conf
-  sed -i "s|\${SERVER_NAME}|${SERVER_NAME}|" /etc/nginx/conf.d/default.conf
-  sed -i "s|\${SERVER_REDIRECT_CODE}|${SERVER_REDIRECT_CODE}|" /etc/nginx/conf.d/default.conf
-  sed -i "s|\${SERVER_REDIRECT_POST_CODE}|${SERVER_REDIRECT_POST_CODE}|" /etc/nginx/conf.d/default.conf
-  sed -i "s|\${SERVER_REDIRECT_PUT_PATCH_DELETE_CODE}|${SERVER_REDIRECT_PUT_PATCH_DELETE_CODE}|" /etc/nginx/conf.d/default.conf
-  sed -i "s|\${SERVER_REDIRECT_PATH}|${SERVER_REDIRECT_PATH}|" /etc/nginx/conf.d/default.conf
-  sed -i "s|\${SERVER_REDIRECT_SCHEME}|${SERVER_REDIRECT_SCHEME}|" /etc/nginx/conf.d/default.conf
-fi
-
-ln -sfT "$SERVER_ACCESS_LOG" /var/log/nginx/access.log
-ln -sfT "$SERVER_ERROR_LOG" /var/log/nginx/error.log
-
-echo "Configuration complete, generated /etc/nginx/conf.d/default.conf with the following content:"
-cat /etc/nginx/conf.d/default.conf
-
-exec nginx -g 'daemon off;'
diff --git a/src/puppeteerConfigFile.json b/src/puppeteerConfigFile.json
new file mode 100644
index 0000000..86fd697
--- /dev/null
+++ b/src/puppeteerConfigFile.json
@@ -0,0 +1,7 @@
+{
+  "args": [
+    "--no-sandbox",
+    "--disable-setuid-sandbox"
+  ],
+  "executablePath": "/usr/bin/chromium-browser"
+}
-- 
GitLab