diff --git a/.env.example b/.env.example index 740dedf..9913f3f 100644 --- a/.env.example +++ b/.env.example @@ -9,7 +9,6 @@ AUTH_HEADER_EMAIL=X-authentik-email FORGEJO_BASE_URL= FORGEJO_TOKEN= FORGEJO_ORG= -PROJECTS_ROOT=$HOME/projects/$app CADDY_ROUTE_ENABLED=false CADDY_ADMIN_URL=http://localhost:2019 CADDY_SERVER_ID=srv0 diff --git a/README.md b/README.md index 2444709..fd910a0 100644 --- a/README.md +++ b/README.md @@ -38,10 +38,6 @@ 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`). @@ -83,9 +79,9 @@ 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 `/repo` if missing. + 1. Clone repo to `~/projects//repo` if missing. 2. Otherwise `fetch origin main` and `reset --hard origin/main`. - 3. Build binary to `/bin/app`. + 3. Build binary to `~/projects//bin/app`. 4. Restart the project user service via `systemctl --user restart`. Notes: @@ -105,8 +101,8 @@ Notes: ## Systemd For each project in workspace `` owned by unix user ``, the app writes: -- env file: `/.env` -- binary path used by systemd: `/bin/app` +- env file: `/projects//.env` +- binary path used by systemd: `/projects//bin/app` - unit file: `/.config/systemd/user/projectmgr--.service` Then it attempts as that unix user: @@ -115,6 +111,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=/app.sock` +- `LISTEN_ADDRESS=/projects//app.sock` If user systemd is not available in the runtime environment, project creation still succeeds and unit files are still generated. diff --git a/internal/app/config.go b/internal/app/config.go index 6b22c87..7a92ab1 100644 --- a/internal/app/config.go +++ b/internal/app/config.go @@ -8,7 +8,6 @@ import ( ) func loadConfig() (Config, error) { - projectRoot := strings.TrimSpace(getenv("PROJECTS_ROOT", "$HOME/projects/$app")) cfg := Config{ DatabaseURL: getenv("DATABASE_URL", "postgres://postgres:postgres@localhost:5432/box?sslmode=disable"), ListenAddr: getenv("LISTEN_ADDR", ":8080"), @@ -21,7 +20,6 @@ func loadConfig() (Config, error) { ForgejoBaseURL: strings.TrimRight(getenv("FORGEJO_BASE_URL", ""), "/"), ForgejoToken: getenv("FORGEJO_TOKEN", ""), ForgejoOrg: getenv("FORGEJO_ORG", ""), - ProjectRoot: projectRoot, CaddyAdminURL: strings.TrimRight(getenv("CADDY_ADMIN_URL", "http://localhost:2019"), "/"), CaddyServerID: getenv("CADDY_SERVER_ID", "srv0"), CaddyDomainSuffix: getenv("CADDY_DOMAIN_SUFFIX", ""), diff --git a/internal/app/paths.go b/internal/app/paths.go index 8555644..e04aae2 100644 --- a/internal/app/paths.go +++ b/internal/app/paths.go @@ -2,7 +2,6 @@ package app import ( "path/filepath" - "strings" ) func (a *App) projectDirFor(p Project) (string, error) { @@ -10,20 +9,5 @@ func (a *App) projectDirFor(p Project) (string, error) { if err != nil { return "", err } - tpl := strings.TrimSpace(a.cfg.ProjectRoot) - if tpl == "" { - tpl = "$HOME/projects/$app" - } - path := tpl - path = strings.ReplaceAll(path, "${HOME}", homeDir) - path = strings.ReplaceAll(path, "$HOME", homeDir) - path = strings.ReplaceAll(path, "${app}", p.Slug) - path = strings.ReplaceAll(path, "$app", p.Slug) - if strings.HasPrefix(path, "~/") { - path = filepath.Join(homeDir, strings.TrimPrefix(path, "~/")) - } - if !filepath.IsAbs(path) { - path = filepath.Join(homeDir, path) - } - return filepath.Clean(path), nil + return filepath.Clean(filepath.Join(homeDir, "projects", p.Slug)), nil } diff --git a/internal/app/types.go b/internal/app/types.go index 3cf4c86..eea6dd2 100644 --- a/internal/app/types.go +++ b/internal/app/types.go @@ -17,7 +17,6 @@ type Config struct { ForgejoBaseURL string ForgejoToken string ForgejoOrg string - ProjectRoot string CaddyAdminURL string CaddyServerID string CaddyDomainSuffix string