From 0df6a85bbc51fe263c4a31acf121c3c965db05f4 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Fri, 21 Feb 2025 15:51:40 -0300 Subject: [PATCH] Set timezone configuration via environment variable --- .env.example | 3 +++ docker-compose-no-nginx-dev.yml | 7 +++++++ entrypoint.sh | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/.env.example b/.env.example index 0de055e..a907de4 100644 --- a/.env.example +++ b/.env.example @@ -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 \ No newline at end of file diff --git a/docker-compose-no-nginx-dev.yml b/docker-compose-no-nginx-dev.yml index c6d53eb..5d24c87 100644 --- a/docker-compose-no-nginx-dev.yml +++ b/docker-compose-no-nginx-dev.yml @@ -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/ diff --git a/entrypoint.sh b/entrypoint.sh index 3f5e0bd..57f2c8b 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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 "$@"