From 9fb1236f67e52731e89f20604679bebd4806c2f1 Mon Sep 17 00:00:00 2001
From: Picasoft Registry <picasoft@assos.picasoft.net>
Date: Sat, 18 Feb 2017 15:12:38 +0100
Subject: [PATCH] ajout slapd + mattermost

---
 mattermost/.travis.yml                        | 22 ++++++++++
 .../Dockerrun.aws.json                        |  0
 {tx-mattermost => mattermost}/LICENSE         |  0
 {tx-mattermost => mattermost}/README.aws.md   |  0
 {tx-mattermost => mattermost}/README.md       |  0
 {tx-mattermost => mattermost}/app/Dockerfile  |  4 +-
 .../app/config.template.json                  |  0
 .../app/docker-entry.sh                       |  0
 .../contrib/kubernetes/README.md              |  0
 .../kubernetes/mattermost.deployment.yaml     |  0
 .../contrib/kubernetes/mattermost.secret.yaml |  0
 .../contrib/kubernetes/mattermost.svc.yaml    |  0
 {tx-mattermost => mattermost}/db/Dockerfile   |  0
 .../db/docker-entrypoint1.sh                  |  6 +++
 {tx-mattermost => mattermost}/db/make_db.sh   |  0
 .../db/setup-wale.sh                          |  0
 .../docker-compose-v1.yml                     |  0
 mattermost/docker-compose.yml                 | 41 ++++++++++++++++++
 {tx-mattermost => mattermost}/web/Dockerfile  |  2 +-
 .../web/docker-entry.sh                       |  3 --
 {tx-mattermost => mattermost}/web/mattermost  |  2 +-
 .../web/mattermost-ssl                        |  2 +-
 pica-slapd/Dockerfile                         | 35 ++++++++++++++++
 pica-slapd/README.md                          | 40 ++++++++++++++++++
 pica-slapd/docker-compose.yml                 |  9 ++++
 pica-slapd/slapd.sh                           | 42 +++++++++++++++++++
 tx-etherpad/Dockerfile                        |  5 +++
 27 files changed, 205 insertions(+), 8 deletions(-)
 create mode 100644 mattermost/.travis.yml
 rename {tx-mattermost => mattermost}/Dockerrun.aws.json (100%)
 rename {tx-mattermost => mattermost}/LICENSE (100%)
 rename {tx-mattermost => mattermost}/README.aws.md (100%)
 rename {tx-mattermost => mattermost}/README.md (100%)
 rename {tx-mattermost => mattermost}/app/Dockerfile (68%)
 rename {tx-mattermost => mattermost}/app/config.template.json (100%)
 rename {tx-mattermost => mattermost}/app/docker-entry.sh (100%)
 rename {tx-mattermost => mattermost}/contrib/kubernetes/README.md (100%)
 rename {tx-mattermost => mattermost}/contrib/kubernetes/mattermost.deployment.yaml (100%)
 rename {tx-mattermost => mattermost}/contrib/kubernetes/mattermost.secret.yaml (100%)
 rename {tx-mattermost => mattermost}/contrib/kubernetes/mattermost.svc.yaml (100%)
 rename {tx-mattermost => mattermost}/db/Dockerfile (100%)
 rename {tx-mattermost => mattermost}/db/docker-entrypoint1.sh (87%)
 rename {tx-mattermost => mattermost}/db/make_db.sh (100%)
 rename {tx-mattermost => mattermost}/db/setup-wale.sh (100%)
 rename tx-mattermost/docker-compose.yml => mattermost/docker-compose-v1.yml (100%)
 create mode 100644 mattermost/docker-compose.yml
 rename {tx-mattermost => mattermost}/web/Dockerfile (96%)
 rename {tx-mattermost => mattermost}/web/docker-entry.sh (72%)
 rename {tx-mattermost => mattermost}/web/mattermost (92%)
 rename {tx-mattermost => mattermost}/web/mattermost-ssl (96%)
 create mode 100644 pica-slapd/Dockerfile
 create mode 100644 pica-slapd/README.md
 create mode 100644 pica-slapd/docker-compose.yml
 create mode 100644 pica-slapd/slapd.sh

diff --git a/mattermost/.travis.yml b/mattermost/.travis.yml
new file mode 100644
index 00000000..04ced962
--- /dev/null
+++ b/mattermost/.travis.yml
@@ -0,0 +1,22 @@
+sudo: required
+
+services:
+    - docker
+
+before_install:
+    - docker build -t mattermost-prod-db db
+    - docker build -t mattermost-prod-app app
+
+install:
+    - eval $BUILD
+    - sleep 10
+
+env:
+    - BUILD="docker-compose up -d"
+    - BUILD="docker run -d --name db mattermost-prod-db && sleep 5 && docker run -d --link db -p 80:80 --name app mattermost-prod-app"
+
+script:
+    - curl -sSf http://localhost > /dev/null
+
+after_failure:
+    - timeout 3s docker-compose logs app db web
diff --git a/tx-mattermost/Dockerrun.aws.json b/mattermost/Dockerrun.aws.json
similarity index 100%
rename from tx-mattermost/Dockerrun.aws.json
rename to mattermost/Dockerrun.aws.json
diff --git a/tx-mattermost/LICENSE b/mattermost/LICENSE
similarity index 100%
rename from tx-mattermost/LICENSE
rename to mattermost/LICENSE
diff --git a/tx-mattermost/README.aws.md b/mattermost/README.aws.md
similarity index 100%
rename from tx-mattermost/README.aws.md
rename to mattermost/README.aws.md
diff --git a/tx-mattermost/README.md b/mattermost/README.md
similarity index 100%
rename from tx-mattermost/README.md
rename to mattermost/README.md
diff --git a/tx-mattermost/app/Dockerfile b/mattermost/app/Dockerfile
similarity index 68%
rename from tx-mattermost/app/Dockerfile
rename to mattermost/app/Dockerfile
index 5280102b..3732032c 100644
--- a/tx-mattermost/app/Dockerfile
+++ b/mattermost/app/Dockerfile
@@ -1,9 +1,9 @@
-FROM pica-debian
+FROM ubuntu:14.04
 
 RUN apt-get update && apt-get -y install curl netcat
 RUN mkdir -p /mattermost/data
 
-RUN curl https://releases.mattermost.com/3.5.1/mattermost-team-3.5.1-linux-amd64.tar.gz | tar -xvz
+RUN curl https://releases.mattermost.com/3.6.1/mattermost-team-3.6.1-linux-amd64.tar.gz | tar -xvz
 
 RUN rm /mattermost/config/config.json
 COPY config.template.json /
diff --git a/tx-mattermost/app/config.template.json b/mattermost/app/config.template.json
similarity index 100%
rename from tx-mattermost/app/config.template.json
rename to mattermost/app/config.template.json
diff --git a/tx-mattermost/app/docker-entry.sh b/mattermost/app/docker-entry.sh
similarity index 100%
rename from tx-mattermost/app/docker-entry.sh
rename to mattermost/app/docker-entry.sh
diff --git a/tx-mattermost/contrib/kubernetes/README.md b/mattermost/contrib/kubernetes/README.md
similarity index 100%
rename from tx-mattermost/contrib/kubernetes/README.md
rename to mattermost/contrib/kubernetes/README.md
diff --git a/tx-mattermost/contrib/kubernetes/mattermost.deployment.yaml b/mattermost/contrib/kubernetes/mattermost.deployment.yaml
similarity index 100%
rename from tx-mattermost/contrib/kubernetes/mattermost.deployment.yaml
rename to mattermost/contrib/kubernetes/mattermost.deployment.yaml
diff --git a/tx-mattermost/contrib/kubernetes/mattermost.secret.yaml b/mattermost/contrib/kubernetes/mattermost.secret.yaml
similarity index 100%
rename from tx-mattermost/contrib/kubernetes/mattermost.secret.yaml
rename to mattermost/contrib/kubernetes/mattermost.secret.yaml
diff --git a/tx-mattermost/contrib/kubernetes/mattermost.svc.yaml b/mattermost/contrib/kubernetes/mattermost.svc.yaml
similarity index 100%
rename from tx-mattermost/contrib/kubernetes/mattermost.svc.yaml
rename to mattermost/contrib/kubernetes/mattermost.svc.yaml
diff --git a/tx-mattermost/db/Dockerfile b/mattermost/db/Dockerfile
similarity index 100%
rename from tx-mattermost/db/Dockerfile
rename to mattermost/db/Dockerfile
diff --git a/tx-mattermost/db/docker-entrypoint1.sh b/mattermost/db/docker-entrypoint1.sh
similarity index 87%
rename from tx-mattermost/db/docker-entrypoint1.sh
rename to mattermost/db/docker-entrypoint1.sh
index e21fe899..67d085a0 100755
--- a/tx-mattermost/db/docker-entrypoint1.sh
+++ b/mattermost/db/docker-entrypoint1.sh
@@ -4,12 +4,18 @@
 : ${WAL_LEVEL:=minimal}
 : ${ARCHIVE_MODE:=off}
 : ${ARCHIVE_TIMEOUT:=60}
+
+export WAL_LEVEL
+export ARCHIVE_MODE
+export ARCHIVE_TIMEOUT
+
 # PGDATA is defined in upstream postgres dockerfile
 
 function update_conf () {
     if [ -f $PGDATA/postgresql.conf ]; then
         sed -i "s/wal_level =.*$/wal_level = $WAL_LEVEL/g" $PGDATA/postgresql.conf
         sed -i "s/archive_mode =.*$/archive_mode = $ARCHIVE_MODE/g" $PGDATA/postgresql.conf
+        sed -i "s/archive_timeout =.*$/archive_timeout = $ARCHIVE_TIMEOUT/g" $PGDATA/postgresql.conf
     fi
 }
 
diff --git a/tx-mattermost/db/make_db.sh b/mattermost/db/make_db.sh
similarity index 100%
rename from tx-mattermost/db/make_db.sh
rename to mattermost/db/make_db.sh
diff --git a/tx-mattermost/db/setup-wale.sh b/mattermost/db/setup-wale.sh
similarity index 100%
rename from tx-mattermost/db/setup-wale.sh
rename to mattermost/db/setup-wale.sh
diff --git a/tx-mattermost/docker-compose.yml b/mattermost/docker-compose-v1.yml
similarity index 100%
rename from tx-mattermost/docker-compose.yml
rename to mattermost/docker-compose-v1.yml
diff --git a/mattermost/docker-compose.yml b/mattermost/docker-compose.yml
new file mode 100644
index 00000000..6751bd79
--- /dev/null
+++ b/mattermost/docker-compose.yml
@@ -0,0 +1,41 @@
+version: "2"
+
+services:
+
+  db:
+    build: db
+    restart: always
+    volumes:
+      - ./volumes/db/var/lib/postgresql/data:/var/lib/postgresql/data
+      - /etc/localtime:/etc/localtime:ro
+    # uncomment the following to enable backup
+    environment:
+      - MM_USERNAME=mmuser
+      - MM_PASSWORD=mmuser_password
+      - MM_DBNAME=mattermost
+    #  - AWS_ACCESS_KEY_ID=XXXX
+    #  - AWS_SECRET_ACCESS_KEY=XXXX
+    #  - WALE_S3_PREFIX=s3://BUCKET_NAME/PATH
+    #  - AWS_REGION=us-east-1
+
+  app:
+    build: app
+    restart: always
+    volumes:
+      - ./volumes/app/mattermost/config:/mattermost/config:rw
+      - ./volumes/app/mattermost/data:/mattermost/data:rw
+      - /etc/localtime:/etc/localtime:ro
+
+  web:
+    build: web
+    ports:
+      - "80:80"
+      - "443:443"
+    restart: always
+    volumes:
+      # This directory must have cert files
+      - ./volumes/web/cert:/cert:ro
+      - /etc/localtime:/etc/localtime:ro
+    environment:
+      - MATTERMOST_ENABLE_SSL=false
+      - PLATFORM_PORT_80_TCP_PORT=80
diff --git a/tx-mattermost/web/Dockerfile b/mattermost/web/Dockerfile
similarity index 96%
rename from tx-mattermost/web/Dockerfile
rename to mattermost/web/Dockerfile
index 21300667..af26369a 100644
--- a/tx-mattermost/web/Dockerfile
+++ b/mattermost/web/Dockerfile
@@ -1,4 +1,4 @@
-FROM pica-debian
+FROM ubuntu:14.04
 
 RUN apt-get update && apt-get install -y nginx
 
diff --git a/tx-mattermost/web/docker-entry.sh b/mattermost/web/docker-entry.sh
similarity index 72%
rename from tx-mattermost/web/docker-entry.sh
rename to mattermost/web/docker-entry.sh
index f0898cdf..4f90a5b4 100644
--- a/tx-mattermost/web/docker-entry.sh
+++ b/mattermost/web/docker-entry.sh
@@ -2,9 +2,6 @@
 echo Starting Nginx
 sed -Ei "s/APP_PORT/$PLATFORM_PORT_80_TCP_PORT/" /etc/nginx/sites-available/mattermost
 sed -Ei "s/APP_PORT/$PLATFORM_PORT_80_TCP_PORT/" /etc/nginx/sites-available/mattermost-ssl
-sed -Ei "s/APP_HOST/$APP_HOST/" /etc/nginx/sites-available/mattermost
-sed -Ei "s/APP_HOST/$APP_HOST/" /etc/nginx/sites-available/mattermost-ssl
-
 if [ "$MATTERMOST_ENABLE_SSL" = true ]; then
     ssl="-ssl"
 fi
diff --git a/tx-mattermost/web/mattermost b/mattermost/web/mattermost
similarity index 92%
rename from tx-mattermost/web/mattermost
rename to mattermost/web/mattermost
index 18fd3e85..69a64ec5 100644
--- a/tx-mattermost/web/mattermost
+++ b/mattermost/web/mattermost
@@ -17,6 +17,6 @@ server {
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;
         proxy_set_header X-Frame-Options SAMEORIGIN;
-        proxy_pass http://APP_HOST:APP_PORT;
+        proxy_pass http://app:APP_PORT;
     }
 }
diff --git a/tx-mattermost/web/mattermost-ssl b/mattermost/web/mattermost-ssl
similarity index 96%
rename from tx-mattermost/web/mattermost-ssl
rename to mattermost/web/mattermost-ssl
index 4ec471fa..ac28a9b5 100644
--- a/tx-mattermost/web/mattermost-ssl
+++ b/mattermost/web/mattermost-ssl
@@ -32,7 +32,7 @@ server {
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;
         proxy_set_header X-Frame-Options SAMEORIGIN;
-        proxy_pass http://APP_HOST:APP_PORT;
+        proxy_pass http://app:APP_PORT;
     }
 }
 
diff --git a/pica-slapd/Dockerfile b/pica-slapd/Dockerfile
new file mode 100644
index 00000000..5752f46f
--- /dev/null
+++ b/pica-slapd/Dockerfile
@@ -0,0 +1,35 @@
+FROM pica-debian
+MAINTAINER picasoft kyane@kyane.fr
+
+ENV HOME /root
+
+# Disable SSH
+RUN rm -rf /etc/service/sshd /etc/my_init.d/00_regen_ssh_host_keys.sh
+
+# Use baseimage-docker's init system.
+CMD ["/etc/service/slapd/run"]
+
+# Configure apt
+# RUN echo 'deb http://us.archive.ubuntu.com/ubuntu/ precise universe' >> /etc/apt/sources.list
+RUN apt-get -y update
+
+# Install slapd
+RUN LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get install -y slapd
+
+# Default configuration: can be overridden at the docker command line
+ENV LDAP_ROOTPASS password
+ENV LDAP_ORGANISATION Picasoft
+ENV LDAP_DOMAIN picasoft.net
+
+EXPOSE 389
+
+RUN mkdir -p /etc/service/slapd
+ADD slapd.sh /etc/service/slapd/run
+RUN chmod 755 /etc/service/slapd/run
+
+# To store the data outside the container, mount /var/lib/ldap as a data volume
+VOLUME /var/lib/ldap
+
+RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
+
+
diff --git a/pica-slapd/README.md b/pica-slapd/README.md
new file mode 100644
index 00000000..3780609c
--- /dev/null
+++ b/pica-slapd/README.md
@@ -0,0 +1,40 @@
+## slapd
+
+A basic configuration of the OpenLDAP server, slapd, with support for data
+volumes.
+
+This image will initialize a basic configuration of slapd. Most common schemas
+are preloaded (all the schemas that come preloaded with the default Ubuntu
+Precise install of slapd), but the only record added to the directory will be
+the root organisational unit.
+
+You can (and should) configure the following by providing environment variables
+to `docker run`:
+
+- `LDAP_DOMAIN` sets the LDAP root domain. (e.g. if you provide `foo.bar.com`
+  here, the root of your directory will be `dc=foo,dc=bar,dc=com`)
+- `LDAP_ORGANISATION` sets the human-readable name for your organisation (e.g.
+  `Acme Widgets Inc.`)
+- `LDAP_ROOTPASS` sets the LDAP admin user password (i.e. the password for
+  `cn=admin,dc=example,dc=com` if your domain was `example.com`)
+
+For example, to start a container running slapd for the `mycorp.com` domain,
+with data stored in `/data/ldap` on the host, use the following:
+
+    docker run -v /data/ldap:/var/lib/ldap \
+               -e LDAP_DOMAIN=mycorp.com \
+               -e LDAP_ORGANISATION="My Mega Corporation" \
+               -e LDAP_ROOTPASS=s3cr3tpassw0rd \
+               -d nickstenning/slapd
+
+You can find out which port the LDAP server is bound to on the host by running
+`docker ps` (or `docker port <container_id> 389`). You could then load an LDIF
+file (to set up your directory) like so:
+
+    ldapadd -h localhost -p <host_port> -c -x -D cn=admin,dc=mycorp,dc=com -W -f
+data.ldif
+
+**NB**: Please be aware that by default docker will make the LDAP port
+accessible from anywhere if the host firewall is unconfigured.
+
+
diff --git a/pica-slapd/docker-compose.yml b/pica-slapd/docker-compose.yml
new file mode 100644
index 00000000..1bf6dbae
--- /dev/null
+++ b/pica-slapd/docker-compose.yml
@@ -0,0 +1,9 @@
+slapd:
+    image: nickstenning/slapd
+    volumes:
+      - /DATA/volumes/ldap/var_lib_ldap:/var/lib/ldap
+      - /DATA/volumes/ldap/etc_ldap_slapdd:/etc/ldap/slapd.d
+    environment:
+      - LDAP_DOMAIN=picasoft.net
+      - LDAP_ORGANISATION="Picasoft"
+      - LDAP_ROOTPASS=iMGr97fD4kz
diff --git a/pica-slapd/slapd.sh b/pica-slapd/slapd.sh
new file mode 100644
index 00000000..cb756568
--- /dev/null
+++ b/pica-slapd/slapd.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+set -eu
+
+status () {
+  echo "---> ${@}" >&2
+}
+
+set -x
+: LDAP_ROOTPASS=${LDAP_ROOTPASS}
+: LDAP_DOMAIN=${LDAP_DOMAIN}
+: LDAP_ORGANISATION=${LDAP_ORGANISATION}
+
+if [ ! -e /var/lib/ldap/docker_bootstrapped ]; then
+  status "configuring slapd for first run"
+
+  cat <<EOF | debconf-set-selections
+slapd slapd/internal/generated_adminpw password ${LDAP_ROOTPASS}
+slapd slapd/internal/adminpw password ${LDAP_ROOTPASS}
+slapd slapd/password2 password ${LDAP_ROOTPASS}
+slapd slapd/password1 password ${LDAP_ROOTPASS}
+slapd slapd/dump_database_destdir string /var/backups/slapd-VERSION
+slapd slapd/domain string ${LDAP_DOMAIN}
+slapd shared/organization string ${LDAP_ORGANISATION}
+slapd slapd/backend string HDB
+slapd slapd/purge_database boolean true
+slapd slapd/move_old_database boolean true
+slapd slapd/allow_ldap_v2 boolean false
+slapd slapd/no_configuration boolean false
+slapd slapd/dump_database select when needed
+EOF
+
+  dpkg-reconfigure -f noninteractive slapd
+
+  touch /var/lib/ldap/docker_bootstrapped
+else
+  status "found already-configured slapd"
+fi
+
+status "starting slapd"
+set -x
+exec /usr/sbin/slapd -h "ldap:///" -u openldap -g openldap -d 0
diff --git a/tx-etherpad/Dockerfile b/tx-etherpad/Dockerfile
index f602e42e..0a447ebd 100644
--- a/tx-etherpad/Dockerfile
+++ b/tx-etherpad/Dockerfile
@@ -20,6 +20,11 @@ WORKDIR etherpad-lite
 RUN bin/installDeps.sh && rm settings.json
 RUN ln -s var/settings.json settings.json
 
+# Installation modules Etherpad
+RUN npm install ep_align && npm install ep_author_hover && npm install ep_comments_page && npm install ep_countable && \
+    npm install ep_delete_empty_pads && npm install ep_font_color && npm install ep_headings2 && npm install ep_markdown && \
+    npm install ep_page_view && npm install ep_spellcheck && npm install ep_subscript_and_superscript && npm install ep_table_of_contents && npm install ep_user_font_size
+
 #Copy configuration
 COPY add/entrypoint.sh /entrypoint.sh
 COPY add/supervisord.conf /etc/supervisord.conf
-- 
GitLab