fix service templates and paths

This commit is contained in:
pavel 2026-05-14 20:21:01 +02:00
commit 3ac11468a1
7 changed files with 70 additions and 30 deletions

View file

@ -38,6 +38,10 @@ Important:
- `X-authentik-email`
- `FORGEJO_BASE_URL` + `FORGEJO_TOKEN` enable repository creation.
- `FORGEJO_ORG` switches creation from personal repos to org repos.
- `PROJECTS_ROOT` supports templates:
- `$HOME` = workspace unix user home
- `$app` = project slug
- Example: `$HOME/projects/$app`
- `UNIX_SOCKET_PATH` enables unix socket listener in addition to `LISTEN_ADDR`.
- `CADDY_ROUTE_ENABLED=true` enables route provisioning.
- `CADDY_ADMIN_URL` points to the Caddy Admin API (default `http://localhost:2019`).
@ -79,9 +83,10 @@ Route shape:
- If auto-provisioning cannot apply (for example external non-Forgejo repo), configure a webhook manually to call `webhook_url`.
- Deploy runs only when payload `ref` equals `refs/heads/main`.
- Deploy behavior:
1. Clone repo to `<PROJECTS_ROOT>/<app-user>/<workspace>/<project>/repo` if missing.
1. Clone repo to `<PROJECTS_ROOT>/repo` if missing.
2. Otherwise `fetch origin main` and `reset --hard origin/main`.
3. Restart the project user service via `systemctl --user restart`.
3. Build binary to `<PROJECTS_ROOT>/bin/app`.
4. Restart the project user service via `systemctl --user restart`.
Notes:
- `WEBHOOK_BASE_URL` should be set to an externally reachable base URL so Forgejo can call webhook endpoints.
@ -100,7 +105,8 @@ Notes:
## Systemd
For each project in workspace `<ws>` owned by unix user `<unix_user>`, the app writes:
- env file: `<PROJECTS_ROOT>/<app-user>/<workspace>/<project>/.env`
- env file: `<PROJECTS_ROOT>/.env`
- binary path used by systemd: `<PROJECTS_ROOT>/bin/app`
- unit file: `<home-of-unix-user>/.config/systemd/user/projectmgr-<app-user>-<project>.service`
Then it attempts as that unix user:
@ -109,6 +115,6 @@ Then it attempts as that unix user:
The generated `.env` is synced from the project env-var configuration and always includes:
- `LISTEN_NETWORK=unix`
- `LISTEN_ADDRESS=<PROJECTS_ROOT>/<app-user>/<workspace>/<project>/app.sock`
- `LISTEN_ADDRESS=<PROJECTS_ROOT>/app.sock`
If user systemd is not available in the runtime environment, project creation still succeeds and unit files are still generated.