From 2297c1d73437207c5d9a593d5dbf617366e0c37f Mon Sep 17 00:00:00 2001
From: Romain de Laage <romain.delaage@rdelaage.ovh>
Date: Thu, 29 Oct 2020 09:41:10 +0100
Subject: [PATCH] [Whiteboard] Add landing page

---
 pica-whiteboard/Dockerfile         |  6 +++++-
 pica-whiteboard/default.conf       | 19 +++++++++++++++++++
 pica-whiteboard/docker-compose.yml |  2 +-
 pica-whiteboard/entrypoint.sh      |  1 +
 pica-whiteboard/index.html         | 16 ++++++++++++++++
 5 files changed, 42 insertions(+), 2 deletions(-)
 create mode 100644 pica-whiteboard/default.conf
 create mode 100644 pica-whiteboard/index.html

diff --git a/pica-whiteboard/Dockerfile b/pica-whiteboard/Dockerfile
index a59a8c5d..dc150c2e 100644
--- a/pica-whiteboard/Dockerfile
+++ b/pica-whiteboard/Dockerfile
@@ -4,6 +4,8 @@ ENV WBVERSION=1.5 \
     SCVERSION=0.1.11
 
 RUN apk add --no-cache --virtual .download ca-certificates wget && \
+    apk add --no-cache nginx && \
+    mkdir /run/nginx && touch /run/nginx/nginx.pid && \
     wget https://github.com/cracker0dks/whiteboard/archive/v$WBVERSION.tar.gz && \
     wget https://github.com/aptible/supercronic/releases/download/v$SCVERSION/supercronic-linux-amd64 && \
     chmod +x supercronic-linux-amd64 && \
@@ -16,9 +18,11 @@ RUN apk add --no-cache --virtual .download ca-certificates wget && \
     apk del .download
 
 ADD entrypoint.sh /entrypoint.sh
+ADD default.conf /etc/nginx/conf.d/default.conf
+ADD index.html /var/www/localhost/htdocs/index.html
 
 RUN chmod +x /entrypoint.sh
 
-EXPOSE 8080
+EXPOSE 80
 
 ENTRYPOINT ["/entrypoint.sh"]
diff --git a/pica-whiteboard/default.conf b/pica-whiteboard/default.conf
new file mode 100644
index 00000000..f4a85715
--- /dev/null
+++ b/pica-whiteboard/default.conf
@@ -0,0 +1,19 @@
+server {
+	listen 80 default_server;
+	listen [::]:80 default_server;
+
+	root /var/www/localhost/htdocs;
+
+	index index.html;
+
+	location / {
+		try_files $uri $uri/ =404;
+	}
+
+	location /app/ {
+		proxy_pass http://whiteboard-app:8080/;
+		proxy_set_header Host $host;
+		proxy_set_header X-Real-IP $remote_addr;
+		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+	}
+}
diff --git a/pica-whiteboard/docker-compose.yml b/pica-whiteboard/docker-compose.yml
index f8733545..6d112903 100644
--- a/pica-whiteboard/docker-compose.yml
+++ b/pica-whiteboard/docker-compose.yml
@@ -11,7 +11,7 @@ services:
     labels:
       traefik.http.routers.whiteboard-app.entrypoints: websecure
       traefik.http.routers.whiteboard-app.rule: Host(`whiteboard.picasoft.net`)
-      traefik.http.services.whiteboard-app.loadbalancer.server.port: 8080
+      traefik.http.services.whiteboard-app.loadbalancer.server.port: 80
       traefik.enable: true
     environment:
       STOP_APP: "0 0 * * *"
diff --git a/pica-whiteboard/entrypoint.sh b/pica-whiteboard/entrypoint.sh
index eee67969..618a4d28 100644
--- a/pica-whiteboard/entrypoint.sh
+++ b/pica-whiteboard/entrypoint.sh
@@ -6,4 +6,5 @@ $STOP_APP pkill node
 $RESTART_APP cd /opt/whiteboard && node server.js --mode=production
 EOF
 node server.js --mode=production &
+nginx
 supercronic crontab
diff --git a/pica-whiteboard/index.html b/pica-whiteboard/index.html
new file mode 100644
index 00000000..fb553d34
--- /dev/null
+++ b/pica-whiteboard/index.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+	<head>
+		<title>Whiteboard Picasoft</title>
+		<meta charset="utf-8" />
+	</head>
+	<body>
+		<h1>Whiteboard de Picasoft</h1>
+		<p>
+		Vous êtes sur le whiteboard hébergé par Picasoft, celui-ci est réinitialisé toutes les nuits (vers minuit)
+		</p>
+		<p>
+		<a href⁼"https://picasoft.net/co/cgu.html">CGU</a>
+		</p>
+	</body>
+</html>
-- 
GitLab