Any instructions on installing Photoprism with MariaDB or MySQL?

birdifly

Cadet
Joined
Oct 28, 2023
Messages
5
Hi all! I have a server in the cloud running photoprism with mysql that I would like to transfer to my TrueNAS Scale server. There is a nice guide on this forum on setting it up with TrueNAS CORE and am wondering if there is any such guide for SCALE.

The default Photoprism setup even for the TrueCharts version (as far as I'm aware) uses SQLite for the database, which isn't too performant for large photo collections. And I also can't restore from a backup made in MySQL.

As I understand I need to start up a MariaDB docker image, and then point environment variables on Photoprism to MariaDB. I'm not quite sure what networking options I need to choose to be able to expose the database to other containers.

If anyone can provide any pointers or a general guide that'd be very helpful. Cheers!
 

sfatula

Guru
Joined
Jul 5, 2022
Messages
608
I do exactly that.

So, step1 is to get mariadb running. Use the big blue button to launch docker image. You can use image repo of bitnami/mariadb and tag whatever tag you want, maybe latest, maybe a specific version, etc. Environment variables you'll probably want to define are:

TZ
MARIADB_SKIP_TEST_DB set to yes to not create a test database and users
MARIADB_DATABASE initial database you want to create, maybe photoprism
MARIADB_USER initial database user you want to use, again maybe photoprism
MARIADB_PASSWORD initial database password you want
MARIADB_ROOT_PASSWORD admin password

Generally, you can find details for docker apps on the docker hub website.

Assuming you are not using a bridge to assign it's own IP, you'll need to define the "port forward" in the app config also. So, 3306 maybe use for Scale 33306.

Hostpaths you will potentially want:

/bitnami/mariadb/data which is your actual database files
/opt/bitnami/mariadb/conf which is the mysql config files

The docker hub site documents how to override the config file. You'll want to change the port

I also define a /Backup hostpath as I have an in container backup script so I can do a consistant backup as opposed to just snapshots which may or may not be consistent.

So, pretty much like running docker anywhere else.

To point at mariadb from your photoprism container (it may or may not work via truecharts, I don't and never will use them), I generally use heavy script utility to find internal DNS names.
Run heavyscript and use option 1, then 1 again and look for your internal DNS name. For me, it is mariadb-ix-chart.ix-mariadb.svc.cluster.local

Now that I have the heavyscript DNS name, you can install the photoprism app, you'll need at least the following environment variables:

PHOTOPRISM_DATABASE_DRIVER set to mysql
PHOTOPRISM_DATABASE_SERVER set to internal dns name and port, for me mariadb-ix-chart.ix-mariadb.svc.cluster.local:3306
PHOTOPRISM_DATABASE_NAME would be your MySQL database name
PHOTOPRISM_DATABASE_USER would be your database user
PHOTOPRISM_DATABASE_PASSWORD would be your database password

And continue on installing photoprism, not going to go into that as there are many posts I've seen about that.

HeavyScript is used by quite a few here to backup application pool and other things like this.

That should do it. I actually did not do it this way for mariadb as I wanted to the the standard port for all sorts of other apps I have that use mariadb and are not on the truenas server. So, I created a bridge interface and gave mariadb it's own IP which then allowed me to use the standard port. This is not necessary for you though. My point in mentioning is it is quite possible I neglected something but get mariadb working first and if you use a tool such as dbeaver or mysql workbench, etc., then see if you can connect to mariadb from another machine to test the install.

It seems like a lot of steps, but it's not much different than using docker to me at least. You still need to assign hostpaths with docker, set environment variables, etc. so if you are familiar with docker, then, this shouldn't take but a few minutes to get mariadb running. I will say I created a specific dataset for mariadb as I wanted to use a recordsize of 16k for the mariadb database hostpath.
 

DaSnipe

Explorer
Joined
Jun 26, 2021
Messages
86
Hi all! I have a server in the cloud running photoprism with mysql that I would like to transfer to my TrueNAS Scale server. There is a nice guide on this forum on setting it up with TrueNAS CORE and am wondering if there is any such guide for SCALE.

The default Photoprism setup even for the TrueCharts version (as far as I'm aware) uses SQLite for the database, which isn't too performant for large photo collections. And I also can't restore from a backup made in MySQL.

As I understand I need to start up a MariaDB docker image, and then point environment variables on Photoprism to MariaDB. I'm not quite sure what networking options I need to choose to be able to expose the database to other containers.

If anyone can provide any pointers or a general guide that'd be very helpful. Cheers!
The TrueCharts version uses MariaDB, you can see the source code here -> https://github.com/truecharts/chart...d3e6/charts/stable/photoprism/values.yaml#L25
 

birdifly

Cadet
Joined
Oct 28, 2023
Messages
5
Thank you @DaSnipe. The TrueCharts version is what I ended up going with since that was way easier than doing it manually via the Truenas version. I got my backup restored successfully. Cheers!
 
Top