From 4c410fa89f3729b6bd563c3c3362d9c3db073c6e Mon Sep 17 00:00:00 2001 From: WP Studio Date: Tue, 24 Jun 2025 13:53:08 +0300 Subject: [PATCH] + python projects nginx example config and postgis and additional python server docker examples --- bash/python-restart.sh | 22 ++++++++++++++++++++++ config/nginx/conf.d/z-python.conf.example | 7 +++++++ docker-compose.postgres.yml.example | 13 +++++++++++++ docker-compose.python.yml.example | 14 ++++++++++++++ 4 files changed, 56 insertions(+) create mode 100755 bash/python-restart.sh diff --git a/bash/python-restart.sh b/bash/python-restart.sh new file mode 100755 index 0000000..a5df79b --- /dev/null +++ b/bash/python-restart.sh @@ -0,0 +1,22 @@ +#!/bin/bash +DIR="$(realpath $(dirname "$(readlink -f "$0")")/..)" + +. $DIR/bash/_docker-cmd.sh || { + echo "no docker cmd is presented" && exit 1 +} + +PYTHON_SERVICE=$1 + +if [[ -z "${PYTHON_SERVICE}" ]]; then + echo "Usage: $(basename $0) PYTHON_PROJECT_NAME" + exit 1 +fi + +CONTAINER=$(docker ps | grep "python-${PYTHON_SERVICE}" | awk '{print $1}') + +if [[ -z "${CONTAINER}" ]]; then + echo "Unable to find container: db" + exit 1 +fi + +$DOCKER_CMD restart ${CONTAINER} \ No newline at end of file diff --git a/config/nginx/conf.d/z-python.conf.example b/config/nginx/conf.d/z-python.conf.example index 7b3dcc0..2c9351b 100644 --- a/config/nginx/conf.d/z-python.conf.example +++ b/config/nginx/conf.d/z-python.conf.example @@ -22,7 +22,14 @@ server { root $python_root; + location @media_proxy { + proxy_pass $uploads_upstream; + proxy_ssl_server_name on; + } + location ~ /media { + root $python_root; + try_files $uri @media_proxy; expires max; } diff --git a/docker-compose.postgres.yml.example b/docker-compose.postgres.yml.example index 93f02a9..fda5e70 100755 --- a/docker-compose.postgres.yml.example +++ b/docker-compose.postgres.yml.example @@ -9,6 +9,19 @@ services: - ./hostfiles:/hostfiles ports: - "5432:5432" + db-project: + image: postgis/postgis:14-3.3 + environment: + - POSTGRES_DB=project_db + - POSTGRES_USER=project_db_user + - POSTGRES_PASSWORD=project_db_password + ports: + - "5434:5432" + healthcheck: + test: [ "CMD-SHELL", "pg_isready" ] + interval: 10s + timeout: 5s + retries: 5 volumes: databasepg: diff --git a/docker-compose.python.yml.example b/docker-compose.python.yml.example index 93cda52..6563a44 100755 --- a/docker-compose.python.yml.example +++ b/docker-compose.python.yml.example @@ -13,4 +13,18 @@ services: python manage.py migrate && python manage.py collectstatic && uvicorn 'APP_NAME.asgi:application' --host 0.0.0.0 + " + python-project: + user: ${WORKSPACE_PUID}:${WORKSPACE_PGID} + restart: always + build: + context: ${PYTHON_PROJECTS_DIR}/project + volumes: + - ${PYTHON_PROJECTS_DIR}/project:/code + command: bash -c " + cd src + && python manage.py compilemessages + && python manage.py collectstatic --clear --noinput + && python manage.py migrate + && uvicorn --reload app.asgi:application --host 0.0.0.0 " \ No newline at end of file