Set timezone configuration via environment variable

This commit is contained in:
Eduardo Silva 2025-02-21 15:51:40 -03:00
parent 8212446a72
commit 0df6a85bbc
3 changed files with 15 additions and 0 deletions

View File

@ -2,3 +2,6 @@
# A missconfigured SERVER_ADDRESS will cause the app to have CSRF errors.
SERVER_ADDRESS=my_server_address
DEBUG_MODE=False
# Choose a timezone from https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
TIMEZONE=America/Sao_Paulo

View File

@ -9,6 +9,7 @@ services:
- SERVER_ADDRESS=127.0.0.1
- DEBUG_MODE=True
- COMPOSE_VERSION=02r
- TZ=${TIMEZONE}
volumes:
- wireguard:/etc/wireguard
- static_volume:/app_static_files/
@ -39,6 +40,8 @@ services:
build:
context: ./cron
dockerfile: Dockerfile-cron
environment:
- TZ=${TIMEZONE}
depends_on:
- wireguard-webadmin
@ -51,6 +54,8 @@ services:
volumes:
- app_secrets:/app_secrets/
- rrd_data:/rrd_data/
environment:
- TZ=${TIMEZONE}
depends_on:
- wireguard-webadmin
@ -60,6 +65,8 @@ services:
build:
context: ./containers/dnsmasq
dockerfile: Dockerfile-dnsmasq
environment:
- TZ=${TIMEZONE}
volumes:
- dnsmasq_conf:/etc/dnsmasq/

View File

@ -28,6 +28,11 @@ CSRF_TRUSTED_ORIGINS = ['http://wireguard-webadmin', 'https://$SERVER_ADDRESS']
SECRET_KEY = '$(openssl rand -base64 32)'
EOL
if [ -n "$TZ" ]; then
echo "TIME_ZONE = '$TZ'" >> /app/wireguard_webadmin/production_settings.py
fi
sed -i "/^ path('admin\/', admin.site.urls),/s/^ / # /" /app/wireguard_webadmin/urls.py
exec "$@"