77 lines
2.9 KiB
Docker
77 lines
2.9 KiB
Docker
# DOMAIN=example.com docker stack deploy -c pytition.yml pytition
|
|
# python3 /code/pytition/manage.py createsuperuser
|
|
|
|
services:
|
|
web:
|
|
image: ethibox/pytition:${VERSION:-latest}
|
|
command:
|
|
- /bin/sh
|
|
- -c
|
|
- |
|
|
apt-get update && apt-get install -y netcat-traditional
|
|
while ! nc -z db 5432; do echo "waiting for postgres to start..." && sleep 1; done;
|
|
cp /code/pytition/pytition/settings/config_example.py /config/docker_config.py
|
|
touch /config/__init__.py
|
|
sed -i -e 's/localhost/'$$DOMAIN'/g' /config/docker_config.py
|
|
pdm run /code/dev/generate_docker_config.sh
|
|
sed -i '/EMAIL_HOST/d' /config/docker_config.py
|
|
sed -i '/EMAIL_PORT/d' /config/docker_config.py
|
|
echo 'CSRF_TRUSTED_ORIGINS=["'$$CSRF_TRUSTED_ORIGINS'"]' >> /config/docker_config.py
|
|
echo 'EMAIL_HOST="'$$EMAIL_HOST'"' >> /config/docker_config.py
|
|
echo 'EMAIL_PORT='$$EMAIL_PORT'' >> /config/docker_config.py
|
|
echo 'EMAIL_HOST_USER="'$$EMAIL_HOST_USER'"' >> /config/docker_config.py
|
|
echo 'EMAIL_HOST_PASSWORD="'$$EMAIL_HOST_PASSWORD'"' >> /config/docker_config.py
|
|
echo 'EMAIL_USE_TLS='$$EMAIL_USE_TLS'' >> /config/docker_config.py
|
|
echo 'DEFAULT_FROM_EMAIL="'$$DEFAULT_FROM_EMAIL'"' >> /config/docker_config.py
|
|
pdm run python pytition/manage.py migrate
|
|
pdm run python pytition/manage.py collectstatic
|
|
pdm run python pytition/manage.py compilemessages
|
|
pdm run python pytition/manage.py runserver 0.0.0.0:8000
|
|
environment:
|
|
- EMAIL_HOST=${SMTP_HOST}
|
|
- EMAIL_PORT=${SMTP_PORT:-587}
|
|
- EMAIL_HOST_USER=${SMTP_USER}
|
|
- EMAIL_USE_TLS=${SMTP_TLS:-True}
|
|
- EMAIL_HOST_PASSWORD=${SMTP_PASSWORD}
|
|
- DEFAULT_FROM_EMAIL=${SMTP_FROM:-noreply@example.com}
|
|
- CSRF_TRUSTED_ORIGINS=${SCHEME:-https}://${DOMAIN:-pytition.localhost}
|
|
- DJANGO_SETTINGS_MODULE=config.docker_config
|
|
- PYTHONPATH=/
|
|
- DOMAIN=${DOMAIN:-pytition.localhost}
|
|
volumes:
|
|
- ${VOLUME_PATH}config:/config
|
|
- ${VOLUME_PATH}media:/mediaroot
|
|
deploy:
|
|
labels:
|
|
- traefik.enable=true
|
|
- traefik.http.routers.pytition-${NUMBER:-1}.rule=Host(`${DOMAIN:-pytition.localhost}`)
|
|
- traefik.http.routers.pytition-${NUMBER:-1}.entrypoints=${SCHEME:-https}
|
|
- traefik.http.routers.pytition-${NUMBER:-1}.service=pytition-${NUMBER:-1}
|
|
- traefik.http.routers.pytition-${NUMBER:-1}.tls.certresolver=letsencrypt
|
|
- traefik.http.services.pytition-${NUMBER:-1}.loadbalancer.server.port=8000
|
|
networks:
|
|
- internal
|
|
- traefik
|
|
|
|
db:
|
|
image: postgres:${POSTGRES_VERSION:-12-alpine}
|
|
volumes:
|
|
- ${VOLUME_PATH}db:/var/lib/postgresql/data
|
|
environment:
|
|
- POSTGRES_USER=postgres
|
|
- POSTGRES_PASSWORD=postgres
|
|
networks:
|
|
- internal
|
|
|
|
volumes:
|
|
db:
|
|
config:
|
|
media:
|
|
|
|
networks:
|
|
internal:
|
|
driver: overlay
|
|
attachable: true
|
|
traefik:
|
|
external: true
|
|
name: traefik-net
|