From 592da38946e2a4d898bbc651755321253991202a Mon Sep 17 00:00:00 2001
From: Patrick Jentsch <p.jentsch@uni-bielefeld.de>
Date: Fri, 6 Dec 2019 10:29:38 +0100
Subject: [PATCH] add docker compose file for traefik

---
 docker-compose.yml         | 18 +----------
 docker-compose_traefik.yml | 66 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 67 insertions(+), 17 deletions(-)
 create mode 100644 docker-compose_traefik.yml

diff --git a/docker-compose.yml b/docker-compose.yml
index aecc11ba..abe066c9 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,25 +1,9 @@
 version: '3'
 
 services:
-  traefik:
-    command:
-      - "--api.insecure=true"
-      - "--providers.docker=true"
-      - "--providers.docker.exposedbydefault=false"
-      - "--entrypoints.nopaque.address=:5000"
-    image: traefik:2.0
-    ports:
-      - 5000:5000
-      - 9090:8080
-    volumes:
-      - /var/run/docker.sock:/var/run/docker.sock:ro
   web:
     ports:
-      - "5000"
-    labels:
-      - "traefik.enable=true"
-      - "traefik.http.routers.nopaque.entrypoints=nopaque"
-      - "traefik.http.routers.nopaque.rule=Host(`nopaque.localhost`)"
+      - "5000:5000"
     depends_on:
       - db
       - redis
diff --git a/docker-compose_traefik.yml b/docker-compose_traefik.yml
new file mode 100644
index 00000000..f234f92d
--- /dev/null
+++ b/docker-compose_traefik.yml
@@ -0,0 +1,66 @@
+version: '3'
+
+services:
+  traefik:
+    command:
+      - "--api.insecure=true"
+      - "--providers.docker=true"
+      - "--providers.docker.exposedbydefault=false"
+      - "--entrypoints.nopaque.address=:5000"
+    image: traefik:2.0
+    ports:
+      - 5000:5000
+      - 9090:8080
+    volumes:
+      - /var/run/docker.sock:/var/run/docker.sock:ro
+  web:
+    ports:
+      - "5000"
+    labels:
+      - "traefik.enable=true"
+      - "traefik.http.routers.nopaque.entrypoints=nopaque"
+      - "traefik.http.routers.nopaque.rule=Host(`nopaque.localhost`)"
+      # Use sticky sessions for load balancing
+      # Socket.IO is not compatible with cookie sticky sessions which are the
+      # only available option in traefik
+      - "traefik.http.services.web-opaque.loadbalancer.sticky=true"
+      - "traefik.http.services.web-opaque.loadbalancer.sticky.cookie.httpOnly=true"
+    depends_on:
+      - db
+      - redis
+    env_file:
+      - db.env
+      - web.env
+    image: gitlab.ub.uni-bielefeld.de:4567/sfb1288inf/opaque:development
+    volumes:
+      - /mnt/nopaque:/mnt/nopaque
+      - ./app:/home/nopaque/app
+      - ./logs:/home/nopaque/logs
+      - ./migrations:/home/nopaque/migrations
+      - ./tests:/home/nopaque/tests
+      - ./config.py:/home/nopaque/config.py
+      - ./docker-entrypoint.sh:/usr/local/bin/docker-entrypoint.sh
+      - ./nopaque.py:/home/nopaque/nopaque.py
+      - ./requirements.txt:/home/nopaque/requirements.txt
+  daemon:
+    depends_on:
+      - db
+    env_file:
+      - db.env
+      - web.env
+    image: gitlab.ub.uni-bielefeld.de:4567/sfb1288inf/opaque_daemon:latest
+    volumes:
+      - /mnt/nopaque:/mnt/nopaque
+      - ./logs:/home/nopaqued/logs
+      - ../opaque_daemon/docker-entrypoint.sh:/usr/local/bin/docker-entrypoint.sh
+      - ../opaque_daemon/nopaqued.py:/home/nopaqued/nopaqued.py
+      - ../opaque_daemon/merge_corpus_files.py:/home/nopaqued/merge_corpus_files.py
+      - ../opaque_daemon/requirements.txt:/home/nopaqued/requirements.txt
+      - $HOME/.docker:/home/nopaqued/.docker
+  db:
+    env_file: db.env
+    image: postgres:11
+    volumes:
+      - /srv/nopaque/database:/var/lib/postgresql/data
+  redis:
+    image: redis:5
-- 
GitLab