diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5587a1d..76ec494 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,9 +22,9 @@ build: # - docker image rm mathwave/sprint-repo:sprint # - docker pull mathwave/sprint-repo:sprint script: - - docker-compose up -d +# - docker-compose up -d # - docker-compose -f docker-compose-infra.yaml up -d -# - docker stack deploy -c ./docker-compose-deploy.yaml sprint + - docker stack deploy -c ./docker-compose-deploy.yaml sprint deploy-dev: extends: diff --git a/docker-compose-deploy.yaml b/docker-compose-deploy.yaml index 2579796..ba30f9a 100644 --- a/docker-compose-deploy.yaml +++ b/docker-compose-deploy.yaml @@ -1,11 +1,31 @@ -version: "3.2" +version: "3" services: + postgres: + restart: always + build: + context: . + dockerfile: dockerfiles/postgres/Dockerfile + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: $POSTGRES_PASSWORD + POSTGRES_DB: sprint + volumes: + - /sprint-data/postgres-data:/var/lib/postgresql/data + ports: + - "5432:5432" + deploy: + mode: replicated + restart_policy: + condition: on-failure + migrations: image: mathwave/sprint-repo:sprint command: ./manage.py migrate + depends_on: + - postgres deploy: mode: replicated restart_policy: @@ -13,13 +33,31 @@ services: web: image: mathwave/sprint-repo:sprint + restart: always environment: - PORT: 80 + PORT: $PORT HOST: $HOST debug: "false" - command: ./manage.py runserver 0.0.0.0:80 --noreload + command: ./manage.py runserver 0.0.0.0:$PORT --noreload ports: - - "80:80" + - "${PORT}:${PORT}" + depends_on: + - migrations + - rabbitmq + - storage + deploy: + mode: replicated + restart_policy: + condition: on-failure + + storage: + restart: always + image: mathwave/sprint-repo:sprint + command: ./manage.py storage + ports: + - "5555:5555" + volumes: + - /sprint-data/data:/usr/src/app/data deploy: mode: replicated restart_policy: @@ -27,6 +65,7 @@ services: bot: image: mathwave/sprint-repo:sprint + restart: always environment: HOST: $HOST command: ./manage.py bot @@ -39,6 +78,7 @@ services: loop: image: mathwave/sprint-repo:sprint + restart: always environment: HOST: $HOST command: ./manage.py loop @@ -49,15 +89,32 @@ services: restart_policy: condition: on-failure + rabbitmq: + restart: always + build: + context: . + dockerfile: dockerfiles/rabbitmq/Dockerfile + ports: + - "15672:15672" + - "5672:5672" + deploy: + mode: replicated + restart_policy: + condition: on-failure + worker: + restart: always image: mathwave/sprint-repo:sprint + privileged: true command: ./manage.py receive environment: SOLUTIONS_ROOT_EXTERNAL: "${SOLUTIONS_ROOT_EXTERNAL}" HOST: $HOST depends_on: - web + - rabbitmq - migrations + - storage volumes: - /sprint-data/solutions:/usr/src/app/solutions - /var/run/docker.sock:/var/run/docker.sock @@ -72,6 +129,8 @@ services: command: ./manage.py apply_languages depends_on: - migrations + - web + - postgres deploy: mode: replicated restart_policy: @@ -84,7 +143,10 @@ services: - migrations - web - worker + - storage + - rabbitmq - bot + - postgres - apply-languages - loop deploy: