Add notes service

This commit is contained in:
Wojciech Kozlowski 2022-11-20 15:10:07 +01:00
parent 260bc71939
commit 63f5ca366a
5 changed files with 106 additions and 0 deletions

View File

@ -17,6 +17,8 @@
- "data"
git:
- "data"
notes:
- "data"
tasks:
- include_tasks: tasks/services/b-user/service-user.yml

View File

@ -10,6 +10,8 @@
nextcloud: "25-fpm"
git:
gitea: "1"
notes:
joplin: "2"
tasks:
- import_tasks: tasks/services/c-deploy/00-hosts.yml

View File

@ -0,0 +1,35 @@
server {
listen 80;
server_name notes.wojciechkozlowski.eu;
location ^~ /.well-known {
allow all;
root /var/www/html;
}
location / {
return 301 https://$server_name$request_uri;
}
}
server {
listen 443 ssl;
server_name notes.wojciechkozlowski.eu;
ssl_certificate /etc/letsencrypt/live/notes.wojciechkozlowski.eu/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/notes.wojciechkozlowski.eu/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/notes.wojciechkozlowski.eu/chain.pem;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://pod-notes:22300;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}

View File

@ -0,0 +1,43 @@
[Unit]
Description=Podman container-notes-joplin.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
After=network-online.target
BindsTo=pod-notes.service
After=pod-notes.service
OnFailure=status-mail@%n.service
[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=on-failure
TimeoutStopSec=70
ExecStartPre=/bin/rm -f %t/container-notes-joplin.pid %t/container-notes-joplin.ctr-id
ExecStart=/usr/bin/podman run \
--conmon-pidfile %t/container-notes-joplin.pid \
--cidfile %t/container-notes-joplin.ctr-id \
--cgroups=no-conmon \
--pod-id-file %t/pod-notes.pod-id \
--replace \
--label "io.containers.autoupdate=image" \
-dt \
--add-host=pod-database:{{ services['database'].address }} \
-v /var/lib/yggdrasil/valkyrie-resolv.conf:/etc/resolv.conf:ro \
-v /var/lib/yggdrasil/data/pod-notes/data/_data:/data \
-e APP_BASE_URL="https://{{ services[service_name].domain }}" \
-e APP_PORT="22300" \
-e DB_CLIENT="pg" \
-e POSTGRES_PASSWORD="{{ services[service_name].database_password }}" \
-e POSTGRES_DATABASE="{{ services[service_name].database_name }}" \
-e POSTGRES_USER="{{ services[service_name].database_user }}" \
-e POSTGRES_PORT="5432" \
-e POSTGRES_HOST="pod-database" \
-e STORAGE_DRIVER="Type=Filesystem; Path=/data" \
--name=pod-notes-joplin \
docker.io/joplin/server:{{ versions.notes.joplin }}
ExecStop=/usr/bin/podman stop --ignore --cidfile %t/container-notes-joplin.ctr-id -t 10
ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/container-notes-joplin.ctr-id
PIDFile=%t/container-notes-joplin.pid
Type=forking
[Install]
WantedBy=multi-user.target default.target

View File

@ -0,0 +1,24 @@
[Unit]
Description=Podman pod-notes.service
Documentation=man:podman-generate-systemd(1)
Wants=network.target
After=network-online.target
Requires=container-notes-joplin.service
Before=container-notes-joplin.service
OnFailure=status-mail@%n.service
[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=on-failure
TimeoutStopSec=70
ExecStartPre=/bin/rm -f %t/pod-notes.pid %t/pod-notes.pod-id
ExecStartPre=/usr/bin/podman pod create --infra-conmon-pidfile %t/pod-notes.pid --pod-id-file %t/pod-notes.pod-id --name=notes --network=none --replace
ExecStart=/usr/bin/podman pod start --pod-id-file %t/pod-notes.pod-id
ExecStartPost=/usr/bin/sh -c 'podman inspect --format "{% raw %}{{ .State.Pid }}{% endraw %}" $(podman inspect --format "{% raw %}{{ .InfraContainerID }}{% endraw %}" notes) > /var/lib/{{ ansible_hostname }}/containers/pod-notes/pidfile'
ExecStop=/usr/bin/podman pod stop --ignore --pod-id-file %t/pod-notes.pod-id -t 10
ExecStopPost=/usr/bin/podman pod rm --ignore -f --pod-id-file %t/pod-notes.pod-id
PIDFile=%t/pod-notes.pid
Type=forking
[Install]
WantedBy=multi-user.target default.target