dotfiles/roles/forgejo/templates/forgejo.container
Matej Focko 737acfde87
fix: require postgresql for forgejo and vaultwarden
Storing data for Forgejo and Vaultwarden in the postgres database results
in a rather wonky behavior during restarts of the VPS and potential
restarts of the postgres itself.

Based on some observations Forgejo is capable of recovering from such
issues, but Vaultwarden falls into a retry loop trying to reconnect to
the database while failing on resolving the hostname / connecting, e.g.,

    [2024-11-27 16:52:43.646][r2d2][ERROR] connection to server at "host.containers.internal" (XXX.XXX.XXX.XXX), port 5432 failed: Connection refused

Therefore adjust the quadlet definitions to require and boot containers
»after« the postgres is running to minimalize the possible issues.

Signed-off-by: Matej Focko <me@mfocko.xyz>
2024-11-27 17:57:35 +01:00

30 lines
625 B
Text

# {{ ansible_managed }}
[Unit]
Description=Forgejo
After=postgresql.service
Requires=postgresql.service
[Container]
ContainerName=forgejo
Image=codeberg.org/forgejo/forgejo:9
AutoUpdate=registry
Environment=USER_UID=1000
Environment=USER_GID=1000
Environment=TZ=Europe/Prague
Environment=START_SSH_SERVER=true
Environment=SSH_CREATE_AUTHORIZED_PRINCIPALS_FILES=true
Environment=SSH_AUTHORIZED_PRINCIPALS_ALLOW="username,email"
Network=forgejo.network
PublishPort={{ forgejo_ssh_port }}:22
PublishPort={{ forgejo_http_port }}:3000
Volume=forgejo-data:/data
[Service]
Restart=always
[Install]
WantedBy=multi-user.target