# Auto-starts the apf-portal local-dev infrastructure stack at boot.
#
# This is a TEMPLATE unit (note the trailing `@`). The instance name is the
# Linux username of the dev who owns the clone — the unit reads
# `/home/<user>/Works/apf_portal/infra/local/dev.compose.yml`.
#
# Install:
#   sudo cp docs/setup/systemd/apf-portal-infra@.service /etc/systemd/system/
#   sudo systemctl daemon-reload
#   sudo systemctl enable --now apf-portal-infra@$USER.service
#
# Override the working directory if your clone lives elsewhere:
#   sudo systemctl edit apf-portal-infra@$USER.service
#   # Add: [Service]
#   #      Environment="REPO=/custom/path/to/apf_portal"
#   #      WorkingDirectory=
#   #      WorkingDirectory=${REPO}
#   #      ExecStart=
#   #      ExecStart=${REPO}/infra/local/dev.sh up
#   #      ExecStop=
#   #      ExecStop=${REPO}/infra/local/dev.sh down

[Unit]
Description=apf-portal local infrastructure (postgres + redis + otel) for %i
Requires=docker.service
After=docker.service network-online.target
Wants=network-online.target

[Service]
Type=oneshot
RemainAfterExit=yes
User=%i
Group=%i
WorkingDirectory=/home/%i/Works/apf_portal
ExecStart=/home/%i/Works/apf_portal/infra/local/dev.sh up
ExecStop=/home/%i/Works/apf_portal/infra/local/dev.sh down
TimeoutStartSec=180
TimeoutStopSec=60

[Install]
WantedBy=multi-user.target
