@@ -35,7 +35,7 @@ volumes:
3535 - ./lychee/storage/app:/app/storage/app
3636 - ./lychee/logs:/app/storage/logs
3737 - ./lychee/tmp:/app/storage/tmp # so that uploads are not filling up the memory of the container
38- - ./lychee/conf/.env:/app/.env:ro
38+ - ./lychee/conf/.env:/app/.env
3939 - ./conf/user.css:/app/public/dist/user.css # optional
4040 - ./conf/custom.js:/app/public/dist/custom.js # optional
4141` ` `
@@ -266,6 +266,296 @@ or by logging into the web interface and going to Settings ⇒ Maintenance &r
266266For more help, visit our [GitHub Discussions](https://github.com/LycheeOrg/Lychee/discussions) or [Discord server](https://discord.gg/y4aUbnF).
267267
268268
269+ # # Migrating from Traditional Installation to Docker Compose
270+
271+ This guide helps you migrate an existing Lychee installation from a traditional setup (e.g., `/var/www/html/Lychee`) to a Docker Compose deployment.
272+
273+ # ## Prerequisites
274+
275+ Before starting the migration, make sure you have docker compose installed. You can follow the instructions [here](https://docs.docker.com/compose/install/).
276+
277+ # ## Migration Steps
278+
279+ # ### 1. **Backup Your Current Installation**
280+
281+ > {note} **Critical**: Always create backups before migrating. This ensures you can restore your installation if anything goes wrong.
282+
283+ ` ` ` bash
284+ # Backup the database
285+ mysqldump -u your_db_user -p your_db_name > ~/lychee_db_backup.sql
286+
287+ # Backup the entire Lychee directory
288+ cp -r /var/www/html/Lychee ~/lychee_backup
289+
290+ # Backup your .env file specifically
291+ cp /var/www/html/Lychee/.env ~/lychee_env_backup
292+ ` ` `
293+
294+ # ### 2. **Create Docker Compose Directory Structure**
295+
296+ Create a directory for your Docker Compose setup :
297+
298+ ` ` ` bash
299+ mkdir -p ~/lychee-docker
300+ cd ~/lychee-docker
301+
302+ # Create directories for volume mounts
303+ mkdir -p lychee/uploads
304+ mkdir -p lychee/storage/app
305+ mkdir -p lychee/logs
306+ mkdir -p lychee/tmp
307+ mkdir -p lychee/conf
308+ ` ` `
309+
310+ # ### 3. **Copy Your Data**
311+
312+ Move your existing uploads and configuration :
313+
314+ ` ` ` bash
315+ # Copy uploads (this may take time depending on your photo library size)
316+ sudo cp -r /var/www/html/Lychee/public/uploads/* ~/lychee-docker/lychee/uploads/
317+
318+ # Copy your .env configuration
319+ sudo cp /var/www/html/Lychee/.env ~/lychee-docker/lychee/conf/.env
320+
321+ # If you have custom CSS or JavaScript
322+ sudo cp /var/www/html/Lychee/public/dist/user.css ~/lychee-docker/conf/user.css 2>/dev/null || true
323+ sudo cp /var/www/html/Lychee/public/dist/custom.js ~/lychee-docker/conf/custom.js 2>/dev/null || true
324+
325+ # Set appropriate permissions
326+ sudo chown -R $USER:$USER ~/lychee-docker/lychee
327+ chmod -R 755 ~/lychee-docker/lychee
328+ ` ` `
329+
330+ # ### 4. **Create docker-compose.yml**
331+
332+ Create a `docker-compose.yml` file in `~/lychee-docker` :
333+
334+ ` ` ` yaml
335+ services:
336+ lychee_db:
337+ image: mariadb:11
338+ container_name: lychee_db
339+ environment:
340+ - MYSQL_ROOT_PASSWORD=rootpassword
341+ - MYSQL_DATABASE=lychee
342+ - MYSQL_USER=lychee
343+ - MYSQL_PASSWORD=lychee_password
344+ volumes:
345+ - ./lychee/lychee_db:/var/lib/mysql
346+ networks:
347+ - lychee
348+ restart: unless-stopped
349+
350+ lychee_api:
351+ image: ghcr.io/lycheeorg/lychee:latest
352+ container_name: lychee
353+ ports:
354+ - "8000:8000" # Change the first part XXXX:8000 this to your preferred port
355+ env_file:
356+ - ./lychee/conf/.env
357+ volumes:
358+ - ./lychee/uploads:/app/public/uploads
359+ - ./lychee/storage/app:/app/storage/app
360+ - ./lychee/logs:/app/storage/logs
361+ - ./lychee/tmp:/app/storage/tmp
362+ - ./lychee/conf/.env:/app/.env
363+ # Optional: Uncomment if you have custom CSS/JS
364+ # - ./conf/user.css:/app/public/dist/user.css
365+ # - ./conf/custom.js:/app/public/dist/custom.js
366+ environment:
367+ - DB_CONNECTION=mysql
368+ - DB_HOST=lychee_db
369+ - DB_PORT=3306
370+ - DB_DATABASE=lychee
371+ - DB_USERNAME=lychee
372+ - DB_PASSWORD=lychee_password
373+ depends_on:
374+ - lychee_db
375+ networks:
376+ - lychee
377+ restart: unless-stopped
378+
379+ networks:
380+ lychee:
381+ ` ` `
382+
383+ # ### 6. **Update Your .env File**
384+
385+ Edit `~/lychee-docker/lychee/conf/.env` to update database connection settings :
386+
387+ ` ` ` bash
388+ # Update these values to match your docker-compose.yml
389+ DB_CONNECTION=mysql
390+ DB_HOST=lychee_db
391+ DB_PORT=3306
392+ DB_DATABASE=lychee
393+ DB_USERNAME=lychee
394+ DB_PASSWORD=lychee_password
395+
396+ # Set the application URL
397+ APP_URL=http://your-domain.com:8000 # Update with your domain/IP
398+ ` ` `
399+
400+ # ### 7. **Import Your Database**
401+
402+ Start the database container and import your data :
403+
404+ ` ` ` bash
405+ cd ~/lychee-docker
406+
407+ # Start only the database service
408+ docker-compose up -d lychee_db
409+
410+ # Wait for the database to be ready (about 10-20 seconds)
411+ sleep 20
412+
413+ # Import your database backup
414+ docker exec -i lychee_db mysql -u lychee -plychee_password lychee < ~/lychee_db_backup.sql
415+ ` ` `
416+
417+ # ### 8. **Start Lychee**
418+
419+ ` ` ` bash
420+ # Start all services
421+ docker-compose up -d
422+
423+ # Check logs to ensure everything started correctly
424+ docker-compose logs -f lychee
425+ ` ` `
426+
427+ Press `Ctrl+C` to exit log viewing.
428+
429+ # ### 9. **Configure Reverse Proxy (Optional)**
430+
431+ If you're using a reverse proxy (recommended for production), configure it to forward to the Docker container.
432+
433+ **Nginx Example:**
434+
435+ ` ` ` nginx
436+ server {
437+ listen 80;
438+ server_name your-domain.com;
439+
440+ location / {
441+ proxy_pass http://localhost:8000;
442+ proxy_set_header Host $host;
443+ proxy_set_header X-Real-IP $remote_addr;
444+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
445+ proxy_set_header X-Forwarded-Proto $scheme;
446+
447+ # For large photo uploads
448+ client_max_body_size 100M;
449+ }
450+ }
451+ ` ` `
452+
453+ **Apache Example:**
454+
455+ ` ` ` apacheconf
456+ <VirtualHost *:80>
457+ ServerName your-domain.com
458+
459+ ProxyPreserveHost On
460+ ProxyPass / http://localhost:8000/
461+ ProxyPassReverse / http://localhost:8000/
462+
463+ # For large photo uploads
464+ LimitRequestBody 104857600
465+ </VirtualHost>
466+ ` ` `
467+
468+ Enable required modules and restart :
469+ ` ` ` bash
470+ # For Apache
471+ sudo a2enmod proxy proxy_http
472+ sudo systemctl restart apache2
473+
474+ # For Nginx
475+ sudo systemctl restart nginx
476+ ` ` `
477+
478+ # ### 10. **Verify Migration**
479+
480+ 1. Access Lychee at `http://your-domain.com` (or `http://your-domain.com:8000` if not using reverse proxy)
481+ 2. Log in with your existing credentials
482+ 3. Verify your photos and albums are displayed correctly
483+ 4. Check Settings ⇒ Diagnostics to ensure everything is working
484+
485+ # ### 11. **Optional: Add Worker Service**
486+
487+ For better performance with large photo libraries, consider adding a worker service :
488+
489+ ` ` ` yaml
490+ lychee_worker:
491+ image: ghcr.io/lycheeorg/lychee:latest
492+ container_name: lychee_worker
493+ volumes:
494+ - ./lychee/uploads:/app/public/uploads
495+ - ./lychee/storage/app:/app/storage/app
496+ - ./lychee/logs:/app/storage/logs
497+ - ./lychee/tmp:/app/storage/tmp
498+ - ./lychee/conf/.env:/app/.env:ro
499+ environment:
500+ - LYCHEE_MODE=worker
501+ - DB_CONNECTION=mysql
502+ - DB_HOST=lychee_db
503+ - DB_PORT=3306
504+ - DB_DATABASE=lychee
505+ - DB_USERNAME=lychee
506+ - DB_PASSWORD=lychee_password
507+ - QUEUE_CONNECTION=database
508+ depends_on:
509+ - lychee_db
510+ - lychee_api
511+ networks:
512+ - lychee
513+ restart: unless-stopped
514+ ` ` `
515+
516+ Also add `QUEUE_CONNECTION=database` to the `lychee_api` service environment variables, then restart :
517+
518+ ` ` ` bash
519+ docker-compose up -d
520+ ` ` `
521+
522+ # ## Post-Migration Cleanup
523+
524+ After confirming everything works correctly :
525+
526+ ` ` ` bash
527+ # Disable the old web server from starting on boot
528+ sudo systemctl disable apache2 # or nginx
529+
530+ # You can remove the old installation (keep the backup!)
531+ # sudo rm -rf /var/www/html/Lychee # Only after thorough testing!
532+ ` ` `
533+
534+ # ## Troubleshooting
535+
536+ **Cannot access Lychee**
537+ - Check if containers are running : ` docker ps`
538+ - Check logs : ` docker logs lychee`
539+ - Verify port 8000 is not blocked by firewall
540+ - If using reverse proxy, check proxy configuration
541+
542+ **Photos not showing**
543+ - Verify uploads were copied correctly : ` ls -la ~/lychee-docker/lychee/uploads/`
544+ - Check volume mount permissions
545+ - Verify file paths in database match new structure
546+
547+ **Database connection errors**
548+ - Confirm database container is running : ` docker ps lychee_db`
549+ - Verify credentials in `.env` match `docker-compose.yml`
550+ - Check database logs : ` docker logs lychee_db`
551+
552+ **Permission errors**
553+ - Fix ownership : ` sudo chown -R 33:33 ~/lychee-docker/lychee/` (33 is www-data UID/GID but can also be 82 for alpine)
554+ - Or make directories writable : ` chmod -R 777 ~/lychee-docker/lychee/` (less secure)
555+
556+ For additional help, visit our [GitHub Discussions](https://github.com/LycheeOrg/Lychee/discussions) or [Discord server](https://discord.gg/y4aUbnF).
557+
558+
269559# # Upgrading from Lychee v3 to v4
270560
271561# ## Checking requirements
0 commit comments