Browse Source

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

master
WP Studio 3 days ago
parent
commit
4c410fa89f
  1. 22
      bash/python-restart.sh
  2. 7
      config/nginx/conf.d/z-python.conf.example
  3. 13
      docker-compose.postgres.yml.example
  4. 14
      docker-compose.python.yml.example

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

7
config/nginx/conf.d/z-python.conf.example

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

13
docker-compose.postgres.yml.example

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

14
docker-compose.python.yml.example

@ -14,3 +14,17 @@ services:
&& 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
"
Loading…
Cancel
Save