Deploying LibrePhotos
Introduction
LibrePhotos is a powerful, self-hosted photo management system that brings Google Photos-like features to your own server. Using machine learning for facial recognition, object detection, and scene classification, LibrePhotos automatically organizes your photo library while keeping your memories completely private.
Forked from Ownphotos, LibrePhotos has evolved into a feature-rich platform with an active development community. The application uses Python and Django for the backend, with a React frontend providing a modern, responsive user interface.
Key highlights of LibrePhotos:
- Facial Recognition: Automatically detect and group faces across your photo library
- Object Detection: Identify objects, scenes, and locations in photos using AI
- Timeline View: Browse photos chronologically with smart grouping
- Map Integration: View photos on a map based on GPS metadata
- Album Management: Create and organize albums manually or automatically
- Search: Find photos by person, object, location, or date
- Sharing: Share albums with other users or via public links
- RAW Support: Handle RAW photo formats from various cameras
- Video Support: Manage videos alongside photos
- Multi-User: Support multiple users with separate libraries
- Mobile Apps: Access your library from iOS and Android apps
- Privacy-Focused: All processing happens on your server
This guide walks through deploying LibrePhotos on Klutch.sh using Docker and configuring it for your photo library.
Why Deploy LibrePhotos on Klutch.sh
Deploying LibrePhotos on Klutch.sh provides several advantages:
Simplified Deployment: Klutch.sh builds LibrePhotos from your Dockerfile automatically. Push to GitHub, and your photo library deploys.
Persistent Storage: Attach persistent volumes for your photos, thumbnails, and database. Your library survives restarts.
HTTPS by Default: Klutch.sh provides automatic SSL certificates for secure access to your photos.
GitHub Integration: Connect your repository for automatic redeployments on updates.
Scalable Resources: AI processing requires significant resources. Allocate CPU and memory based on library size.
Environment Variable Management: Securely store configuration without exposing credentials.
Custom Domains: Assign a custom domain for your photo library.
Always-On Availability: Your photo library remains accessible 24/7.
Prerequisites
Before deploying LibrePhotos on Klutch.sh, ensure you have:
- A Klutch.sh account
- A GitHub account with a repository for your configuration
- Basic familiarity with Docker and containerization concepts
- A PostgreSQL database
- Redis for caching and task queues
- Sufficient storage for your photo library and generated thumbnails
- (Optional) A custom domain for your LibrePhotos instance
Understanding LibrePhotos Architecture
LibrePhotos consists of multiple components:
Backend (Django): Python/Django application handling API requests and photo processing.
Frontend (React): Modern web interface for browsing and managing photos.
PostgreSQL: Database storing metadata, face encodings, and user data.
Redis: Message broker for background tasks and caching.
Worker Processes: Celery workers handling photo scanning, face detection, and AI processing.
Machine Learning Models: Pre-trained models for face recognition, object detection, and scene classification.
Preparing Your Repository
Repository Structure
librephotos-deploy/├── Dockerfile├── README.md└── .dockerignoreCreating the Dockerfile
FROM reallibrephotos/librephotos:latest
# Environment configurationENV BACKEND_HOST=0.0.0.0ENV BACKEND_PORT=8001ENV DB_BACKEND=postgresqlENV DB_HOST=${DB_HOST:-postgres}ENV DB_PORT=${DB_PORT:-5432}ENV DB_NAME=${DB_NAME:-librephotos}ENV DB_USER=${DB_USER:-librephotos}ENV DB_PASS=${DB_PASS}ENV REDIS_HOST=${REDIS_HOST:-redis}ENV REDIS_PORT=${REDIS_PORT:-6379}ENV SECRET_KEY=${SECRET_KEY}ENV MAPBOX_API_KEY=${MAPBOX_API_KEY:-}
# Create directoriesRUN mkdir -p /data /protected_media /logs
# Expose portsEXPOSE 8001
# Health checkHEALTHCHECK --interval=30s --timeout=10s --start-period=120s --retries=3 \ CMD curl -f http://localhost:8001/api/health/ || exit 1Creating the .dockerignore File
.git.github*.mdLICENSE.gitignore*.log.DS_Store.env.env.local__pycache__/Environment Variables Reference
| Variable | Required | Default | Description |
|---|---|---|---|
DB_HOST | Yes | postgres | PostgreSQL hostname |
DB_PORT | No | 5432 | PostgreSQL port |
DB_NAME | No | librephotos | Database name |
DB_USER | Yes | - | Database username |
DB_PASS | Yes | - | Database password |
REDIS_HOST | Yes | redis | Redis hostname |
SECRET_KEY | Yes | - | Django secret key |
MAPBOX_API_KEY | No | - | Mapbox API key for maps |
ALLOW_UPLOAD | No | true | Allow photo uploads |
Deploying LibrePhotos on Klutch.sh
- Select HTTP as the traffic type
- Set the internal port to 8001
Set Up PostgreSQL Database
Deploy PostgreSQL with the required extensions. LibrePhotos needs a database for storing metadata and face encodings.
Set Up Redis
Deploy Redis for task queue management. LibrePhotos uses Celery with Redis for background processing.
Generate a Secret Key
Create a secure Django secret key:
python -c 'from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())'Push Your Repository to GitHub
git initgit add Dockerfile .dockerignore README.mdgit commit -m "Initial LibrePhotos deployment configuration"git remote add origin https://github.com/yourusername/librephotos-deploy.gitgit push -u origin mainCreate a New Project on Klutch.sh
Navigate to the Klutch.sh dashboard and create a new project named “librephotos” or “photos”.
Create a New App
Within your project, create a new app. Connect your GitHub account and select your LibrePhotos repository.
Configure HTTP Traffic
In the deployment settings:
Set Environment Variables
Add the following:
| Variable | Value |
|---|---|
DB_HOST | Your PostgreSQL hostname |
DB_NAME | librephotos |
DB_USER | Your database username |
DB_PASS | Your database password |
REDIS_HOST | Your Redis hostname |
SECRET_KEY | Your generated secret key |
MAPBOX_API_KEY | Your Mapbox API key (optional) |
Attach Persistent Volumes
| Mount Path | Recommended Size | Purpose |
|---|---|---|
/data | 100+ GB | Original photo storage |
/protected_media | 50+ GB | Thumbnails and processed images |
/logs | 2 GB | Application logs |
Deploy Your Application
Click Deploy to start the build process. Initial deployment may take time as ML models are downloaded.
Create Admin User
After deployment, create the admin account through the setup process or API.
Initial Configuration
Setting Up Your Library
Configure photo sources:
- Log in as administrator
- Go to Settings > Scan Directory
- Point to your photo directories
- Start the initial scan
Face Recognition Setup
Enable facial recognition:
- Navigate to Settings > Face Recognition
- Enable face detection
- Run face scan on your library
- Review and label detected faces
Map Configuration
Enable location features:
- Obtain a Mapbox API key
- Add to environment variables
- Restart the application
- View photos on the map
User Management
Set up additional users:
- Create accounts for family members
- Assign appropriate permissions
- Each user gets their own library or shared access
Using LibrePhotos
Browsing Photos
Navigate your library:
- Use the timeline view for chronological browsing
- Filter by date, person, or location
- View photos on the map
- Search for specific content
Albums and Organization
Create albums:
- Select photos to add
- Create new album or add to existing
- Set sharing permissions
- Generate sharing links if needed
Face Management
Organize people:
- Review auto-detected faces
- Label identified individuals
- Merge duplicate face clusters
- Search photos by person
Production Best Practices
Security Recommendations
- Use strong passwords for all accounts
- Keep LibrePhotos updated
- Secure your PostgreSQL database
- Consider access restrictions if public-facing
Performance Optimization
- Allocate sufficient CPU for ML processing
- Use SSD storage for better performance
- Increase worker processes for faster scanning
- Configure Redis for optimal caching
Backup Strategy
- Back up PostgreSQL database regularly
- Back up original photos separately
- The
/protected_mediadirectory can be regenerated - Export face data if available
Troubleshooting
Photos Not Appearing
- Verify scan directory path is correct
- Check file permissions
- Review scan logs for errors
- Ensure supported file formats
Face Recognition Not Working
- Check ML model downloads completed
- Verify sufficient memory for processing
- Review worker logs for errors
- Manually trigger face scan
Slow Performance
- Increase allocated resources
- Check database query performance
- Optimize Redis cache settings
- Consider reducing concurrent workers
Additional Resources
- LibrePhotos GitHub Repository
- LibrePhotos Documentation
- LibrePhotos Discord
- Klutch.sh Persistent Volumes
- Klutch.sh Deployments
Conclusion
Deploying LibrePhotos on Klutch.sh gives you a powerful, AI-enhanced photo management system with automatic builds and secure HTTPS access. With facial recognition, object detection, and intelligent organization, LibrePhotos provides Google Photos-like features while keeping your memories completely private.
Your photos deserve a home you control, and LibrePhotos on Klutch.sh provides the infrastructure to make that possible.