From ac0774d7f7ff4bad7c95f26ea3da10e9d58b3f5a Mon Sep 17 00:00:00 2001 From: Marcin Kozlowski Date: Fri, 13 Sep 2024 10:35:09 +0200 Subject: [PATCH] Update docker-compose.yml --- dockerhub/docker-compose.yml | 58 +++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/dockerhub/docker-compose.yml b/dockerhub/docker-compose.yml index fce3183a..df909bae 100644 --- a/dockerhub/docker-compose.yml +++ b/dockerhub/docker-compose.yml @@ -1,22 +1,27 @@ +version: '3.8' + services: server: image: sunsolution/betterscan-server:latest restart: always environment: - OPENAI_GPT_API: + OPENAI_GPT_API: ${OPENAI_GPT_API} depends_on: - - postgres + postgres: + condition: service_healthy working_dir: /srv/betterscan/ entrypoint: sh - command: -c "mkdir -p data1/repositories data2/tasks setup_state && if [ -f /srv/betterscan/setup_state/setup_done ]; then python /srv/betterscan/manage.py runserver; else python /srv/betterscan/manage.py setup && touch /srv/betterscan/setup_state/setup_done; fi" + command: -c "mkdir -p data1/repositories data2/tasks setup_state && \ + if [ -f /srv/betterscan/setup_state/setup_done ]; \ + then python /srv/betterscan/manage.py runserver; \ + else python /srv/betterscan/manage.py setup && touch /srv/betterscan/setup_state/setup_done; \ + fi" ports: - 5001:5000 volumes: - - ./data1:/srv/betterscan/quantifiedcode/data/ - - ./data2:/srv/betterscan/quantifiedcode/backend/data/tasks - - ./setup_state:/srv/betterscan/setup_state - links: - - "postgres" + - data1:/srv/betterscan/quantifiedcode/data/ + - data2:/srv/betterscan/quantifiedcode/backend/data/tasks + - setup_state:/srv/betterscan/setup_state postgres: image: postgres:13.2 @@ -30,40 +35,45 @@ services: - "5432:5432" volumes: - db-data:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U qc"] + interval: 10s + timeout: 5s + retries: 5 + worker_1: image: sunsolution/betterscan-worker:latest ulimits: stack: -1 restart: always environment: - OPENAI_GPT_API: + OPENAI_GPT_API: ${OPENAI_GPT_API} hostname: worker_1 depends_on: - - rabbitmq3 - - postgres - - server + rabbitmq3: + condition: service_healthy + postgres: + condition: service_healthy + server: + condition: service_healthy working_dir: /srv/betterscan/ entrypoint: sh command: -c "python /srv/betterscan/manage.py runworker" volumes: - - ./data1:/srv/betterscan/quantifiedcode/data/ - - ./data2:/srv/betterscan/quantifiedcode/backend/data/tasks - links: - - "rabbitmq3" - - "server" - - "postgres" + - data1:/srv/betterscan/quantifiedcode/data/ + - data2:/srv/betterscan/quantifiedcode/backend/data/tasks rabbitmq3: container_name: "rabbitmq" image: rabbitmq:3.8-management-alpine environment: - - RABBITMQ_DEFAULT_USER=qc - - RABBITMQ_DEFAULT_PASS=qc + RABBITMQ_DEFAULT_USER: qc + RABBITMQ_DEFAULT_PASS: qc ports: - 5672:5672 - 15672:15672 healthcheck: - test: [ "CMD", "nc", "-z", "localhost", "5672" ] + test: ["CMD", "nc", "-z", "localhost", "5672"] interval: 5s timeout: 15s retries: 1 @@ -71,3 +81,9 @@ services: volumes: db-data: driver: local + data1: + driver: local + data2: + driver: local + setup_state: + driver: local