WIP: It starts!
This commit is contained in:
parent
2c4e55e2e7
commit
6edab9597b
4 changed files with 187 additions and 0 deletions
102
deploy.py
Normal file
102
deploy.py
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
from pyinfra import host
|
||||||
|
from pyinfra.operations import apt, server, files, systemd, mysql
|
||||||
|
|
||||||
|
apt.update(
|
||||||
|
name='Update apt repositories',
|
||||||
|
)
|
||||||
|
|
||||||
|
apt.upgrade(
|
||||||
|
name='Upgrade apt packages',
|
||||||
|
)
|
||||||
|
|
||||||
|
apt.packages(
|
||||||
|
name='Install dependencies',
|
||||||
|
packages=['mariadb-server', 'skopeo'],
|
||||||
|
update=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
server.user(
|
||||||
|
name='Create UNIX user',
|
||||||
|
user='photoprism',
|
||||||
|
shell='/bin/false',
|
||||||
|
present=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
for items in ['storage', 'originals', 'import']:
|
||||||
|
files.directory(
|
||||||
|
name='Make required directories /home/photoprism/{}'.format(items),
|
||||||
|
path='/home/photoprism/{}'.format(items),
|
||||||
|
user='photoprism',
|
||||||
|
group='photoprism',
|
||||||
|
mode=755
|
||||||
|
)
|
||||||
|
|
||||||
|
mysql.user(
|
||||||
|
name='Create MariaDB user',
|
||||||
|
user=host.data.photoprism_database_user,
|
||||||
|
password=host.data.photoprism_database_password,
|
||||||
|
)
|
||||||
|
|
||||||
|
mysql.database(
|
||||||
|
name='Create MariaDB database',
|
||||||
|
database=host.data.photoprism_database_name,
|
||||||
|
user=host.data.photoprism_database_user,
|
||||||
|
)
|
||||||
|
|
||||||
|
files.download(
|
||||||
|
name='Download undocker',
|
||||||
|
src=host.data.undocker_url,
|
||||||
|
dest='/usr/local/bin/undocker',
|
||||||
|
user='root',
|
||||||
|
group='root',
|
||||||
|
mode='755',
|
||||||
|
sha256sum='b937e69e774c530c080c1f6685763ca7db4dc58520a5a2054d111e1504f47688',
|
||||||
|
)
|
||||||
|
|
||||||
|
if not host.fact.file('/tmp/photoprism.tar'):
|
||||||
|
server.shell(
|
||||||
|
name='Download photoprism Docker image',
|
||||||
|
chdir='/tmp',
|
||||||
|
commands=['skopeo copy docker://docker.io/photoprism/photoprism:latest docker-archive:photoprism.tar'],
|
||||||
|
)
|
||||||
|
|
||||||
|
files.directory(
|
||||||
|
name='Ensure /opt/photoprism exists',
|
||||||
|
path='/opt/photoprism',
|
||||||
|
user='root',
|
||||||
|
group='root',
|
||||||
|
mode=755
|
||||||
|
)
|
||||||
|
|
||||||
|
server.shell(
|
||||||
|
name='Undocker the Docker image',
|
||||||
|
chdir='/opt/photoprism',
|
||||||
|
commands=['undocker /tmp/photoprism.tar - | tar -xv'],
|
||||||
|
)
|
||||||
|
|
||||||
|
files.template(
|
||||||
|
name='Set env file',
|
||||||
|
src='templates/env.j2',
|
||||||
|
dest='/etc/photoprism.env',
|
||||||
|
mode='600',
|
||||||
|
)
|
||||||
|
|
||||||
|
files.put(
|
||||||
|
name='Set systemd service file',
|
||||||
|
src='files/photoprism.service',
|
||||||
|
dest='/etc/systemd/system/photoprism.service',
|
||||||
|
mode='644',
|
||||||
|
)
|
||||||
|
|
||||||
|
systemd.daemon_reload(
|
||||||
|
name='Reload systemd',
|
||||||
|
user_mode=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
systemd.service(
|
||||||
|
name='Enable systemd service',
|
||||||
|
service='photoprism.service',
|
||||||
|
running=True,
|
||||||
|
restarted=True,
|
||||||
|
enabled=True,
|
||||||
|
)
|
18
files/photoprism.service
Normal file
18
files/photoprism.service
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
[Unit]
|
||||||
|
Description=photoprism
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
User=photoprism
|
||||||
|
Group=photoprism
|
||||||
|
StateDirectory=photoprism
|
||||||
|
EnvironmentFile=/etc/photoprism.env
|
||||||
|
WorkingDirectory=/photoprism
|
||||||
|
RootDirectory=/opt/photoprism
|
||||||
|
BindPaths=/home/photoprism/storage:/photoprism/storage /home/photoprism/originals:/photoprism/originals /home/photoprism/import:/photoprism/import
|
||||||
|
ExecStart=/photoprism/bin/photoprism start
|
||||||
|
Restart=on-failure
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
34
group_data/all.py
Normal file
34
group_data/all.py
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
# Undocker source
|
||||||
|
undocker_url='https://git.sr.ht/~motiejus/undocker/refs/download/v1.0.2/undocker-linux-amd64-v1.0.2'
|
||||||
|
|
||||||
|
# Used for the system
|
||||||
|
|
||||||
|
# From Dockerfile
|
||||||
|
|
||||||
|
# From docker-compose
|
||||||
|
photoprism_admin_password='insecure' # File size limit for originals in MB (increase for high-res video)
|
||||||
|
photoprism_originals_limit=5000 # File size limit for originals in MB (increase for high-res video)
|
||||||
|
photoprism_http_compression="GZIP" # Improves transfer speed and bandwidth utilization (none or gzip)
|
||||||
|
photoprism_debug="false" # Run in debug mode (shows additional log messages)
|
||||||
|
photoprism_public="false" # No authentication required (disables password protection)
|
||||||
|
photoprism_readonly="false" # Don't modify originals directory (reduced functionality)
|
||||||
|
photoprism_experimental="false" # Enables experimental features
|
||||||
|
photoprism_disable_webdav="false" # Disables built-in WebDAV server
|
||||||
|
photoprism_disable_settings="false" # Disables Settings in Web UI
|
||||||
|
photoprism_disable_tensorflow="false" # Disables all features depending on TensorFlow
|
||||||
|
photoprism_disable_faces="false" # Disables facial recognition
|
||||||
|
photoprism_disable_classification="false" # Disables image classification
|
||||||
|
photoprism_darktable_presets="false" # Enables Darktable presets and disables concurrent RAW conversion
|
||||||
|
photoprism_detect_nsfw="false" # Flag photos as private that MAY be offensive (requires TensorFlow)
|
||||||
|
photoprism_upload_nsfw="true" # Allow uploads that MAY be offensive
|
||||||
|
photoprism_database_driver="mysql" # Use MariaDB (or MySQL) instead of SQLite for improved performance
|
||||||
|
photoprism_database_server="127.0.0.1:3306" # MariaDB database server (hostname=port)
|
||||||
|
photoprism_database_name="photoprism" # MariaDB database schema name
|
||||||
|
photoprism_database_user="photoprism" # MariaDB database user name
|
||||||
|
photoprism_database_password='insecure'
|
||||||
|
photoprism_site_url="http://localhost:2342/" # Public PhotoPrism URL
|
||||||
|
photoprism_site_title="PhotoPrism"
|
||||||
|
photoprism_site_caption="Browse Your Life"
|
||||||
|
photoprism_site_description=""
|
||||||
|
photoprism_site_author=""
|
||||||
|
home="/photoprism"
|
33
templates/env.j2
Normal file
33
templates/env.j2
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
PHOTOPRISM_ASSETS_PATH="/photoprism/assets"
|
||||||
|
PHOTOPRISM_STORAGE_PATH="/photoprism/storage"
|
||||||
|
PHOTOPRISM_BACKUP_PATH="/var/lib/photoprism"
|
||||||
|
PHOTOPRISM_ORIGINALS_PATH="/photoprism/originals"
|
||||||
|
PHOTOPRISM_IMPORT_PATH="/photoprism/import"
|
||||||
|
PHOTOPRISM_LOG_FILENAME="/photoprism/photoprism.log"
|
||||||
|
PHOTOPRISM_PID_FILENAME="/photoprism/photoprism.pid"
|
||||||
|
PHOTOPRISM_ADMIN_PASSWORD="{{ host.data.photoprism_admin_password }}"
|
||||||
|
PHOTOPRISM_ORIGINALS_LIMIT={{ host.data.photoprism_originals_limit }}
|
||||||
|
PHOTOPRISM_HTTP_COMPRESSION="{{ host.data.photoprism_http_compression }}"
|
||||||
|
PHOTOPRISM_DEBUG="false"
|
||||||
|
PHOTOPRISM_PUBLIC="false"
|
||||||
|
PHOTOPRISM_READONLY="false"
|
||||||
|
PHOTOPRISM_EXPERIMENTAL="false"
|
||||||
|
PHOTOPRISM_DISABLE_WEBDAV="false"
|
||||||
|
PHOTOPRISM_DISABLE_SETTINGS="false"
|
||||||
|
PHOTOPRISM_DISABLE_TENSORFLOW="false"
|
||||||
|
PHOTOPRISM_DISABLE_FACES="false"
|
||||||
|
PHOTOPRISM_DISABLE_CLASSIFICATION="false"
|
||||||
|
PHOTOPRISM_DARKTABLE_PRESETS="false"
|
||||||
|
PHOTOPRISM_DETECT_NSFW="false"
|
||||||
|
PHOTOPRISM_UPLOAD_NSFW="true"
|
||||||
|
PHOTOPRISM_DATABASE_DRIVER="mysql"
|
||||||
|
PHOTOPRISM_DATABASE_SERVER="{{ host.data.photoprism_database_server }}"
|
||||||
|
PHOTOPRISM_DATABASE_NAME="{{ host.data.photoprism_database_name }}"
|
||||||
|
PHOTOPRISM_DATABASE_USER="{{ host.data.photoprism_database_user }}"
|
||||||
|
PHOTOPRISM_DATABASE_PASSWORD="{{ host.data.photoprism_database_password }}"
|
||||||
|
PHOTOPRISM_SITE_URL="http://localhost:2342/"
|
||||||
|
PHOTOPRISM_SITE_TITLE="PhotoPrism"
|
||||||
|
PHOTOPRISM_SITE_CAPTION="Browse Your Life"
|
||||||
|
PHOTOPRISM_SITE_DESCRIPTION=""
|
||||||
|
PHOTOPRISM_SITE_AUTHOR=""
|
||||||
|
HOME="/photoprism"
|
Reference in a new issue