diff --git a/.github/workflows/deploy-development.yml b/.github/workflows/deploy-development.yml new file mode 100644 index 00000000..8764ad8f --- /dev/null +++ b/.github/workflows/deploy-development.yml @@ -0,0 +1,18 @@ +name: deploy-development + +on: + push: + branches: [ multiple-environments ] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: wshihadeh/docker-deployment-action@v2 + with: + remote_docker_host: webstrom@server.strom.sk + ssh_private_key: ${{ secrets.WEBSTROM_DEPLOY_SSH_PRIVATE_KEY }} + ssh_public_key: ${{ secrets.WEBSTROM_DEPLOY_SSH_PUBLIC_KEY }} + stack_file_name: deployment/compose-development.yaml + args: up --build --force-recreate --detach diff --git a/.github/workflows/deploy-production.yml b/.github/workflows/deploy-production.yml new file mode 100644 index 00000000..cd4068c0 --- /dev/null +++ b/.github/workflows/deploy-production.yml @@ -0,0 +1,16 @@ +name: deploy-production + +on: workflow_dispatch + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: wshihadeh/docker-deployment-action@v2 + with: + remote_docker_host: webstrom@server.strom.sk + ssh_private_key: ${{ secrets.WEBSTROM_DEPLOY_SSH_PRIVATE_KEY }} + ssh_public_key: ${{ secrets.WEBSTROM_DEPLOY_SSH_PUBLIC_KEY }} + stack_file_name: deployment/compose-production.yaml + args: up --build --force-recreate --detach diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy-testing.yml similarity index 77% rename from .github/workflows/deploy.yml rename to .github/workflows/deploy-testing.yml index 4446fa95..e4bece86 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy-testing.yml @@ -1,4 +1,4 @@ -name: deploy +name: deploy-testing on: workflow_dispatch @@ -6,11 +6,11 @@ jobs: deploy: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: wshihadeh/docker-deployment-action@v2 with: remote_docker_host: webstrom@server.strom.sk ssh_private_key: ${{ secrets.WEBSTROM_DEPLOY_SSH_PRIVATE_KEY }} ssh_public_key: ${{ secrets.WEBSTROM_DEPLOY_SSH_PUBLIC_KEY }} - stack_file_name: compose.yaml + stack_file_name: deployment/compose-testing.yaml args: up --build --force-recreate --detach diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8192b463..13698a6b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,7 +16,7 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Upgrade pip run: pip3 install --upgrade pip @@ -37,7 +37,7 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Upgrade pip run: pip3 install --upgrade pip diff --git a/.vscode/settings.json b/.vscode/settings.json index 3784257a..05430d69 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,8 +6,11 @@ "editor.defaultFormatter": "ms-python.autopep8", "editor.formatOnSave": true, }, + "files.associations": { + "compose-*.yaml": "dockercompose" + }, "git.branchProtection": [ "master" ], "git.branchProtectionPrompt": "alwaysCommitToNewBranch" -} \ No newline at end of file +} diff --git a/Pipfile b/Pipfile index 334e3e25..e6532a69 100644 --- a/Pipfile +++ b/Pipfile @@ -12,6 +12,7 @@ django-filter = "~=23.5" djangorestframework = "~=3.14.0" drf-writable-nested = "~=0.7.0" pillow = "~=10.3.0" +psycopg = "~=3.1.18" python-magic = "~=0.4.27" [dev-packages] diff --git a/Pipfile.lock b/Pipfile.lock index 358d5aeb..cb414857 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "7df0459bbb2186ea13bb8c25ce90a415fc188092d1f00f88ca5d6350af79aa21" + "sha256": "015f694f1252cff501635b7ea70ae740ebfd61bd41ce18f1646ad74b7d7fe992" }, "pipfile-spec": 6, "requires": {}, @@ -418,6 +418,14 @@ "index": "pypi", "version": "==10.3.0" }, + "psycopg": { + "hashes": [ + "sha256:31144d3fb4c17d78094d9e579826f047d4af1da6a10427d91dfcfb6ecdf6f12b", + "sha256:4d5a0a5a8590906daa58ebd5f3cfc34091377354a1acced269dd10faf55da60e" + ], + "index": "pypi", + "version": "==3.1.18" + }, "pyasn1": { "hashes": [ "sha256:3a35ab2c4b5ef98e17dfdec8ab074046fbda76e281c5a706ccd82328cfc8f64c", @@ -507,11 +515,11 @@ }, "setuptools": { "hashes": [ - "sha256:659e902e587e77fab8212358f5b03977b5f0d18d4724310d4a093929fee4ca1a", - "sha256:b6df12d754b505e4ca283c61582d5578db83ae2f56a979b3bc9a8754705ae3bf" + "sha256:3b2dbd8f63dcc6b7c327d0243c2d7dc8c96cc507c016f09221f3787e6e528719", + "sha256:8d881f842bfc0e29e93bc98a2e650e8845609adff4d2989ba6c748e67b09d5be" ], "markers": "python_version >= '3.8'", - "version": "==69.4.0" + "version": "==69.5.0" }, "six": { "hashes": [ @@ -523,11 +531,11 @@ }, "sqlparse": { "hashes": [ - "sha256:5430a4fe2ac7d0f93e66f1efc6e1338a41884b7ddf2a350cedd20ccc4d9d28f3", - "sha256:d446183e84b8349fa3061f0fe7f06ca94ba65b426946ffebe6e3e8295332420c" + "sha256:714d0a4932c059d16189f58ef5411ec2287a4360f17cdd0edd2d09d4c5087c93", + "sha256:c204494cd97479d0e39f28c93d46c0b2d5959c7b9ab904762ea6c7af211c8663" ], - "markers": "python_version >= '3.5'", - "version": "==0.4.4" + "markers": "python_version >= '3.8'", + "version": "==0.5.0" }, "twisted": { "extras": [ @@ -1062,11 +1070,11 @@ }, "sqlparse": { "hashes": [ - "sha256:5430a4fe2ac7d0f93e66f1efc6e1338a41884b7ddf2a350cedd20ccc4d9d28f3", - "sha256:d446183e84b8349fa3061f0fe7f06ca94ba65b426946ffebe6e3e8295332420c" + "sha256:714d0a4932c059d16189f58ef5411ec2287a4360f17cdd0edd2d09d4c5087c93", + "sha256:c204494cd97479d0e39f28c93d46c0b2d5959c7b9ab904762ea6c7af211c8663" ], - "markers": "python_version >= '3.5'", - "version": "==0.4.4" + "markers": "python_version >= '3.8'", + "version": "==0.5.0" }, "tomlkit": { "hashes": [ diff --git a/deployment/compose-development.yaml b/deployment/compose-development.yaml new file mode 100644 index 00000000..e8043519 --- /dev/null +++ b/deployment/compose-development.yaml @@ -0,0 +1,18 @@ +version: "3" + +services: + webstrom-backend: + build: .. + + image: webstrom-backend-development + + environment: + - DJANGO_SETTINGS_MODULE=webstrom.settings_development + + volumes: + - /var/run/postgresql:/var/run/postgresql:rw + + restart: "always" + + ports: + - 8930:8000 diff --git a/deployment/compose-production.yaml b/deployment/compose-production.yaml new file mode 100644 index 00000000..e69de29b diff --git a/deployment/compose-testing.yaml b/deployment/compose-testing.yaml new file mode 100644 index 00000000..191e3724 --- /dev/null +++ b/deployment/compose-testing.yaml @@ -0,0 +1,15 @@ +version: "3" + +services: + webstrom-backend: + build: .. + + image: webstrom-backend-testing + + environment: + - DJANGO_SETTINGS_MODULE=webstrom.settings_testing + + restart: "always" + + ports: + - 8920:8000 diff --git a/requirements.txt b/requirements.txt index d53a229f..fc0373d4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -34,6 +34,7 @@ oauthlib==3.2.2 openapi-codec==1.3.2 pillow==10.3.0 platformdirs==4.2.0 +psycopg==3.1.18 pyasn1==0.6.0 pyasn1_modules==0.4.0 pycodestyle==2.11.1 @@ -51,7 +52,7 @@ requests-oauthlib==2.0.0 service-identity==24.1.0 simplejson==3.19.2 six==1.16.0 -sqlparse==0.4.4 +sqlparse==0.5.0 tomlkit==0.12.4 Twisted==24.3.0 txaio==23.1.1 diff --git a/webstrom/settings_development.py b/webstrom/settings_development.py new file mode 100644 index 00000000..b483ac91 --- /dev/null +++ b/webstrom/settings_development.py @@ -0,0 +1,16 @@ +# pylint: disable=wildcard-import,unused-wildcard-import + +from .settings import * + +ALLOWED_HOSTS = [ + "development.strom.sk", +] + + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': 'webstrom-development', + 'USER': 'webstrom', + } +} diff --git a/webstrom/settings_production.py b/webstrom/settings_production.py new file mode 100644 index 00000000..e69de29b diff --git a/webstrom/settings_testing.py b/webstrom/settings_testing.py new file mode 100644 index 00000000..5646bea7 --- /dev/null +++ b/webstrom/settings_testing.py @@ -0,0 +1,7 @@ +# pylint: disable=wildcard-import,unused-wildcard-import + +from .settings import * + +ALLOWED_HOSTS = [ + "testing.strom.sk", +]