Setup Using Synology NAS and Portainer¶
Note: This is contributed content and work in progress. Click the edit link to perform changes and send a pull request.
This guide will help you install PhotoPrism in your Synology NAS using Portainer, an open-source container manager system. The guide will cover the following steps:
- install Portainer in your Synology NAS using Task Manager;
- configure Portainer to use your Synology's docker endpoint;
- install PhotoPrism in your Synology NAS using Portainer, accessible over http / direct IP;
- (TO-DO) configure a reverse proxy in your Synology NAS to access Photoprism over https / custom domain name.
Step 1: install Portainer in your Synology NAS using Task Manager¶
Synology's official docker app is quite limited in terms of functionality and that is the reason why we will install Portainer first. It will make managing docker containers inside Synology much more easier and functional while sharing the same local docker endpoint (i.e. the same docker images / containers / volumes / etc. will be manageable in both Synology's app and Portainer). We could install it using the terminal / SSH connection to the NAS but in this way everything can be done using Synology's Diskstation Manager UI.
To install Portainer:
- install Synology's Docker app from the official package center;
- open Synology's File Station app and browse to the newly created docker shared folder;
- create a folder named portainer inside docker, which will persist relevant Portainer's data in our local filesystem.
open Synology's Control Panel > Task Scheduler and create a new Scheduled Task > User-defined script; you'll then need to fill in some details in the General, Schedule and Task Settings sections.
4.1. in General fill in:
4.1.1. Task: use a meaningful name, for e.g. Install Portainer;
4.1.2. User: keep this as root.
4.2. in Schedule fill in:
4.2.1. Date: set the task to run on a specific date (for eg. today) and choose Do not repeat. This task will be used just once to install Portainer, we don't want to run it afterwards;
4.2.2. Time: leave the default settings, they have no relevance;
4.3. in Task Settings fill in:
4.3.1. Run command: copy/paste the user defined script below. Check if the ports are available on your NAS and that the path to the volume is correct (it should point to the folder created in step 3 above):
docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v /volume1/docker/portainer:/data portainer/portainer-ce
click OK; then, on the list of scheduled tasks, select the newly created task and hit Run; follow the prompts to install Portainer; in the end you can delete the task or keep it – just uncheck the enabled checkbox to disable the task.
Portainer should now be acessible in your local network in http://[YOUR-LOCAL-IP]:9000/.
Step 2: configure Portainer to use your Synology's docker endpoint¶
- Open Portainer by visiting http://[YOUR-LOCAL-IP]:9000/;
- Choose and confirm a strong password; you will manage Portainer using this password and the admin username;
- Select Docker - Manage the local Docker environment to link Portainer to your Synology's local docker endpoint and hit Connect; Portainer's admin page should open;
- Click Endpoint in the left menu, then local and under Public IP place your local NAS IP (it should be the same [YOUR-LOCAL-IP] of step 6.
Step 3: install Photoprism in your Synology NAS using Portainer, accessible over http / direct IP¶
With Portainer installed we can use a docker-compose file to deploy a stack composed by Photoprism and MariaDB to quickly get Photoprism running in our NAS. We can use Photoprism's default docker-compose yml file but we need to make a few cosmetic changes since Portainer only understands docker-compose version 2 syntax in standalone docker hosts.
- open Synology's File Station app and browse to the docker shared folder;
- create a folder named photoprism inside docker, which will persist relevant Photoprism's data in our local filesystem;
- inside photoprism folder, create three more folders: storage, originals and database.
- Open Portainer by visiting http://[YOUR-LOCAL-IP]:9000/;
- Click Stacks in the left menu, then Add stack, give it a meaningful name (for eg. Photoprism) and in the Web Editor place the below code, which was based on Photoprism's default docker-compose yml file but downgraded to compose version 2. BE SURE TO USE YOUR OWN [LOCAL-PORT], [YOUR-ADMIN-PASS], [YOUR-DB-PASS] and [YOUR-LOCAL-IP] BY CHANGING THE VALUES ACCORDINGLY, AND CHECK THE LOCAL VOLUMES PATHS TO MATCH THOSE DEFINED IN STEP 13.
version: '2' services: photoprism: image: photoprism/photoprism:latest security_opt: - seccomp:unconfined - apparmor:unconfined ports: - [LOCAL-PORT]:2342 environment: - PHOTOPRISM_HTTP_PORT=2342 - PHOTOPRISM_ADMIN_PASSWORD=[YOUR-ADMIN-PASS] - PHOTOPRISM_DEBUG=false - PHOTOPRISM_PUBLIC=false - PHOTOPRISM_READONLY=false - PHOTOPRISM_EXPERIMENTAL=true - PHOTOPRISM_DISABLE_WEBDAV=false - PHOTOPRISM_DISABLE_SETTINGS=false - PHOTOPRISM_DISABLE_TENSORFLOW=false - PHOTOPRISM_DETECT_NSFW=false - PHOTOPRISM_UPLOAD_NSFW=true - PHOTOPRISM_DATABASE_DRIVER=mysql - PHOTOPRISM_DATABASE_SERVER=mariadb:3306 - PHOTOPRISM_DATABASE_NAME=photoprism - PHOTOPRISM_DATABASE_USER=photoprism - PHOTOPRISM_DATABASE_PASSWORD=[YOUR-DB-PASS] - PHOTOPRISM_SITE_URL=http://[YOUR-LOCAL-IP]:[LOCAL-PORT] - PHOTOPRISM_SITE_TITLE=PhotoPrism - PHOTOPRISM_SITE_CAPTION=Browse Your Life - PHOTOPRISM_SITE_DESCRIPTION=Photoprism - PHOTOPRISM_SITE_AUTHOR=Photoprism volumes: - /volume1/docker/photoprism/originals:/photoprism/originals - /volume1/docker/photoprism/storage:/photoprism/storage mariadb: image: mariadb:10.5 restart: unless-stopped security_opt: - seccomp:unconfined - apparmor:unconfined command: mysqld --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=50 volumes: - /volume1/docker/photoprism/database:/var/lib/mysql environment: - MYSQL_ROOT_PASSWORD=[YOUR-DB-PASS] - MYSQL_DATABASE=photoprism - MYSQL_USER=photoprism - MYSQL_PASSWORD=[YOUR-DB-PASS]
- Click Deploy the stack. Give it a few minutes and PhotoPrism should be accessible in http://[YOUR-LOCAL-IP]:[LOCAL-PORT]/.
IMPORTANT: Synology automatically creates thumbnail files inside a special @eaDir directory when you upload media files such as images. To prevent Photoprism to index these files place a .ppignore file with the following content inside docker/photoprism/originals folder:
Step 4: configure a reverse proxy in your Synology NAS to access PhotoPrism over https / custom domain name¶
Synology allows you to configure a nginx reverse proxy to serve your applications over HTTPS. Configurations can be made in Diskstation manager Control Panel, Application Portal, Reverse proxy.: Click create. [Description] give it a meaningful name (for eg. Photoprism) [Protocol]=HTTPS [Hostname]=[YOUR-HOSTNAME] [Port]=[YOUR-PORT] (for eg. 2343) check Enable HSTS and HTTP/2 . under Destination [Protocol]=HTTP [Hostname]=[YOUR-LOCAL-IP][PORT]=[YOUR-PORT] (default is 2342) Last step under Custom Header.: Click create [Websocket] and hit OK (this step makes that your browser receive photo counts, log messages, or metadata updates).
IMPORTANT: make sure that you have forwarded the selected port (for eg. 2343) in your router: