117 lines
5.4 KiB
Django/Jinja
117 lines
5.4 KiB
Django/Jinja
version: '3.5'
|
|
|
|
# Docker Compose config file for PhotoPrism
|
|
#
|
|
# Note:
|
|
# - Hardware transcoding is only available for sponsors due to the high maintenance and support effort.
|
|
# - Running PhotoPrism on a server with less than 4 GB of swap space or setting a memory/swap limit can cause unexpected
|
|
# restarts ("crashes"), for example, when the indexer temporarily needs more memory to process large files.
|
|
# - If you install PhotoPrism on a public server outside your home network, please always run it behind a secure
|
|
# HTTPS reverse proxy such as Traefik or Caddy. Your files and passwords will otherwise be transmitted
|
|
# in clear text and can be intercepted by anyone, including your provider, hackers, and governments:
|
|
# https://docs.photoprism.app/getting-started/proxies/traefik/
|
|
#
|
|
# Setup Guides:
|
|
# - https://docs.photoprism.app/getting-started/docker-compose/
|
|
# - https://docs.photoprism.app/getting-started/raspberry-pi/
|
|
#
|
|
# Troubleshooting Checklists:
|
|
# - https://docs.photoprism.app/getting-started/troubleshooting/
|
|
# - https://docs.photoprism.app/getting-started/troubleshooting/docker/
|
|
# - https://docs.photoprism.app/getting-started/troubleshooting/mariadb/
|
|
#
|
|
# CLI Commands:
|
|
# - https://docs.photoprism.app/getting-started/docker-compose/#command-line-interface
|
|
#
|
|
# All commands may have to be prefixed with "sudo" when not running as root.
|
|
# This will point the home directory shortcut ~ to /root in volume mounts.
|
|
|
|
services:
|
|
photoprism:
|
|
## Use photoprism/photoprism:preview for testing preview builds:
|
|
image: photoprism/photoprism:latest
|
|
## Start as non-root user before initialization (supported: 0, 33, 50-99, 500-600, and 900-1200):
|
|
{% if photoprism.run_as.uid is defined and photoprism.run_as.uid != "" -%}
|
|
{% if photoprism.run_as.uid is defined and photoprism.run_as.uid != "" -%}
|
|
user: "{{ photoprism.run_as.uid }}:{{ photoprism.run_as.gid }}"
|
|
{%- else %}
|
|
user: "{{ photoprism.run_as.uid }}"
|
|
{%- endif %}
|
|
{%- else %}
|
|
# user: "1000:1000"
|
|
{%- endif %}
|
|
depends_on:
|
|
- mariadb
|
|
## Don't enable automatic restarts until PhotoPrism has been properly configured and tested!
|
|
## If the service gets stuck in a restart loop, this points to a memory, filesystem, network, or database issue:
|
|
## https://docs.photoprism.app/getting-started/troubleshooting/#fatal-server-errors
|
|
{% if photoprism.system.restart is defined and photoprism.system.restart != "" -%}
|
|
restart: "{{ photoprism.system.restart }}"
|
|
{%- else %}
|
|
# restart: unless-stopped
|
|
{%- endif %}
|
|
security_opt:
|
|
- seccomp:unconfined
|
|
- apparmor:unconfined
|
|
ports:
|
|
- "{{ photoprism.site.port }}:2342" # HTTP port (host:container)
|
|
env_file:
|
|
- "{{ photoprism_config_path | expanduser | realpath }}/photoprism.yml"
|
|
|
|
working_dir: "/photoprism" # do not change or remove
|
|
## Storage Folders: "~" is a shortcut for your home directory, "." for the current directory
|
|
volumes:
|
|
# "/host/folder:/photoprism/folder" # Example
|
|
- "~/Pictures:/photoprism/originals" # Original media files (DO NOT REMOVE)
|
|
# - "/example/family:/photoprism/originals/family" # *Additional* media folders can be mounted like this
|
|
# - "~/Import:/photoprism/import" # *Optional* base folder from which files can be imported to originals
|
|
- "{{ photoprism_cache_path }}:/photoprism/storage" # *Writable* storage folder for cache, database, and sidecar files (DO NOT REMOVE)
|
|
|
|
{% if photoprism.devices is defined and photoprism.devices|length >= 1 %}
|
|
devices:
|
|
{% for device in photoprism.devices %}
|
|
- "{{ device }}"
|
|
{% endfor %}
|
|
{% endif %}
|
|
networks:
|
|
- photoprism
|
|
|
|
## Database Server (recommended)
|
|
## see https://docs.photoprism.app/getting-started/faq/#should-i-use-sqlite-mariadb-or-mysql
|
|
mariadb:
|
|
## If MariaDB gets stuck in a restart loop, this points to a memory or filesystem issue:
|
|
## https://docs.photoprism.app/getting-started/troubleshooting/#fatal-server-errors
|
|
restart: unless-stopped
|
|
image: "{{ photoprism.db.image }}:{{ photoprism.db.version }}
|
|
env_file:
|
|
- "{{ grafana_setup_path | expanduser | realpath }}/db.yml"
|
|
security_opt: # see https://github.com/MariaDB/mariadb-docker/issues/434#issuecomment-1136151239
|
|
- seccomp:unconfined
|
|
- apparmor:unconfined
|
|
command: mysqld --innodb-buffer-pool-size=512M --transaction-isolation=READ-COMMITTED --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --max-connections=512 --innodb-rollback-on-timeout=OFF --innodb-lock-wait-timeout=120
|
|
## Never store database files on an unreliable device such as a USB flash drive,
|
|
## an SD card, or a shared network folder:
|
|
volumes:
|
|
- "{{ photoprism_db_path }}:/var/lib/mysql"
|
|
networks:
|
|
- photoprism
|
|
|
|
{% if photoprism.system.autoupdate == "true" %}
|
|
## Watchtower upgrades services automatically (optional)
|
|
## see https://docs.photoprism.app/getting-started/updates/#watchtower
|
|
## activate via "COMPOSE_PROFILES=update docker compose up -d"
|
|
watchtower:
|
|
restart: unless-stopped
|
|
image: containrrr/watchtower
|
|
profiles: ["update"]
|
|
environment:
|
|
WATCHTOWER_CLEANUP: "true"
|
|
WATCHTOWER_POLL_INTERVAL: 7200 # checks for updates every two hours
|
|
volumes:
|
|
- "/var/run/docker.sock:/var/run/docker.sock"
|
|
- "~/.docker/config.json:/config.json" # optional, for authentication if you have a Docker Hub account
|
|
{% endif %}
|
|
|
|
networks:
|
|
photoprism: {}
|