+ python projects nginx example config and postgis and additional python server docker examples

This commit is contained in:
WP Studio
2025-06-24 13:53:08 +03:00
parent 92cefd6fcd
commit 4c410fa89f
4 changed files with 56 additions and 0 deletions

22
bash/python-restart.sh Executable file
View File

@ -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}

View File

@ -22,7 +22,14 @@ server {
root $python_root; root $python_root;
location @media_proxy {
proxy_pass $uploads_upstream;
proxy_ssl_server_name on;
}
location ~ /media { location ~ /media {
root $python_root;
try_files $uri @media_proxy;
expires max; expires max;
} }

View File

@ -9,6 +9,19 @@ services:
- ./hostfiles:/hostfiles - ./hostfiles:/hostfiles
ports: ports:
- "5432:5432" - "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: volumes:
databasepg: databasepg:

View File

@ -13,4 +13,18 @@ services:
python manage.py migrate python manage.py migrate
&& python manage.py collectstatic && python manage.py collectstatic
&& uvicorn 'APP_NAME.asgi:application' --host 0.0.0.0 && 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
" "