# Run Lychee - Photo Management System - in Docker

## What is Lychee?

> Lychee is a free photo-management tool, which runs on your server or web-space. Installing is a matter of seconds. Upload, manage and share photos like from a native application. Lychee comes with everything you need and all your photos are stored securely. -https://lycheeorg.github.io/

## Installing Docker

1. Log into the Linux based device
2. Run the following commands in the terminal
   # install prerequisites
   sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg-agent -y
   # add docker gpg key
   curl -fsSL https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release)/gpg | sudo apt-key add -
   # add docker software repository
   sudo add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release) $(lsb_release -cs) stable"
   # install docker
   sudo apt install docker-ce docker-compose containerd.io -y
   # enable and start docker service
   sudo systemctl enable docker && sudo systemctl start docker
   # add the current user to the docker group
   sudo usermod -aG docker $USER
   # reauthenticate for the new group membership to take effect
   su - $USER

## Running Lychee

1. Continue with the following commands in a terminal window
   # list current uid and gid, note these for later
   id $user
   # create working directories
   mkdir ~/docker/lychee/{conf,uploads,sim} -p && mkdir ~/docker/mariadb -p
   # set ownership on the working directories
   sudo chown "$USER":"$USER" ~/docker -R
   # create containers network
   docker network create containers
   # run the mariadb docker container
   docker run -d --name mariadb --network containers -e MYSQL_ROOT_PASSWORD=r00tp@$$ -e MYSQL_USER=lychee_rw -e MYSQL_PASSWORD='Lych33!' -e MYSQL_DATABASE=lychee -v ~/docker/mariadb:/var/lib/mysql -p 3306:3306 --restart=unless-stopped mariadb:latest
   # run the lychee docker image
   # replace PUID, GUID with the output of the id $user command above
   docker run -d --name lychee --network containers -e PUID=1000 -e PGID=1000 -e TZ=America/New_York -e PHP_TZ=America/New_York -e DB_CONNECTION=mysql -e DB_HOST=mariadb -e DB_PORT=3306 -e DB_USERNAME=lychee_rw -e DB_PASSWORD='Lych33!' -e DB_DATABASE=lychee -p 8090:80 -v ~/docker/lychee/conf:/config -v ~/docker/lychee/uploads:/uploads -v ~/docker/lychee/sym:/sym --restart=unless-stopped lycheeorg/lychee
2. Open a web browser and navigate to http://DNSorIP:8090
3. Click Next at the Lychee welcome screen
4. Click Next at the Requirements Check
5. Click Next at the Permissions Check
6. Update at least the following values in the

   APP_URL=http://DNSorIP:8090
   DB_CONNECTION=mysql
   DB_HOST=mariadb
   DB_PORT=3306
   DB_DATABASE=lychee
   DB_USERNAME=lychee_rw
   DB_PASSWORD=Lych33!

7. Click Save > Click Install
8. Once the installation completes click Set up admin account
9. Enter a Username > Enter and confirm a Password > Click Create admin account
10. Click Open Lychee
11. Login using the username and password setup earlier
12. Welcome to Lychee

Documentation: https://lycheeorg.github.io/docs/#installation