4.7 KiB
4.7 KiB
🌍 Timezone Configuration for Kompose Stacks
All stacks in this Kompose project are now configured to use a centralized timezone setting through the root .env file.
🚀 Quick Start (3 Steps)
# 1. Make scripts executable
chmod +x add-timezone.sh restart-all-stacks.sh preview-timezone.py
# 2. Add timezone to all compose files
./add-timezone.sh
# 3. Restart stacks to apply changes
./restart-all-stacks.sh
That's it! All your containers will now use Europe/Amsterdam timezone (or whatever you set in .env).
📋 What's Included
Configuration Files
- ✅
.env- Updated withTIMEZONE=Europe/Amsterdam - 📄
.gitignore- Updated to ignore.bakbackup files
Scripts
- 🔧
add-timezone.sh- Adds TZ environment variable to all compose files - 🔧
add-timezone.py- Python implementation (called by .sh wrapper) - 🔧
restart-all-stacks.sh- Restarts all stacks to apply changes - 🔍
preview-timezone.py- Preview changes before applying
Documentation
- 📖
TIMEZONE_SUMMARY.md- Complete implementation summary - 📖
TIMEZONE_QUICKSTART.md- Step-by-step guide - 📖
TIMEZONE_CONFIG.md- Detailed configuration guide - 📖
TIMEZONE_README.md- This file
🎯 Preview Before Applying (Optional)
Want to see what changes will be made? Preview a single file first:
chmod +x preview-timezone.py
./preview-timezone.py auth/compose.yaml
This shows exactly what will be added without making any changes.
🔄 How It Works
- Root
.envdefines:TIMEZONE=Europe/Amsterdam - Each compose file gets:
TZ: ${TIMEZONE:-Europe/Amsterdam} - Docker applies the timezone to all containers
- Result: All logs, timestamps, and scheduled tasks use your timezone!
Example Service Configuration
services:
postgres:
image: postgres:latest
environment:
TZ: ${TIMEZONE:-Europe/Amsterdam} # 🆕 Added automatically
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASSWORD}
⚙️ Changing the Timezone
For All Stacks
Edit the root .env file:
# Change from Europe/Amsterdam to your timezone
TIMEZONE=America/New_York
Then restart stacks:
./restart-all-stacks.sh
For a Single Stack
Create or edit the stack's local .env file:
# In auth/.env
TIMEZONE=Asia/Tokyo
Then restart that stack:
cd auth && docker compose up -d
🌐 Common Timezones
| Region | Timezone | UTC Offset |
|---|---|---|
| Amsterdam | Europe/Amsterdam |
UTC+1/+2 |
| Berlin | Europe/Berlin |
UTC+1/+2 |
| London | Europe/London |
UTC+0/+1 |
| New York | America/New_York |
UTC-5/-4 |
| Los Angeles | America/Los_Angeles |
UTC-8/-7 |
| Tokyo | Asia/Tokyo |
UTC+9 |
| Sydney | Australia/Sydney |
UTC+10/+11 |
✅ Verification
Check if timezone is correctly applied:
# View current timezone
docker exec <container_name> date
# Check TZ environment variable
docker exec <container_name> printenv TZ
# View compose configuration
cd <stack> && docker compose config | grep TZ
🎓 Understanding the Format
The format ${TIMEZONE:-Europe/Amsterdam} means:
- Use
TIMEZONEfrom.envif set - Otherwise, fall back to
Europe/Amsterdam - This ensures it works even if
.envis missing
📦 Affected Stacks
All stacks in subdirectories will be configured:
- auth, auto, blog, chain, chat, code, dash, data
- dock, docs, home, link, news, proxy, sexy
- trace, track, vault, vpn
🔍 Troubleshooting
Scripts won't run
chmod +x *.sh *.py
Timezone not applied
# Force recreate
docker compose up -d --force-recreate
# Check configuration
docker compose config
Wrong time showing
# Verify root .env
grep TIMEZONE .env
# Check for stack override
grep TIMEZONE <stack>/.env
# Verify container env
docker exec <container> env | grep TZ
📚 More Information
- Quick Start: See
TIMEZONE_QUICKSTART.mdfor detailed steps - Full Guide: See
TIMEZONE_CONFIG.mdfor comprehensive documentation - Summary: See
TIMEZONE_SUMMARY.mdfor implementation details
🤝 Contributing
When adding new stacks, always include timezone configuration:
services:
your-service:
environment:
TZ: ${TIMEZONE:-Europe/Amsterdam}
📝 Notes
- Changes require container restart to take effect
- Backup files (
.bak) are automatically created - Backup files are git-ignored and can be safely deleted after verification
- Some containers may need additional timezone configuration (rare)
Need Help? Check the documentation files or open an issue!