photoview: add config
This commit is contained in:
parent
56faa4323b
commit
ad36788772
12 changed files with 191 additions and 13 deletions
35
roles/photoview/files/compose.yml
Normal file
35
roles/photoview/files/compose.yml
Normal 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'
|
||||
5
roles/photoview/files/photoview.postgres.backup.sh
Normal file
5
roles/photoview/files/photoview.postgres.backup.sh
Normal 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
|
||||
13
roles/photoview/files/photoview.service
Normal file
13
roles/photoview/files/photoview.service
Normal 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
|
||||
5
roles/photoview/handlers/main.yml
Normal file
5
roles/photoview/handlers/main.yml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
- name: 'restart photoview'
|
||||
ansible.builtin.service:
|
||||
name: 'photoview'
|
||||
state: 'restarted'
|
||||
69
roles/photoview/tasks/main.yml
Normal file
69
roles/photoview/tasks/main.yml
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue