From 44b2b38dc2d3f99806c23ea529d0eec3f6c52ec9 Mon Sep 17 00:00:00 2001 From: Egor Matveev Date: Wed, 2 Mar 2022 20:44:50 +0300 Subject: [PATCH] infra --- .gitlab-ci.yml | 3 +- ...compose.yaml => docker-compose-deploy.yaml | 62 +++++-------------- docker-compose-infra.yaml | 36 +++++++++++ 3 files changed, 54 insertions(+), 47 deletions(-) rename docker-compose.yaml => docker-compose-deploy.yaml (60%) create mode 100644 docker-compose-infra.yaml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 994c176..a295ead 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,7 +22,8 @@ build: # - docker image rm mathwave/sprint-repo:sprint # - docker pull mathwave/sprint-repo:sprint script: - - docker-compose up -d --scale worker=4 + - docker-compose up -d -f docker-compose-infra.yaml + - docker stack deploy -c ./docker-compose-deploy.yaml sprint deploy-dev: extends: diff --git a/docker-compose.yaml b/docker-compose-deploy.yaml similarity index 60% rename from docker-compose.yaml rename to docker-compose-deploy.yaml index 0f51666..59f8f9c 100644 --- a/docker-compose.yaml +++ b/docker-compose-deploy.yaml @@ -1,27 +1,13 @@ -version: "3" +version: "3.2" 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" - migrations: image: mathwave/sprint-repo:sprint command: ./manage.py migrate - depends_on: - - postgres + deploy: + mode: replicated web: image: mathwave/sprint-repo:sprint @@ -33,19 +19,8 @@ services: command: ./manage.py runserver 0.0.0.0:$PORT --noreload ports: - "${PORT}:${PORT}" - depends_on: - - migrations - - rabbitmq - - storage - - 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 bot: image: mathwave/sprint-repo:sprint @@ -55,6 +30,8 @@ services: command: ./manage.py bot depends_on: - web + deploy: + mode: replicated loop: image: mathwave/sprint-repo:sprint @@ -64,15 +41,8 @@ services: command: ./manage.py loop depends_on: - web - - rabbitmq: - restart: always - build: - context: . - dockerfile: dockerfiles/rabbitmq/Dockerfile - ports: - - "15672:15672" - - "5672:5672" + deploy: + mode: replicated worker: restart: always @@ -84,20 +54,21 @@ services: HOST: $HOST depends_on: - web - - rabbitmq - migrations - - storage volumes: - /sprint-data/solutions:/usr/src/app/solutions - /var/run/docker.sock:/var/run/docker.sock + deploy: + mode: replicated + replicas: 4 apply-languages: image: mathwave/sprint-repo:sprint command: ./manage.py apply_languages depends_on: - migrations - - web - - postgres + deploy: + mode: replicated notify-admin: image: mathwave/sprint-repo:sprint @@ -106,9 +77,8 @@ services: - migrations - web - worker - - storage - - rabbitmq - bot - - postgres - apply-languages - loop + deploy: + mode: replicated diff --git a/docker-compose-infra.yaml b/docker-compose-infra.yaml new file mode 100644 index 0000000..a89d10b --- /dev/null +++ b/docker-compose-infra.yaml @@ -0,0 +1,36 @@ +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" + + storage: + restart: always + image: mathwave/sprint-repo:sprint + command: ./manage.py storage + ports: + - "5555:5555" + volumes: + - /sprint-data/data:/usr/src/app/data + + rabbitmq: + restart: always + build: + context: . + dockerfile: dockerfiles/rabbitmq/Dockerfile + ports: + - "15672:15672" + - "5672:5672"