mirror of
https://github.com/DRYTRIX/TimeTracker.git
synced 2026-01-06 11:40:52 -06:00
Store user avatars in persistent /data volume instead of application directory to ensure profile pictures survive container rebuilds and version updates. Changes: - Update avatar upload folder from app/static/uploads/avatars to /data/uploads/avatars using existing app_data volume mount - Modify get_avatar_upload_folder() in auth routes to use persistent location with UPLOAD_FOLDER config - Update User.get_avatar_path() to reference new storage location - Add migration script to safely move existing avatars to new location - Preserve backward compatibility - no database changes required Benefits: - Profile pictures now persist between Docker image updates - Consistent with company logo storage pattern (/data/uploads) - Better user experience - avatars not lost during upgrades - Production-ready data/code separation - All persistent uploads consolidated in app_data volume Migration: For existing installations with user avatars, run: docker-compose run --rm app python /app/docker/migrate-avatar-storage.py New installations work automatically with no action required. Documentation: - docs/AVATAR_STORAGE_MIGRATION.md - Full migration guide - docs/AVATAR_PERSISTENCE_SUMMARY.md - Quick reference - docs/TEST_AVATAR_PERSISTENCE.md - Testing guide - AVATAR_PERSISTENCE_CHANGELOG.md - Detailed changelog Files modified: - app/routes/auth.py - app/models/user.py Files added: - docker/migrate-avatar-storage.py - docs/AVATAR_STORAGE_MIGRATION.md - docs/AVATAR_PERSISTENCE_SUMMARY.md - docs/TEST_AVATAR_PERSISTENCE.md - AVATAR_PERSISTENCE_CHANGELOG.md Tested: ✓ No linter errors, backward compatible, volume mount verified
1.7 KiB
1.7 KiB
Avatar Persistence Update - Summary
Quick Summary
✅ Profile pictures now persist between Docker updates!
User avatars are now stored in the persistent /data volume instead of the application directory, ensuring they survive container rebuilds and updates.
What to Do
For Existing Installations
If you have users with existing profile pictures:
# 1. Stop containers
docker-compose down
# 2. Run migration
docker-compose run --rm app python /app/docker/migrate-avatar-storage.py
# 3. Start containers
docker-compose up -d
For Fresh Installations
Nothing! The new location will be used automatically.
Changes Made
| Component | Change |
|---|---|
| Storage Location | app/static/uploads/avatars/ → /data/uploads/avatars/ |
| Persistence | ❌ Lost on update → ✅ Persists across updates |
| Docker Volume | Uses existing app_data volume |
| URL Structure | /uploads/avatars/{filename} (unchanged) |
Files Modified
- ✅
app/routes/auth.py- Updated upload folder path - ✅
app/models/user.py- Updated avatar path method - ✅
docker/migrate-avatar-storage.py- New migration script - ✅
docs/AVATAR_STORAGE_MIGRATION.md- Full migration guide
Verification
Test that avatars work correctly:
- ✅ Existing avatars display correctly
- ✅ New avatar uploads work
- ✅ Avatar removal works
- ✅ Avatars persist after
docker-compose down && docker-compose up
See Also
- 📖 Full Migration Guide
- 📖 Logo Upload System (similar persistent storage)
Author: AI Assistant
Date: October 2025
Related Issue: Profile pictures persistence between versions