Date: 2025-02-20
Status: accepted
The Epic Stack previously stored uploaded images directly in SQLite using binary data storage. While this approach is simple and works well for small applications, it has several limitations (as noted in the previous decision 018-images.md):
- Binary data in SQLite increases database size and backup complexity
- Large binary data in SQLite can impact database performance
- SQLite backups become larger and more time-consuming when including binary data
- No built-in CDN capabilities for serving images efficiently
We will switch from storing images in SQLite to storing them in Tigris, an S3-compatible object storage service. This change will:
- Move binary image data out of SQLite into specialized object storage
- Maintain metadata about images in SQLite (references, ownership, etc.)
- Leverage Tigris's S3-compatible API for efficient image storage and retrieval
- Enable better scalability for applications with many image uploads
To keep things lightweight, we will not be using an S3 SDK to integrate with Tigris and instead we'll manage authenticated fetch requests ourselves.
- Reduced SQLite database size and improved backup efficiency
- Better separation of concerns (binary data vs relational data)
- Potentially better image serving performance through Tigris's infrastructure
- More scalable solution for applications with heavy image usage
- Easier to implement CDN capabilities in the future
- Simplified database maintenance and backup procedures
- Tigris storage is much cheaper than Fly volume storage
- Additional external service dependency (though Fly as built-in support and no additional account needs to be created)
- Need to manage Tigris configuration
- Slightly more complex deployment setup
- Additional complexity in image upload and retrieval logic
The implementation involves:
- Setting up Tigris configuration
- Modifying image upload handlers to store files in Tigris
- Updating image retrieval routes to serve from Tigris
- Maintaining backward compatibility during migration (database migration is required as well as manual migration of existing images)
- Providing migration utilities for existing applications
- Tigris Documentation
- Previous image handling: 018-images.md