Bare/host (non-Docker) deploys don't inject project env vars into the systemd unit
Bug
Env vars saved via PATCH /api/projects/:id/env (or openship project env set) never reach
the running process for a self-hosted, non-Docker ("bare") deployment. The app starts and
crashes/misbehaves as if no env vars were ever configured.
Repro
openship project create --name demo --framework nextjs --git-owner <owner> --git-repo <repo> --port 3000
openship project env set <projectId> --set "SOME_KEY=some-value" --secret
openship api /deployments/build/access -X POST -d '{
"projectId": "<projectId>",
"deployTarget": "server",
"serverId": "<serverId>",
"buildStrategy": "server",
"publicEndpoints": []
}'
The deployment reaches ready, but the generated systemd unit
(/etc/systemd/system/openship-<deploymentId>.service) only contains:
Environment=PORT=3000
Environment=NODE_ENV=production
None of the project's saved env vars are present, and there's no .env/EnvironmentFile=
written into the release directory either
(/opt/openship/releases/<deploymentId>/) — only the repo's own .env.example is there.
packages/adapters/src/runtime/supervisor/systemd.ts does support writing arbitrary
Environment= lines from opts.env (confirmed by reading the source), so the unit
generator itself works — the deploy pipeline just isn't passing the project's stored env
vars into that opts.env for this (bare/server-build) path.
Workaround
Passing envVars directly in the POST /deployments/build/access body (instead of relying
on the previously-saved project env vars) works — those DO make it into the unit's
Environment= lines. So the fix is presumably: read the project's saved env vars (same
source project/env reads from) when building the deployment snapshot for a bare/server
target, the same way envVars passed inline already works.
Related (same session)
While debugging this I also hit a full pipeline stall unrelated to env vars: redeploying a
project whose previous deployment is still holding the same port produces a dashboard-only
"free the port?" prompt (promptUser / PROMPT_TIMEOUT_MS = 5 * 60 * 1000 in
session-manager.ts) that has no CLI/API equivalent — calling build/access headlessly (no
dashboard tab open to answer the SSE prompt) just hangs in "deploying" for the full 5
minutes and then fails with "Prompt timed out - no response from user". Manually
systemctl stop-ing the old unit before redeploying avoids it. Filing this note here rather
than as a separate issue since it's a UX gap (no CLI prompt-response support) rather than a
clear-cut bug — happy to split it out if useful.
Env: macOS host (Apple Silicon) driving a fresh Ubuntu 24.04 arm64 target over SSH, openship 0.1.11 (latest on npm), self-hosted/desktop mode, no cloud account connected.
Opened a fix: #48 — requestBuildAccess now falls back to repos.project.getEnvMap() when the deploy request has no inline envVars, mirroring the fallback triggerDeployment already has. That was the actual divergence: the systemd unit generator and BareRuntime.deploy() were both fine, requestBuildAccess just never read the project's saved env table before creating the queued deployment.