How to install PhotoPrism in Jail?

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
More precisely: I'm not sure what the current replacement to portsnap fetch extract. From what I see on the FreeBSD forum, it looks like git clone --depth 1 https://cgit-beta.freebsd.org/ports.git, but that's not quite an official source.
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
I edited my post - too late obviously. While for src and docs the migration to git is complete the one for ports is not. So currently that leads to the documented (in the handbook) old-fashioned way:
svnlite co https://svn.freebsd.org/ports/head /usr/ports
or
svnlite co https://svn.freebsd.org/ports/branches/2021Q1 /usr/ports
followed by
cd /usr/ports; svnlite update for subsequent updates.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703

Tigersharke

BOfH in User's clothing
Administrator
Moderator
Joined
May 18, 2016
Messages
893
The issue with the make config-recursive could be solved by one of two methods:
  • creating an optimal config for them all in a clean jail (the provider of the jail plugin does make config-recursive) then copy the entire /var/ports/db to be extracted later into any fresh jail.
  • creating an /etc/make.conf for the jail which includes lines such as below for every one of the optimal dependencies.
    • Code:
      #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
      # freetype2 config                                      #
      #_______________________________________________________#
      
      .if ${.CURDIR:M*/ports/print/freetype2}
        OPTIONS_UNSET+=DEBUG
        OPTIONS_SET+=V38 V40 TABLE_VALIDATION
      .endif
      

      And possibly a load of general options settings (OPTIONS_UNSET is like "never" it supercedes any OPTION_SET) such as below.
    • Code:
      OPTIONS_UNSET+=WEBENGINE WIIMOTEDEV WIKI_PUBLISHER
      OPTIONS_UNSET+=XBACKLIGHT
      OPTIONS_UNSET+=ZSH
      OPTIONS_SET+=3DNOW 7ZIP
      OPTIONS_SET+=A52 AALIB AAC ALLSTAGES ALSA ANY2DJVU AOM API APNG ARMOR ASM ASS AUDIO AUDIOCD AVAHI
      

The trouble with both of these solutions, is that port options and dependencies change over time. Sometimes options are added or removed, and an update to installed ports will be triggered if an option is new or revised. Care must be taken to avoid conflicts in any general 'universal' group of options because some ports may have tick boxes while others using the same keyword may have radio buttons. Tick boxes can be any combination or amount, radio buttons can be set for only one of a total. Which method might be best? I lean toward the make.conf configuration which would override any default options for the ports (always make rmconfig-recursive to ensure this), this would be the choice if you were to have mostly custom configurations and your own repo.

If the preference is to always use pkgs from the FreeBSD repo which has all default options set when built, the first method is best as it would simply record that all configurations are chosen.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
I could reproduce that too... no soup for us.
There's an open issue that sounds relevant; I posted my failure output there:

It's a very new repo, just over a week old. I'd expect/hope it will improve/change quite a bit over the coming weeks, hopefully in such a way that whatever issue I'm seeing is resolved.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
A commit to the repo a few hours ago lets it build for me. Apparently there's a default password I haven't figured out yet, but it's running.

Edit: Once it's all working, looks like it'd be trivial (and documented--good for them on that) to put it behind a Caddy reverse proxy:
 
Last edited:

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
Saw that, but admin/photoprism doesn't work (and admin is given as the default username).
I was thinking more of trying:
sysrc PHOTOPRISM_ADMIN_PASSWORD="photoprism"

I'm just compiling it now, so can't test that yet myself.

Although to be perfectly honest, I don't know if it will be equivalent to the env. variable that docker would pass in on linux.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
Ah, yes, I think that would make more sense--but I don't see that the rc file would know what to do with a variable like that. And trying to run photoprism passwd, as recommended in the PhotoPrism docs, didn't work either--it complained about not being able to open the assets directory. Here's what did: First, install sudo in the jail. Next, stop photoprism with service photoprism stop. Then, sudo -u photoprism /usr/local/bin/photoprism --assets-path=/var/photoprism/assets --storage-path=/var/photoprism/storage --originals-path=/var/photoprism/storage/originals --import-path=/var/photoprism/storage/import passwd
Enter a password, then start photoprism again: service photoprism start.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
You certainly weren't wrong about it thrashing the CPU...
1610814154072.png
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
So, for now it would seem that this sequence gets you to a working jail:
Code:
echo '{"pkgs":["git","ca_root_nss","wget","npm","sudo"]}' > /tmp/pkg.json
iocage create -n "photoprism" -p /tmp/pkg.json -r 12.2-RELEASE vnet="on" allow_raw_sockets="1" dhcp="on" bpf="yes" boot="on"
rm /tmp/pkg.json
iocage console photoprism
svnlite co https://svn.freebsd.org/ports/head /usr/ports
cd /usr/ports; svnlite update
cd ~
git clone https://github.com/huo-ju/photoprism-freebsd-port
cd photoprism-freebsd-port
pkg install `make all-depends-list | cut -d / -f 4,5`
# Y a few times and Enter a bunch too (principle is that you must accept to proceed and use defaults only)
make config-recursive && make install
#Enter a lot of times to accept defaults (critical that only defaults are accepted)
#Tensorflow compiling is heavy on CPU for a long time
sysrc photoprism_enable="YES"
sysrc photoprism_assetspath="/var/photoprism/assets"
sysrc photoprism_storagepath="/var/photoprism/storage"
sudo -u photoprism /usr/local/bin/photoprism --assets-path=/var/photoprism/assets --storage-path=/var/photoprism/storage --originals-path=/var/photoprism/storage/originals --import-path=/var/photoprism/storage/import passwd
#enter the desired password twice
service photoprism start


Connect to http://jail.ip:2342

(I haven't taken into account mounting anything in place of using the default locations, so make sure you think about and do that as early as possible too).
 
Last edited:

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
OK, it's up and running. Setting up the reverse proxy with Caddy was just as easy as they said it would be. It's intriguing that it will let you synchronize with Nextcloud (or any other WebDAV server), and apparently two-way sync is supported. Looks like it also acts as its own WebDAV server, so you can add it as a shared drive in Windows/Mac and just copy photos directly there. This might be worth some more looking into...
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
So, for now it would seem that this sequence gets you to a working jail:
IIRC, sudo isn't installed by default--you'd need to install it separately. I know there's a way of invoking su that would do the same thing, I just hadn't bothered to look it up. Now that I have, it'd probably be better to do su -m photoprism -c '/usr/local/bin/photoprism ...'.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
IIRC, sudo isn't installed by default--you'd need to install it separately
Did you miss it in the pkgs list at the front?
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
Did you miss it in the pkgs list at the front?
Oops, yes, I did. Sorry. Though the su form still avoids needing to install it.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
Oops, yes, I did. Sorry. Though the su form still avoids needing to install it.
We're installing over 400 pkgs, I'm not sure 1 more makes a difference. Given the project will continue to focus on linux, maybe using common tools could help (although su should be there on linux too).
 

adrianwi

Guru
Joined
Oct 15, 2013
Messages
1,231
This looks interesting, but I'm struggling to create the jail with this error when trying to make install

Code:
Invalid C++ compiler path. C++ cannot be found.
Please specify which C++ compiler should be used as the host C++ compiler. [Default is ]: 


Any ideas what I might have done wrong?

Thanks
 

adrianwi

Guru
Joined
Oct 15, 2013
Messages
1,231
Yeah, I've followed this #52 although I did create the jail from the WUI
 
Top