130 lines
3.7 KiB
Markdown
130 lines
3.7 KiB
Markdown
# Quick Deployment Guide - Timezone Fix
|
|
|
|
## For Production Server
|
|
|
|
1. **SSH into your server** where Docker is running
|
|
|
|
2. **Navigate to project directory**
|
|
```bash
|
|
cd /path/to/panel
|
|
```
|
|
|
|
3. **Pull latest code** (includes timezone fixes)
|
|
```bash
|
|
git pull origin main
|
|
```
|
|
|
|
4. **Stop running containers**
|
|
```bash
|
|
docker-compose -f docker-compose.prod.yml down
|
|
```
|
|
|
|
5. **Rebuild Docker images** (this is critical - it bakes in the timezone configuration)
|
|
```bash
|
|
docker-compose -f docker-compose.prod.yml build --no-cache
|
|
```
|
|
|
|
6. **Start containers**
|
|
```bash
|
|
docker-compose -f docker-compose.prod.yml up -d
|
|
```
|
|
|
|
7. **Verify timezone is correct**
|
|
```bash
|
|
# Check container timezone
|
|
docker-compose -f docker-compose.prod.yml exec app date
|
|
# Should show Polish time with CEST/CET timezone
|
|
|
|
# Example output:
|
|
# Sat Oct 4 19:45:00 CEST 2025
|
|
```
|
|
|
|
8. **Test the fix**
|
|
- Post a new note at a known time (e.g., 19:45)
|
|
- Verify it displays the same time (19:45)
|
|
- Test both project notes and task notes
|
|
|
|
## What Changed
|
|
|
|
### Code Changes
|
|
- ✅ Fixed `datetime('now', 'localtime')` in all database queries
|
|
- ✅ Updated display formatters to use Europe/Warsaw timezone
|
|
- ✅ Fixed note display in components
|
|
|
|
### Docker Changes (Critical!)
|
|
- ✅ Set `ENV TZ=Europe/Warsaw` in Dockerfile
|
|
- ✅ Configured system timezone in containers
|
|
- ✅ Added TZ environment variable to docker-compose files
|
|
|
|
## Why Rebuild is Necessary
|
|
|
|
The timezone configuration is **baked into the Docker image** during build time:
|
|
- `ENV TZ=Europe/Warsaw` - Set during image build
|
|
- `RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime` - Executed during image build
|
|
|
|
Just restarting containers (`docker-compose restart`) will **NOT** apply these changes!
|
|
|
|
## Troubleshooting
|
|
|
|
### If times are still wrong after deployment:
|
|
|
|
1. **Verify you rebuilt the images**
|
|
```bash
|
|
docker images | grep panel
|
|
# Check the "CREATED" timestamp - should be recent
|
|
```
|
|
|
|
2. **Check if container has correct timezone**
|
|
```bash
|
|
docker-compose -f docker-compose.prod.yml exec app date
|
|
```
|
|
Should show Polish time, not UTC!
|
|
|
|
3. **Check SQLite is using correct time**
|
|
```bash
|
|
docker-compose -f docker-compose.prod.yml exec app node -e "const db = require('better-sqlite3')('./data/database.sqlite'); console.log(db.prepare(\"SELECT datetime('now', 'localtime') as time\").get());"
|
|
```
|
|
Should show current Polish time
|
|
|
|
4. **Force rebuild if needed**
|
|
```bash
|
|
docker-compose -f docker-compose.prod.yml down
|
|
docker system prune -f
|
|
docker-compose -f docker-compose.prod.yml build --no-cache
|
|
docker-compose -f docker-compose.prod.yml up -d
|
|
```
|
|
|
|
## Expected Behavior After Fix
|
|
|
|
### Before Fix (Docker in UTC):
|
|
```
|
|
User posts note at 10:30 Poland time
|
|
→ Docker sees 08:30 UTC as "local time"
|
|
→ SQLite stores: 08:30
|
|
→ Display shows: 08:30 ❌ (2 hours off!)
|
|
```
|
|
|
|
### After Fix (Docker in Europe/Warsaw):
|
|
```
|
|
User posts note at 10:30 Poland time
|
|
→ Docker sees 10:30 Poland time as "local time"
|
|
→ SQLite stores: 10:30
|
|
→ Display shows: 10:30 ✅ (correct!)
|
|
```
|
|
|
|
## Important Notes
|
|
|
|
1. **Old notes**: Notes created before this fix may still show incorrect times (they were stored in UTC)
|
|
2. **New notes**: All new notes after deployment will show correct times
|
|
3. **Audit logs**: Continue to work correctly (they always used ISO format)
|
|
4. **Zero downtime**: Can't achieve - need to stop/rebuild/start containers
|
|
|
|
## Quick Check Command
|
|
|
|
After deployment, run this one-liner to verify everything:
|
|
```bash
|
|
docker-compose -f docker-compose.prod.yml exec app sh -c 'date && node -e "console.log(new Date().toLocaleString(\"pl-PL\"))"'
|
|
```
|
|
|
|
Both outputs should show the same Polish time!
|