From c3fc917b45f223f4769ca16f7cfab906ff43d639 Mon Sep 17 00:00:00 2001
From: mancini <mancini@astron.nl>
Date: Thu, 11 Aug 2022 11:40:09 +0200
Subject: [PATCH] Refactor docker-compose to use background workers

---
 .../docker/docker-compose-production-cd.yml   | 32 +++++++++++++++----
 1 file changed, 26 insertions(+), 6 deletions(-)

diff --git a/ldvspec/docker/docker-compose-production-cd.yml b/ldvspec/docker/docker-compose-production-cd.yml
index b03a4d5e..3d737ceb 100644
--- a/ldvspec/docker/docker-compose-production-cd.yml
+++ b/ldvspec/docker/docker-compose-production-cd.yml
@@ -25,12 +25,33 @@ services:
       - ldv-spec-db:/var/lib/postgresql/data
     restart: always
 
+  rabbitmq:
+    image: rabbitmq:3-management
+    networks:
+      - ldv_network
+    container_name: ldv-spec-rabbit
+
+  ldv-specification-background:
+    container_name: ldv-specification-background
+    image: git.astron.nl:5000/astron-sdc/ldv-specification:${LDVSPEC_VERSION:-latest}
+    networks:
+      - ldv_network
+    depends_on:
+      - ldv-spec-db
+    environment:
+      CELERY_BROKER_URL: amqp://guest@rabbitmq:5672
+      DJANGO_SETTINGS_MODULE: 'ldvspec.settings.docker_sdc'
+    env_file:
+      - $HOME/shared/ldvspec.env
+    command: celery -A ldvspec worker -l INFO
+    restart: always
+
   ldv-specification:
     container_name: ldv-specification
-    image: git.astron.nl:5000/astron-sdc/ldv-specification:latest
+    image: git.astron.nl:5000/astron-sdc/ldv-specification:${LDVSPEC_VERSION:-latest}
 
-    expose:
-      - "8000"
+    ports:
+      - "8000:8000"
     networks:
       - traefik_proxy
       - ldv_network
@@ -43,11 +64,10 @@ services:
 
     depends_on:
       - ldv-spec-db
+    environment:
+      CELERY_BROKER_URL: amqp://guest@rabbitmq:5672
     env_file:
     - $HOME/shared/ldvspec.env
-#    command: >
-#      sh -c "python manage.py collectstatic --settings=ldvspec.settings.docker_sdc --noinput &&
-#             python manage.py migrate --settings=ldvspec.settings.docker_sdc"
     restart: always
 
 volumes:
-- 
GitLab