Skip to content

Latest commit

 

History

History
183 lines (120 loc) · 5.5 KB

File metadata and controls

183 lines (120 loc) · 5.5 KB

Running PhotoPrism via Podman and systemd

You are going to run the containers in user mode with podman. You would need to set up a (new) user. We assume the username is photoprism (otherwise you have to adjust a few files and commands), and that this user is dedicated for the task at hand: running the service and hosting the image files. So we are going to put all directories and files inside this user's home directory.

prerequisites

  • A linux system
    • using systemd as their init system
    • having podman installed
    • having git installed

creating the user

You are going to create the new user photoprism and afterwards assign a password:

sudo useradd -m photoprism && sudo passwd photoprism

Set up

All the next steps are done as the newly created user photoprism.

su - photoprism

preparations

You are going to need 4 directories, 1 for the database container (database) and 3 for the webserver container (originals, import, storage).

(In case you want to create any of these directories elsewhere or want to name them differently, you'll have to adjust the config; detailed instructions below)

mkdir ~/{database,originals,import,storage}

You need to tell the system that this user is allowed to keep processes running even after the user logged out:

loginctl enable-linger $(whoami)

We are going to store the unit files for systemd in ~/.config/systemd/user/. As this directory might not exist, we are going to create it:

mkdir -p ~/.config/systemd/user/

In order to execute some commands related to systemd as a user, we need to set an environment variable (find out which shell you are using via echo $0):

bash

echo "export XDG_RUNTIME_DIR=/run/user/\$(id -u)" >> ~/.bashrc && source ~/.bashrc

zsh

echo "export XDG_RUNTIME_DIR=/run/user/\$(id -u)" >> ~/.zshrc && source ~/.zshrc

cloning this project

git clone https://github.com/photoprism/photoprism-contrib.git

navigate into the repository

cd photoprism-contrib/config/podman-systemd/

configuring the containers

All relevant files are located in podman-systemd

creating your config files

cp ./container-photoprism-database-user.template ./container-photoprism-database-user.env
cp ./container-photoprism-webserver-user.template ./container-photoprism-webserver-user.env

database

By default, a schema called photoprism as well as a user called photoprism are created in the database (the DBMS mariadb). The user's default password is insecure.

You can change this by editing the two files container-photoprism-database-user.env and container-photoprism-webserver-user.env:

  • schema
    • MARIADB_DATABASE=photoprism in container-photoprism-database-user.env
    • PHOTOPRISM_DATABASE_NAME=photoprism in container-photoprism-webserver-user.env
  • user
    • MARIADB_USER=photoprism in container-photoprism-database-user.env
    • PHOTOPRISM_DATABASE_USER=photoprism in ccontainer-photoprism-webserver-user.env
  • password
    • MARIADB_PASSWORD=insecure in container-photoprism-database-user.env
    • PHOTOPRISM_DATABASE_PASSWORD=insecure in container-photoprism-webserver-user.env

local storage / volumes (optional)

In case you decided to persist your data in non-standard directories or you are running photoprism as another user, you would need to create a new .env file and adjust it accordingly:

cp ./volumes-photoprism-user.template ./volumes-photoprism-user.env

initial admin password for photoprism

You might want to change the admin password in container-photoprism-webserver-user.env:

  • PHOTOPRISM_ADMIN_PASSWORD=please-change-me

other configuration

All config option described here are still available. just add the corresponding options to container-photoprism-webserver-user.env

installing the pod and containers as systemd units

ln -s \
 $(pwd)/*.service \
 $(pwd)/*.env \
 ~/.config/systemd/user/

Next we are going to tell systemd about the new units

systemctl --user daemon-reload

(you would need to run this after the unit files changed, i.e. after you ran git pull)

Running photoprism

Now we can start the pod and both containers

systemctl --user enable --now pod-photoprism.service

let's try to access the webserver on the command line

curl http://localhost:2342

restarting photoprism

systemctl --user restart pod-photoprism.service

Auto updates

Next you are going to enable automatic updates of our images. The containers are being created with this flag: --label "io.containers.autoupdate=image" (in the .service files). Containers with this label which are controlled via systemd can be automatically updated regularly. To do so, we enable a systemd timer:

systemctl --user enable --now podman-auto-update.timer

next steps / TODOs / known issues

  • proxy, e.g. nginx
  • allow writing to import e.g. via smb

Works with

  • Fedora Server 36+
    • as described
  • Ubuntu Server 22.04+
    • works with the following changes:
      • sudo apt install podman -y
      • you might start with bash after logging into the newly created user (if your prompt looks minimal or echo $0 says -sh)

meta information

  • tested with Fedora Server 36 and podman 4.1.1
  • tested with Ubuntu Server 22.04 and podman 3.4.4