From 3c89d31fb3d6494ab0fbf7c08f7315816233722b Mon Sep 17 00:00:00 2001
From: David Beniamine <david.beniamine@tetras-libre.fr>
Date: Tue, 31 Mar 2020 11:17:10 +0200
Subject: [PATCH] Almost working version + doc

---
 Readme             | 49 +++++++++++++++++++++++++++++++++++++++++++++-
 docker-compose.yml |  6 +++---
 docker/Dockerfile  | 12 ++++++------
 docker/noemie.conf | 14 +++++++++++++
 4 files changed, 71 insertions(+), 10 deletions(-)
 create mode 100644 docker/noemie.conf

diff --git a/Readme b/Readme
index bc93bb7..d293a19 100644
--- a/Readme
+++ b/Readme
@@ -1 +1,48 @@
-This is a docker image for running [Pretty Noemi CMS]()
+This is a docker image for running [Pretty Noemi CMS](https://framagit.org/framasoft/PrettyNoemieCMS)
+
+## Installation
+
+```bash
+cp .env.sample .env
+docker-compose up
+ln -s /var/lib/docker/volume/prettynoemie_sites/_data/ sites
+```
+
+## Add a site
+
+### by copy
+
+```bash
+cp sites/framsite sites/mysite.fqdn
+```
+
+### From backup
+
+```bash
+cd sites
+unzip mysite.fqdn.zip
+```
+
+### Set the reverse proxy 
+
+Adapt this file and add it to `/etc/apache2/sites-available/mysite.conf`
+
+```apache2
+<VirtualHost *:80>
+    ServerName mysite.fqdn
+
+    #ProxyVia On
+    #ProxyRequests On
+    ProxyPreserveHost on
+
+    Header set X-FRAMA-SITE mysite.fqdn
+
+    ProxyPass / http://127.0.0.1:8000/
+    ProxyPassReverse / http://127.0.0.1:8000/
+
+    CustomLog ${APACHE_LOG_DIR}/mysite.tetras-libre.access.log combined
+    ErrorLog ${APACHE_LOG_DIR}/mysite-libre.error.log
+</VirtualHost>
+```
+
+Finaly run `certbot` to use HTTPS
diff --git a/docker-compose.yml b/docker-compose.yml
index 85025bd..5222be6 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,11 +1,11 @@
-version: '2'
+version: "3.7"
 
 services:
 
     front:
         build: ./docker
         volumes:
-          - 'noemie:/var/www/html/PrettyNoemieCMS'
+          - sites:/var/www/html/sites
         environment:
             restart: ${RESTART}
             PHP_INI_DATE_TIMEZONE: 'Europe/Paris'
@@ -14,4 +14,4 @@ services:
         restart: ${RESTART}
 
 volumes:
-    noemie:
+    sites:
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 6f28264..d86b0f8 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -14,16 +14,16 @@ RUN apt-get update && apt-get install -y \
 RUN docker-php-ext-install -j$(nproc) gd curl mbstring xml zip
 
 COPY install_composer.sh /
+COPY noemie.conf /etc/apache2/sites-available/
+RUN a2dissite 000-default.conf
+RUN a2ensite noemie.conf
 RUN /bin/bash /install_composer.sh
 RUN rm /install_composer.sh
 
-#COPY noemie.conf /etc/apache2/sites-enabled/000-default.conf
-
+WORKDIR /var/www/
+RUN git clone https://framagit.org/framasoft/PrettyNoemieCMS html
 WORKDIR /var/www/html
-RUN git clone https://framagit.org/framasoft/PrettyNoemieCMS
-WORKDIR /var/www/html/PrettyNoemieCMS
 RUN /usr/local/bin/composer.phar install
-RUN chown -R www-data /var/www/html/PrettyNoemieCMS
-WORKDIR /var/www/html
+RUN chown -R www-data /var/www/html/
 
 RUN a2enmod rewrite
diff --git a/docker/noemie.conf b/docker/noemie.conf
new file mode 100644
index 0000000..90f7199
--- /dev/null
+++ b/docker/noemie.conf
@@ -0,0 +1,14 @@
+<VirtualHost *:8000>
+    DocumentRoot /var/www/html
+
+    ErrorLog ${APACHE_LOG_DIR}/error.log
+    CustomLog ${APACHE_LOG_DIR}/access.log combined
+
+
+    <Directory "/var/www/html">
+        Options -Indexes +FollowSymLinks +Includes
+        AllowOverride All
+        Order allow,deny
+        Allow from All
+    </Directory>
+</VirtualHost>
-- 
GitLab