Files
TimeTracker/docs/AVATAR_PERSISTENCE_SUMMARY.md
Dries Peeters 34946e1b80 feat: Make user profile pictures persistent across Docker updates
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
2025-10-22 11:12:11 +02:00

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

  1. app/routes/auth.py - Updated upload folder path
  2. app/models/user.py - Updated avatar path method
  3. docker/migrate-avatar-storage.py - New migration script
  4. docs/AVATAR_STORAGE_MIGRATION.md - Full migration guide

Verification

Test that avatars work correctly:

  1. Existing avatars display correctly
  2. New avatar uploads work
  3. Avatar removal works
  4. Avatars persist after docker-compose down && docker-compose up

See Also


Author: AI Assistant
Date: October 2025
Related Issue: Profile pictures persistence between versions