PhotoPrism

PhotoPrism
Photo by Anne Nygård / Unsplash

One thing that I have been interested in a while is a way to manage my photos myself. Amazon and Google have nice solutions but it scares me what they're doing with our personal photographs. It's also always abundantly clear that they offer all this free storage space to upload your photos to for free, and once they're all there, you'll now have to pay a price to keep them.

With that in mind, I have plenty of storage space for my photos, and I would think I have enough processing power to serve them to myself and maybe my family. So that seems like the way to go if I can make it work right? I came across some recommendations for PhotoPrism. It looks very slick. I love that it has facial recognition built in, and it has a map view to see where photographs have been taken which I find so very cool! There are a couple of Android apps, and there is an iOS app to upload photos from your phone which would be very handy. PhotoPrism is also compatible with Progressive Web Apps (PWA) so it should perform quite nicely on my iPhone.

Verify System Requirements

So PhotoPrism has some nice documentation and even includes system requirements which is nice to know how much of your resources you need to allocate. They recommend at least two cores and 3GB of physical memory, along with a 64-bit operating system. They also recommend Docker Compose. I've not had very much experience with containers, I'm still very green. So this will be a fun opportunity to maybe learn a little more about containers and Docker.

So I'll set up a virtual machine running Ubuntu 22.04 with 2 vCPUs and the I'll start with 4GB of memory and see how it goes.

Create Virtual Machine

I log into Windows Admin Center and connect to HV-03. I move to Virtual Machines and create a new one named PHOTOPRISM-01. I set the secure boot certificate to Microsoft UEFI Certificate Authority. Then I mount my Ubuntu ISO and I am ready to install the operating system.

Install Operating System

I power on PHOTOPRISM-01 and go through Ubuntu's installation wizard. While waiting for the installation to complete I connect to DC-02 in Windows Admin Center and create a local DNS A record PHOTOS.domain.local > 10.10.10.XXX which should be propagated by the time the installation wizard completes and the system reboots.

Configure Operating System

Configure SSH Key

Steps performed on desktop via Windows Terminal

  • ssh-keygen -t ed25519
  • Move-Item -Path c:\Users\david\filename* -Destination c:\Users\david\.ssh -Force
  • I open Windows Terminal Settings
  • I open the JSON file and add the following:
            {
                "colorScheme": "Ubuntu-ColorScheme",
                "commandline": "ssh -i \"~/.ssh/photoprism-01\" [email protected]",
                "experimental.retroTerminalEffect": false,
                "font": 
                {
                    "face": "Cascadia Code"
                },
                "guid": "{0caa0dad-35be-5f56-a8ff-XXXXXXXXXXXX}",
                "hidden": false,
                "name": "PHOTOPRISM-01",
                "tabTitle": "PHOTOPRISM-01"
            },
  • I confirm that the GUID is unique and then save the file

Configure SSH

Steps performed on PHOTOPRISM-01

  • mkdir /home/david/.ssh
  • nano /home/david/.ssh/authorized_keys
  • I paste in the public key and save the file
  • chmod 600 /home/david/.ssh/authorized_keys
  • sudo nano /etc/ssh/sshd_config
    • PermitRootLogin no
    • PubkeyAuthentication yes
    • PubkeyAcceptedKeyTypes ssh-ed25519
    • PasswordAuthentication no
    • AuthorizedKeysFile /home/david/.ssh/authorized_keys
  • I save the file
  • sudo sshd -t
  • sudo systemctl restart ssh

Install UFW and Fail2Ban

Steps performed on PHOTOPRISM-01

  • sudo apt install ufw
  • sudo apt install fail2ban

Install Dependencies

Steps performed on PHOTOPRISM-01

  • sudo apt install docker
  • sudo apt install docker-compose

I want to utilize my current storage on my fileserver, which is where all the photos currently live anyway.

  • sudo apt install cifs-utils

Steps performed on DC-02 via Windows Admin Center

  • I navigate to Active Directory
  • I click on Browse
  • I navigate to my Managed Service Accounts group
  • I click Create and then User
    • Name: _service_photoprism
    • Sam Account Name: _service_photoprism
    • Password: Record password in my password manager
    • I finish by hitting Create

Now I have a simple account I can use for this service in my little test environment.

Steps performed on PHOTOPRISM-01

  • nano /home/david/.photocredentials
username=_service_photoprism
password=XXXXXXXX
domain=domain.local
  • I saved the file.
  • chmod 400 /home/david/.photocredentials

To test my credentials I'll make a single mount which will disappear after a reboot.

  • mkdir /mnt/pictures
  • mount -t /cifs -o rw,vers3.0,credentials=/home/david/.photocredentials //10.10.10.XXX/Data/Pictures/Memes-Test /mnt/pictures/

The mount is successful so I'll make it permanent now.

  • sudo nano /etc/fstab
    • //10.10.10.XXX/Data/Pictures/Memes-Test /mnt/pictures cifs credentials=/home/david/.photocredentials,iocharset=utf8 0 0

Install PhotoPrism

Steps performed on PHOTOPRISM-01

  • mkdir /home/david/photoprism
  • nano /home/david/photoprism
    • I copy and paste PhotoPrism's sample docker-compose.yml file.
    • PHOTOPRISM_ADMIN_PASSWORD: XXXXXXXX
    • PHOTOPRISM_DATABASE_NAME: photoprism_db
    • PHOTOPRISM_DATABASE_USER: photoprism_user
    • PHOTOPRISM_DATABASE_PASSWORD: XXXXXXXX
    • MARIADB_DATABASE: photoprism_db
    • MARIADB_USER: photoprism_user
    • MARIADB_PASSWORD: XXXXXXXXX
    • MARIADB_ROOT_PASSWORD: XXXXXXXX
    • WATCHTOWER_POLL_INTERVAL: 604800
  • I save the file.
  • sudo docker-compose up -d
    • Creation failed.
  • I found a typo in one of my volume mount points and corrected it.
  • sudo docker-compose stop
  • sudo docker-compose up -d

Success! Next I try browsing to http://photos.domain.local:2342 and I have a login screen! I quickly change and record the admin password. I then proceed to go through the First Steps tutorial which has me:

  • Configure your library
  • Configure your advanced settings
  • Choose whether you want to index your original files directly, leaving all file and folder names unchanged, or use the optional import feature, which automatically removes duplicates, gives files a unique name, and sorts them by year and month.

I went ahead and started the indexing process which looks like it will take some time so I'll sign off for now and plan to check back in on it tomorrow.