From c6ecaa6c31301c29bcaefdf3cc4c5611b9f753d5 Mon Sep 17 00:00:00 2001 From: emmatveev Date: Sat, 12 Oct 2024 15:36:47 +0300 Subject: [PATCH 1/4] add --- .deploy-infra/deploy-dev.yaml | 20 +---------- .deploy-infra/deploy-prod.yaml | 20 +---------- .gitea/workflows/deploy-dev.yaml | 56 +++++++++++++++++++++++++++++++ .gitea/workflows/deploy-prod.yaml | 56 +++++++++++++++++++++++++++++++ 4 files changed, 114 insertions(+), 38 deletions(-) create mode 100644 .gitea/workflows/deploy-dev.yaml create mode 100644 .gitea/workflows/deploy-prod.yaml diff --git a/.deploy-infra/deploy-dev.yaml b/.deploy-infra/deploy-dev.yaml index 34a3d7c..7b7fed0 100644 --- a/.deploy-infra/deploy-dev.yaml +++ b/.deploy-infra/deploy-dev.yaml @@ -99,24 +99,6 @@ services: parallelism: 1 order: start-first - gitlab-runner: - image: mathwave/sprint-repo:gitlab-runner - volumes: - - /var/run/docker.sock:/var/run/docker.sock - - /sprint-data/gitlab:/etc/gitlab-runner - - /sprint-data:/sprint-data - environment: - GITLAB_REGISTRATION_TOKEN: $GITLAB_REGISTRATION_TOKEN - deploy: - mode: replicated - placement: - constraints: [node.role == manager] - restart_policy: - condition: any - update_config: - parallelism: 1 - order: start-first - minio: image: bitnami/minio:2022.10.8 volumes: @@ -144,7 +126,7 @@ services: - /sprint-data:/sprint-data environment: GITEA_INSTANCE_URL: https://gitea.sprinthub.ru/ - GITEA_RUNNER_REGISTRATION_TOKEN: $REGISTRATION_TOKEN_DEV + GITEA_RUNNER_REGISTRATION_TOKEN: $REGISTRATION_TOKEN GITEA_RUNNER_NAME: dev GITEA_RUNNER_LABELS: dev deploy: diff --git a/.deploy-infra/deploy-prod.yaml b/.deploy-infra/deploy-prod.yaml index f86eb06..0898066 100644 --- a/.deploy-infra/deploy-prod.yaml +++ b/.deploy-infra/deploy-prod.yaml @@ -104,24 +104,6 @@ services: parallelism: 1 order: start-first - gitlab-runner: - image: mathwave/sprint-repo:gitlab-runner - volumes: - - /var/run/docker.sock:/var/run/docker.sock - - /sprint-data/gitlab:/etc/gitlab-runner - - /sprint-data:/sprint-data - environment: - GITLAB_REGISTRATION_TOKEN: $GITLAB_REGISTRATION_TOKEN - deploy: - mode: replicated - placement: - constraints: [node.role == manager] - restart_policy: - condition: any - update_config: - parallelism: 1 - order: start-first - minio: image: bitnami/minio:2022.10.8 volumes: @@ -176,7 +158,7 @@ services: - /sprint-data:/sprint-data environment: GITEA_INSTANCE_URL: https://gitea.sprinthub.ru/ - GITEA_RUNNER_REGISTRATION_TOKEN: $REGISTRATION_TOKEN_PROD + GITEA_RUNNER_REGISTRATION_TOKEN: $REGISTRATION_TOKEN GITEA_RUNNER_NAME: prod GITEA_RUNNER_LABELS: prod deploy: diff --git a/.gitea/workflows/deploy-dev.yaml b/.gitea/workflows/deploy-dev.yaml new file mode 100644 index 0000000..1987cfb --- /dev/null +++ b/.gitea/workflows/deploy-dev.yaml @@ -0,0 +1,56 @@ +name: Deploy Dev + +on: + pull_request: + branches: + - dev + types: [closed] + +jobs: + build: + name: Build + runs-on: [ dev ] + steps: + - name: login + run: docker login -u mathwave -p ${{ secrets.DOCKERHUB_PASSWORD }} + - name: checkout + uses: actions/checkout@v4 + with: + ref: dev + - name: build nginx dev + run: docker build -t mathwave/sprint-repo:sprint-infra-nginx-dev nginx/nginx-dev + - name: build gitea runner + run: docker build -t mathwave/sprint-repo:gitea-runner gitea-runner + push: + name: Push + runs-on: [ dev ] + needs: build + steps: + - name: push nginx dev + run: docker push mathwave/sprint-repo:sprint-infra-nginx-dev + - name: push gitea runner + run: docker push mathwave/sprint-repo:gitea-runner + deploy-dev: + name: Deploy dev + runs-on: [dev] + needs: push + steps: + - name: login + run: docker login -u mathwave -p ${{ secrets.DOCKERHUB_PASSWORD }} + - name: checkout + uses: actions/checkout@v4 + with: + ref: dev + - name: deploy swarmpit + run: docker stack deploy --with-registry-auth -c ./.deploy-swarmpit/deploy-dev.yaml swarmpit + - name: deploy portainer + run: docker stack deploy --with-registry-auth -c ./.deploy-portainer/deploy-dev.yaml portainer + - name: deploy infra + env: + MONGO_PASSWORD_DEV: ${{ secret.MONGO_PASSWORD_DEV }} + DB_PASSWORD_DEV: ${{ secrets.POSTGRES_PASSWORD_DEV }} + MINIO_PASSWORD_DEV: ${{ secrets.MINIO_PASSWORD_DEV }} + REDIS_PASSWORD: ${{ secrets.REDIS_PASSWORD_DEV }} + RABBITMQ_PASSWORD: ${{ secrets.RABBITMQ_PASSWORD_DEV }} + REGISTRATION_TOKEN: ${{ secrets.REGISTRATION_TOKEN }} + run: docker stack deploy --with-registry-auth -c ./.deploy-infra/deploy-dev.yaml infra diff --git a/.gitea/workflows/deploy-prod.yaml b/.gitea/workflows/deploy-prod.yaml new file mode 100644 index 0000000..6ae83b8 --- /dev/null +++ b/.gitea/workflows/deploy-prod.yaml @@ -0,0 +1,56 @@ +name: Deploy Prod + +on: + pull_request: + branches: + - prod + types: [closed] + +jobs: + build: + name: Build + runs-on: [ dev ] + steps: + - name: login + run: docker login -u mathwave -p ${{ secrets.DOCKERHUB_PASSWORD }} + - name: checkout + uses: actions/checkout@v4 + with: + ref: dev + - name: build nginx prod + run: docker build -t mathwave/sprint-repo:sprint-infra-nginx-prod nginx/nginx-prod + - name: build gitea runner + run: docker build -t mathwave/sprint-repo:gitea-runner gitea-runner + push: + name: Push + runs-on: [ dev ] + needs: build + steps: + - name: push nginx prod + run: docker push mathwave/sprint-repo:sprint-infra-nginx-prod + - name: push gitea runner + run: docker push mathwave/sprint-repo:gitea-runner + deploy-prod: + name: Deploy prod + runs-on: [prod] + needs: push + steps: + - name: login + run: docker login -u mathwave -p ${{ secrets.DOCKERHUB_PASSWORD }} + - name: checkout + uses: actions/checkout@v4 + with: + ref: prod + - name: deploy swarmpit + run: docker stack deploy --with-registry-auth -c ./.deploy-swarmpit/deploy-prod.yaml swarmpit + - name: deploy portainer + run: docker stack deploy --with-registry-auth -c ./.deploy-portainer/deploy-prod.yaml portainer + - name: deploy infra + env: + MONGO_PASSWORD_DEV: ${{ secret.MONGO_PASSWORD_PROD }} + DB_PASSWORD_DEV: ${{ secrets.POSTGRES_PASSWORD_PROD }} + MINIO_PASSWORD_DEV: ${{ secrets.MINIO_PASSWORD_PROD }} + REDIS_PASSWORD: ${{ secrets.REDIS_PASSWORD_PROD }} + RABBITMQ_PASSWORD: ${{ secrets.RABBITMQ_PASSWORD_PROD }} + REGISTRATION_TOKEN: ${{ secrets.REGISTRATION_TOKEN }} + run: docker stack deploy --with-registry-auth -c ./.deploy-infra/deploy-prod.yaml infra From 22e10ec5e9e2d7edc99c9f054ff8b4c894efeb90 Mon Sep 17 00:00:00 2001 From: emmatveev Date: Sat, 12 Oct 2024 15:41:01 +0300 Subject: [PATCH 2/4] fix --- .gitea/workflows/deploy-dev.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/deploy-dev.yaml b/.gitea/workflows/deploy-dev.yaml index 1987cfb..15cc4a6 100644 --- a/.gitea/workflows/deploy-dev.yaml +++ b/.gitea/workflows/deploy-dev.yaml @@ -47,7 +47,7 @@ jobs: run: docker stack deploy --with-registry-auth -c ./.deploy-portainer/deploy-dev.yaml portainer - name: deploy infra env: - MONGO_PASSWORD_DEV: ${{ secret.MONGO_PASSWORD_DEV }} + MONGO_PASSWORD_DEV: ${{ secrets.MONGO_PASSWORD_DEV }} DB_PASSWORD_DEV: ${{ secrets.POSTGRES_PASSWORD_DEV }} MINIO_PASSWORD_DEV: ${{ secrets.MINIO_PASSWORD_DEV }} REDIS_PASSWORD: ${{ secrets.REDIS_PASSWORD_DEV }} From 524b22b912a706925be3db0a247da16f70c707db Mon Sep 17 00:00:00 2001 From: emmatveev Date: Sat, 12 Oct 2024 15:43:24 +0300 Subject: [PATCH 3/4] fix --- .gitea/workflows/deploy-dev.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/deploy-dev.yaml b/.gitea/workflows/deploy-dev.yaml index 15cc4a6..b9ec092 100644 --- a/.gitea/workflows/deploy-dev.yaml +++ b/.gitea/workflows/deploy-dev.yaml @@ -50,7 +50,7 @@ jobs: MONGO_PASSWORD_DEV: ${{ secrets.MONGO_PASSWORD_DEV }} DB_PASSWORD_DEV: ${{ secrets.POSTGRES_PASSWORD_DEV }} MINIO_PASSWORD_DEV: ${{ secrets.MINIO_PASSWORD_DEV }} - REDIS_PASSWORD: ${{ secrets.REDIS_PASSWORD_DEV }} + REDIS_PASSWORD_DEV: ${{ secrets.REDIS_PASSWORD_DEV }} RABBITMQ_PASSWORD: ${{ secrets.RABBITMQ_PASSWORD_DEV }} REGISTRATION_TOKEN: ${{ secrets.REGISTRATION_TOKEN }} run: docker stack deploy --with-registry-auth -c ./.deploy-infra/deploy-dev.yaml infra From 803b25749bb9f8033ad3c86d8533c11fb6d1542a Mon Sep 17 00:00:00 2001 From: emmatveev Date: Sat, 12 Oct 2024 15:46:26 +0300 Subject: [PATCH 4/4] fix --- .gitea/workflows/deploy-dev.yaml | 2 +- .gitea/workflows/deploy-prod.yaml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/deploy-dev.yaml b/.gitea/workflows/deploy-dev.yaml index b9ec092..627017b 100644 --- a/.gitea/workflows/deploy-dev.yaml +++ b/.gitea/workflows/deploy-dev.yaml @@ -51,6 +51,6 @@ jobs: DB_PASSWORD_DEV: ${{ secrets.POSTGRES_PASSWORD_DEV }} MINIO_PASSWORD_DEV: ${{ secrets.MINIO_PASSWORD_DEV }} REDIS_PASSWORD_DEV: ${{ secrets.REDIS_PASSWORD_DEV }} - RABBITMQ_PASSWORD: ${{ secrets.RABBITMQ_PASSWORD_DEV }} + RABBITMQ_PASSWORD_DEV: ${{ secrets.RABBITMQ_PASSWORD_DEV }} REGISTRATION_TOKEN: ${{ secrets.REGISTRATION_TOKEN }} run: docker stack deploy --with-registry-auth -c ./.deploy-infra/deploy-dev.yaml infra diff --git a/.gitea/workflows/deploy-prod.yaml b/.gitea/workflows/deploy-prod.yaml index 6ae83b8..12f4022 100644 --- a/.gitea/workflows/deploy-prod.yaml +++ b/.gitea/workflows/deploy-prod.yaml @@ -47,10 +47,10 @@ jobs: run: docker stack deploy --with-registry-auth -c ./.deploy-portainer/deploy-prod.yaml portainer - name: deploy infra env: - MONGO_PASSWORD_DEV: ${{ secret.MONGO_PASSWORD_PROD }} - DB_PASSWORD_DEV: ${{ secrets.POSTGRES_PASSWORD_PROD }} - MINIO_PASSWORD_DEV: ${{ secrets.MINIO_PASSWORD_PROD }} - REDIS_PASSWORD: ${{ secrets.REDIS_PASSWORD_PROD }} - RABBITMQ_PASSWORD: ${{ secrets.RABBITMQ_PASSWORD_PROD }} + MONGO_PASSWORD_PROD: ${{ secrets.MONGO_PASSWORD_PROD }} + DB_PASSWORD_PROD: ${{ secrets.POSTGRES_PASSWORD_PROD }} + MINIO_PASSWORD_PROD: ${{ secrets.MINIO_PASSWORD_PROD }} + REDIS_PASSWORD_PROD: ${{ secrets.REDIS_PASSWORD_PROD }} + RABBITMQ_PASSWORD_PROD: ${{ secrets.RABBITMQ_PASSWORD_PROD }} REGISTRATION_TOKEN: ${{ secrets.REGISTRATION_TOKEN }} run: docker stack deploy --with-registry-auth -c ./.deploy-infra/deploy-prod.yaml infra