photoview: add config

main
Jef Roosens 2024-10-01 14:28:28 +02:00
parent 56faa4323b
commit ad36788772
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
12 changed files with 191 additions and 13 deletions

View File

@ -21,6 +21,9 @@
[ntfyserver] [ntfyserver]
192.168.0.3 static_ip=192.168.0.3 192.168.0.3 static_ip=192.168.0.3
[nefarious]
192.168.0.3 static_ip=192.168.0.3
[matrix] [matrix]
192.168.0.2 static_ip=192.168.0.2 192.168.0.2 static_ip=192.168.0.2
@ -29,3 +32,12 @@
[gitea] [gitea]
192.168.0.2 static_ip=192.168.0.2 192.168.0.2 static_ip=192.168.0.2
[kanboard]
192.168.0.2 static_ip=192.168.0.2
[baikal]
192.168.0.2 static_ip=192.168.0.2
[photoview]
192.168.0.3 static_ip=192.168.0.3

24
nas.yml
View File

@ -56,12 +56,12 @@
- woodpecker - woodpecker
tags: woodpecker tags: woodpecker
- name: Install Lander - name: Install Restic
hosts: nas hosts: nas
become: yes become: yes
roles: roles:
- lander - restic
tags: lander tags: restic
- name: Install Restic REST server - name: Install Restic REST server
hosts: nas hosts: nas
@ -70,21 +70,21 @@
- restic-rest - restic-rest
tags: restic-rest tags: restic-rest
- name: Install Restic - name: Install Lander
hosts: nas hosts: nas
become: yes become: yes
roles: roles:
- restic - lander
tags: restic tags: lander
- hosts: nas
become: yes
roles:
- matrix
tags: matrix
- hosts: nas - hosts: nas
become: yes become: yes
roles: roles:
- nefarious - nefarious
tags: nefarious tags: nefarious
- hosts: nas
become: yes
roles:
- photoview
tags: photoview

View File

@ -0,0 +1,3 @@
---
dependencies:
- role: caddy

View File

@ -0,0 +1,9 @@
---
- name: Ensure Caddyfile is present
template:
src: 'photoview.Caddyfile.j2'
dest: '/etc/caddy/photoview.Caddyfile'
owner: root
group: root
mode: '0644'
notify: caddy-reload

View File

@ -0,0 +1,3 @@
photos.roosens.me {
reverse_proxy {{ hostvars[groups['photoview'][0]].static_ip }}:8012
}

View File

@ -0,0 +1,35 @@
services:
app:
image: 'viktorstrate/photoview:2.4.0'
restart: 'always'
depends_on:
db:
condition: service_healthy
environment:
PHOTOVIEW_DATABASE_DRIVER: 'postgres'
PHOTOVIEW_POSTGRES_URL: 'postgres://photoview:photoview@db/photoview?sslmode=disable'
ports:
- '8012:80'
volumes:
- '/etc/localtime:/etc/localtime:ro'
- '/etc/timezone:/etc/timezone:ro'
- '/mnt/data1/photoview/cache:/home/photoview/media-cache'
- '/mnt/data1/photos:/photos:ro'
db:
image: 'postgres:17.0-alpine'
restart: 'always'
healthcheck:
test: ["CMD", "pg_isready", "-U", "photoview"]
interval: 10s
start_period: 30s
environment:
POSTGRES_USER: 'photoview'
POSTGRES_PASSWORD: 'photoview'
POSTGRES_DB: 'photoview'
volumes:
- '/mnt/data1/photoview/postgres:/var/lib/postgresql/data'

View File

@ -0,0 +1,5 @@
cd /etc/photoview
/usr/bin/docker compose exec -T db pg_dump -U photoview photoview |
/usr/bin/gzip --rsyncable |
/usr/local/bin/restic backup --stdin --stdin-filename photoview-postgres.sql.gz

View File

@ -0,0 +1,13 @@
[Unit]
Description=Photo gallery for self-hosted personal servers
After=docker.service
Requires=docker.service
[Service]
Type=exec
WorkingDirectory=/etc/photoview
ExecStart=/usr/bin/docker compose up
ExecStop=/usr/bin/docker compose down
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,5 @@
---
- name: 'restart photoview'
ansible.builtin.service:
name: 'photoview'
state: 'restarted'

View File

@ -0,0 +1,69 @@
---
- name: Ensure data directory is present
ansible.builtin.file:
path: '/mnt/data1/photoview'
state: directory
mode: '0755'
owner: 'root'
group: 'root'
- name: Ensure data subvolumes are present
community.general.btrfs_subvolume:
name: '/photoview/{{ item }}'
loop:
- 'postgres'
- 'cache'
- name: Ensure subvolume permissions are correct
ansible.builtin.file:
path: "/mnt/data1/photoview/{{ item }}"
state: directory
mode: '0755'
owner: '999'
group: '999'
loop:
- 'cache'
- name: Ensure configuration directory is present
ansible.builtin.file:
path: '/etc/photoview'
state: directory
mode: '0755'
- name: Ensure compose file is present
ansible.builtin.copy:
src: 'compose.yml'
dest: '/etc/photoview/compose.yml'
mode: '0644'
owner: 'root'
group: 'root'
notify: 'restart photoview'
- name: Ensure backup scripts are present
ansible.builtin.copy:
src: "photoview.{{ item }}.backup.sh"
dest: "/etc/backups/photoview.{{ item }}.backup.sh"
owner: 'root'
group: 'root'
mode: '0644'
loop:
- 'postgres'
- name: Ensure service file is present
ansible.builtin.copy:
src: 'photoview.service'
dest: '/lib/systemd/system/photoview.service'
owner: 'root'
group: 'root'
mode: '0644'
register: res
- name: systemd-reload
ansible.builtin.systemd_service:
daemon_reload: true
when: 'res.changed'
- name: Ensure photoview service is enabled
ansible.builtin.service:
name: 'photoview'
enabled: true

View File

@ -63,3 +63,15 @@
roles: roles:
- gitea - gitea
tags: gitea tags: gitea
- hosts: ruby
become: yes
roles:
- kanboard
tags: kanboard
- hosts: nas
become: yes
roles:
- matrix
tags: matrix

14
web.yml
View File

@ -51,4 +51,16 @@
become: yes become: yes
roles: roles:
- gitea-web - gitea-web
tags: atuin tags: gitea
- hosts: web
become: yes
roles:
- kanboard-web
tags: kanboard
- hosts: web
become: yes
roles:
- photoview-web
tags: photoview