From 039c13b7d4009f45cd42c351ebd20e517c585efe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9E=D0=BB=D0=B5=D0=B3=20=D0=93=D0=BE=D0=B2=D0=BE=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D1=81=D0=BA=D0=B8=D0=B9?= Date: Thu, 3 Oct 2024 18:53:46 +0500 Subject: [PATCH 1/3] update import import-db.py, export-db.py, docker-compose.prod.yaml --- .gitignore | 2 ++ .../core/management/commands/export-db.py | 2 +- adaptive_hockey_federation/core/management/commands/fill-db.py | 2 +- .../core/management/commands/import-db.py | 2 +- infra/prod/docker-compose.prod.yaml | 1 + 5 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 944c5d95..5a6c1fcd 100644 --- a/.gitignore +++ b/.gitignore @@ -184,3 +184,5 @@ media/ # DS server a_hockey-main/ adaptive_hockey_federation/service/test_video/ + +db_dump.json \ No newline at end of file diff --git a/adaptive_hockey_federation/core/management/commands/export-db.py b/adaptive_hockey_federation/core/management/commands/export-db.py index f4b88dba..bb7cb2e0 100644 --- a/adaptive_hockey_federation/core/management/commands/export-db.py +++ b/adaptive_hockey_federation/core/management/commands/export-db.py @@ -1,7 +1,7 @@ from django.core.management import call_command from django.core.management.base import BaseCommand -from adaptive_hockey_federation.core.config.dev_settings import DB_DUMP_FILE +from core.config.dev_settings import DB_DUMP_FILE class Command(BaseCommand): diff --git a/adaptive_hockey_federation/core/management/commands/fill-db.py b/adaptive_hockey_federation/core/management/commands/fill-db.py index b5ba070b..db2578b2 100644 --- a/adaptive_hockey_federation/core/management/commands/fill-db.py +++ b/adaptive_hockey_federation/core/management/commands/fill-db.py @@ -5,7 +5,7 @@ from django.db import connection, transaction from main.models import Diagnosis -from adaptive_hockey_federation.core.config.dev_settings import ( +from core.config.dev_settings import ( FILE_MODEL_MAP, FIXSTURES_DIR, ) diff --git a/adaptive_hockey_federation/core/management/commands/import-db.py b/adaptive_hockey_federation/core/management/commands/import-db.py index bff63edf..5f39118a 100644 --- a/adaptive_hockey_federation/core/management/commands/import-db.py +++ b/adaptive_hockey_federation/core/management/commands/import-db.py @@ -6,7 +6,7 @@ from django.core.management.base import BaseCommand from django.db import connection -from adaptive_hockey_federation.core.config.dev_settings import DB_DUMP_FILE +from core.config.dev_settings import DB_DUMP_FILE class Command(BaseCommand): diff --git a/infra/prod/docker-compose.prod.yaml b/infra/prod/docker-compose.prod.yaml index 9e978a92..2a2801ba 100644 --- a/infra/prod/docker-compose.prod.yaml +++ b/infra/prod/docker-compose.prod.yaml @@ -20,6 +20,7 @@ services: volumes: - static_value:/app/adaptive_hockey_federation/static/ - ../../media:/app/adaptive_hockey_federation/media/ + - ../../fixtures:/app/adaptive_hockey_federation/core/fixtures/ env_file: - ../../.env depends_on: From 288fcddc3bd9f2c4845c5c85de8bd0abe41c1948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9E=D0=BB=D0=B5=D0=B3=20=D0=93=D0=BE=D0=B2=D0=BE=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D1=81=D0=BA=D0=B8=D0=B9?= Date: Thu, 3 Oct 2024 21:05:06 +0500 Subject: [PATCH 2/3] fix deploy --- .github/workflows/prod_deploy.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/prod_deploy.yaml b/.github/workflows/prod_deploy.yaml index 3f8fab04..790c3b85 100644 --- a/.github/workflows/prod_deploy.yaml +++ b/.github/workflows/prod_deploy.yaml @@ -87,6 +87,19 @@ jobs: rm -r infra/stage rm -r infra/dev + - name: Stopping old containers + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + key: ${{ secrets.SSH_PRIVATE_KEY }} + passphrase: ${{ secrets.SSH_PASSPHRASE }} + script: | + if [ -d /home/${{ secrets.USERNAME }}/${{ env.DEPLOY_PATH }}/infra ]; then + sudo systemctl stop adaptive_hockey_federation.service + echo "Stopping old containers" + fi + - name: Copy infra via ssh uses: appleboy/scp-action@master with: From eaf9d40ef3893865a7879fe007592c309508339c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9E=D0=BB=D0=B5=D0=B3=20=D0=93=D0=BE=D0=B2=D0=BE=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D1=81=D0=BA=D0=B8=D0=B9?= Date: Fri, 4 Oct 2024 19:50:49 +0500 Subject: [PATCH 3/3] on review --- .github/workflows/prod_deploy.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/prod_deploy.yaml b/.github/workflows/prod_deploy.yaml index 790c3b85..b3bd8b07 100644 --- a/.github/workflows/prod_deploy.yaml +++ b/.github/workflows/prod_deploy.yaml @@ -4,7 +4,7 @@ on: push: branches: - master - + env: DEPLOY_PATH: adaptive_hockey_federation REGISTRY: ghcr.io @@ -95,9 +95,12 @@ jobs: key: ${{ secrets.SSH_PRIVATE_KEY }} passphrase: ${{ secrets.SSH_PASSPHRASE }} script: | - if [ -d /home/${{ secrets.USERNAME }}/${{ env.DEPLOY_PATH }}/infra ]; then + STATUS="$(systemctl is-active adaptive_hockey_federation.service)" + if [ "${STATUS}" = "active" ]; then sudo systemctl stop adaptive_hockey_federation.service echo "Stopping old containers" + else + echo "No active containers" fi - name: Copy infra via ssh @@ -111,7 +114,7 @@ jobs: target: "${{ env.DEPLOY_PATH }}/infra" rm: true strip_components: 1 - + - name: Execute commands on VPS uses: appleboy/ssh-action@master with: