Core
Private repositories
The complete upstream guide to private repositories, synchronized with the product repository.
Product v0.22.0 · Complete source guide
Private Repository Deployment Guide
End-to-end playbook for deploying a private GitHub repository with NineDeploy — covers credential setup, build-pack selection, the auto-deploy webhook, and the three working methods (UI, CLI, REST API).
On GitHub, prefer the GitHub App (0.13+). Register one under Sources → GitHub Apps → Create GitHub App and install it on your repositories. Each deploy then clones with a short-lived token scoped to one repository, one App webhook deploys every linked service (no secret to paste per repository), and commit statuses and PR preview comments are available per service. Existing PAT services can be migrated without downtime and reverted. See GITHUB_APP.md.
PATs and deploy keys remain fully supported, and are still the way to go for GitLab, Bitbucket, Gitea and custom hosts. The rest of this guide covers them.
1. TL;DR (3 commands via CLI)
If you have the CLI installed and NINEDEPLOY_GITHUB_TOKEN exported, this is the entire flow:
# 1. Save the token once
ninedeploy sources add github-personal
# (it will pick up $NINEDEPLOY_GITHUB_TOKEN if set, otherwise prompt for it — masked)
# 2. One-shot deploy: source + service + env + first deploy, all from a URL
ninedeploy deploy create-from-github https://github.com/your-org/your-private-app
# 3. Wire up auto-deploy on every push
ninedeploy webhooks add <serviceId> main
# — returns the URL and a one-time secret; paste both into GitHub's webhook UIThat's it. The same flow works in the Web UI under New Service → Source and on the REST API.
2. The pieces, and what they do
| Piece | Purpose | Where it lives |
|---|---|---|
| Source (a.k.a. "Git credential") | An encrypted Personal Access Token (PAT) or SSH deploy key the panel uses to git clone private repos — or, since 0.13, a gh-app:<account> source generated by a GitHub App installation, which holds no token at all (GITHUB_APP.md) | Admin-only; created once, reused for every service. Stored in the sources table, AES-256-GCM encrypted. |
| Service | A long-lived definition of "the thing that deploys": repo URL, branch, port, build pack, env vars… | Created from a Source when the repo is private. |
| Build pack | How the source becomes a runnable image. auto picks Dockerfile when one is present, else Nixpacks. Set per-service. | service.build.buildPack |
| Webhook | An HMAC-signed endpoint GitHub POSTs to on every push. Triggers a deploy automatically. | Per-service; you paste the secret into GitHub once. |
A private repo always needs a Source. The other two are optional but recommended.
3. Create a GitHub Personal Access Token (PAT)
A GitHub App (GITHUB_APP.md) replaces this step entirely and is the recommended setup on GitHub. If you still use a token, you need a fine-grained PAT (recommended over classic) or a classic PAT.
Fine-grained PAT (recommended)
- Go to https://github.com/settings/personal-access-tokens/new (or for an org,
Settings → Developer settings → Personal access tokens → Fine-grained tokens). - Resource owner: pick your user or the org that owns the repo.
- Repository access:
- "All repositories" — simplest, deploys every repo this PAT can reach.
- "Only select repositories" — recommended for least-privilege; pick the specific repo(s) you plan to deploy.
- Permissions (least privilege that actually works):
- Repository → Contents: Read-only — the panel only ever clones & checks out; it never writes to your repo.
- Repository → Metadata: Read-only — required by GitHub for almost any call.
- Repository → Webhooks — not needed. With a PAT you paste the webhook secret manually; automatic webhook registration comes with the GitHub App (GITHUB_APP.md), not with a token.
- Click Generate token, copy the
github_pat_…value. GitHub will never show it again — paste it into NineDeploy immediately.
Classic PAT (only if fine-grained is blocked by tooling)
- https://github.com/settings/tokens/new (classic tab).
- Scopes:
repo— full read of private repos (includes everything else you need for cloning).admin:repo_hook— only required if you want NineDeploy to manage webhooks on your behalf; you can skip it and register the webhook manually in the GitHub UI.
- Generate, copy, paste.
SSH deploy key (alternative to a token)
If you prefer SSH:
- Generate an ed25519 key on your local machine:bash
ssh-keygen -t ed25519 -C "ninedeploy@your-host" -f ~/.ssh/ninedeploy_deploy - Add the public key as a Deploy key on the GitHub repo:
Settings → Security → Deploy keys → Add deploy key(read-only is enough; the panel never pushes). - Save the private key (the
.pubis useless without the matching private key) — paste its full contents (one line) into the Source's "SSH deploy key" field, or setNINEDEPLOY_SSH_KEYin the env when runningninedeploy sources add.
Gitea specifics (0.13+)
Create the Source with type gitea, a Gitea access token (read:repository, plus read:user for the live test), and the instance's base URL, e.g. https://git.example.com. The base URL enables the live token test (GET <base>/api/v1/user), the Deploy Wizard's repository list and its branch picker. Without it the source still clones, but the test answers "Set the Gitea base URL to enable the live test".
- Web UI: the Gitea base URL field on the create form, or Base URL · edit on the source card.
- CLI:
ninedeploy sources add gitea-home --base-url https://git.example.com(or answer the base-URL prompt). - API:
baseUrlonPOST /v1/sourcesandPATCH /v1/sources/:id(nullclears it).
The base URL must be https without credentials, query or fragment. A Gitea on a private (LAN) address is refused by the egress guard unless the server runs with NINEDEPLOY_ALLOW_PRIVATE_EGRESS=1, which also allows http.
Self-hosted GitLab
A gitlab source means gitlab.com unless it has a base URL. For a self-hosted instance, set the base URL to the instance's web root, including any relative URL path, e.g. https://gitlab.example.com or https://example.com/gitlab. The token needs read_api and read_repository.
The base URL is used for the live token test (GET <base>/api/v4/user), the Deploy Wizard's project list (<base>/api/v4/projects) and the branch picker. Projects in nested groups (group/subgroup/project) are supported. Set it the same way as for Gitea: the GitLab base URL field, ninedeploy sources add --base-url …, or baseUrl in the API. The https and private-address rules above apply too. When a node clones with the source (Allow on nodes), the credential is only sent to repositories on the base URL's host.
Bitbucket specifics
Create the Source with type bitbucket and a Bitbucket Cloud API token
(account → Settings → Security → API tokens — it authenticates as Bearer). The token
powers the repos/branches pickers and the connection test. For cloning:
- Deploy keys work over SSH: add the panel's public key under
repo → Settings → Access keys(Read permission) and use the SSH clone URL — this is the recommended path for private Bitbucket repos. - HTTPS token clones require the
x-token-authusername; if you paste an HTTPS URL, make sure the token type you stored matches that flow.
Bitbucket webhooks (repo:push, pullrequest:*, signed with the webhook
secret via X-Hub-Signature) drive auto-deploys and PR previews exactly like
the GitHub providers.
4. Add the credential to NineDeploy
Pick the method that fits:
4.1 Web UI (admins)
- Log in as an admin (members cannot create sources — by design).
- System → Sources (sidebar) → Add credential.
- Name: e.g.
github-personal. - Provider:
GitHub. - Auth kind:
token(orsshfor deploy keys). - Paste the token / key. Hit Save.
- The list now shows it with a green
Tokenbadge. The actual value is never shown again — only the boolean flag.
4.2 CLI
# Easiest: provide the token via env so the script can be non-interactive.
export NINEDEPLOY_GITHUB_TOKEN='github_pat_…'
ninedeploy sources add github-personal
# → "Provider (github | gitlab | gitea | registry | custom)" — choose github
# → "Auth kind (token | ssh)" — choose token
# → picks up $NINEDEPLOY_GITHUB_TOKEN automatically
# → "Default branch (used as suggestion only)" — main
# No env? The prompt is masked — your token never appears on screen or in
# ~/.bash_history (the prompt disables echo and only prints *).
ninedeploy sources add github-personal
# Verify it still works
ninedeploy sources test github-personal
# ✓ github token authenticates as your-handle (Your Name)
# List all
ninedeploy sources list4.3 REST API
curl -fsS -X POST https://your-ninedeploy.example.com/v1/sources \
-H "Authorization: Bearer $ND_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name":"github-personal","type":"github","token":"github_pat_…","defaultBranch":"main"}'
# → { "id": 1, "name": "github-personal", "type": "github", "hasToken": true, ... }The token is encrypted with the master key (AES-256-GCM) before it hits the database. It is decrypted only at the moment a git clone runs; the plaintext never touches the .git/config of the checked-out repo (the panel resets origin back to the clean URL after the clone).
4.4 Generate an SSH deploy key on the panel (recommended for private repos)
Instead of pasting a PAT, you can ask the panel itself to mint an ed25519 deploy-key pair. The private key never leaves the server (it's encrypted into the source row with AES-256-GCM); the panel only returns the public key and a fingerprint, which you paste once into the Git host's "Deploy keys" UI.
This is faster and more secure than the manual keygen workflow because:
- The operator never has to handle a private key file.
- The public key is recognizable in
~/.ssh/known_hostsreview (comment =ninedeploy@<source-name>). - The server can rotate the key on demand without any operator-side file management.
CLI:
# 1. Create the source (no credential needed yet)
ninedeploy sources add my-app --provider github # or: pick "ssh" when prompted
# 2. Ask the panel to generate the key pair
ninedeploy sources keygen 1
# → "Deploy key generated (fingerprint SHA256:abc…)."
# → Prints the public key, ready to copy.Web UI: open System → Sources, find the source card, click "Generate deploy key". The panel shows the public key, fingerprint, and a direct link to your Git host's "Deploy keys" page (GitHub: repo → Settings → Security → Deploy keys).
REST API:
curl -fsS -X POST https://your-ninedeploy.example.com/v1/sources/1/generate-deploy-key \
-H "Authorization: Bearer $ND_TOKEN"
# → { "publicKey": "ssh-ed25519 AAAA… ninedeploy@my-app", "fingerprint": "SHA256:…" }The response is the public key only. The private key lives encrypted on the source row and is decrypted only at the moment a git clone runs (same lifecycle as a stored PAT — the panel resets origin back to the clean URL after the clone, so the plaintext never lands in .git/config).
To rotate, run the same command again — the previous key is replaced and the old one stops working at the next clone.
Pin the Git host's SSH keys (0.15.8, optional)
By default every clone accepts the host key it is shown the first time within that deploy, and refuses one that changes while the deploy runs. Nothing is remembered between deploys, so a host that presents a different key next time goes unnoticed. A deploy-key source can instead pin the host keys:
ninedeploy sources pin-host-keys 3 on # switching on needs no password
ninedeploy sources host-keys 3 # the fingerprints it learnt
ninedeploy sources reset-host-keys 3 # forget them (asks for your password)
ninedeploy sources pin-host-keys 3 off # stop pinning (asks for your password)The same switch is on the source card (Sources → Pin git host keys). The first clone after switching it on learns the keys (after the clone succeeded, which only the holder of the deploy key can do); every later clone refuses a host whose key differs and says so in the deploy log (reason pinned host key changed). If the host really rotated its key, reset the pinned keys and deploy again; if you did not expect a change, do not: something may be intercepting the connection.
It applies to clones the panel makes with the SSH deploy key. A clone on a remote node keeps its own per-job policy. It is off for every existing source, and the panel shows fingerprints only, never the keys themselves.
4.4 Live credential check
Useful after a token rotation, or to debug "private repo deploys fail with 401":
# CLI
ninedeploy sources test 1
# API
curl -fsS -H "Authorization: Bearer $ND_TOKEN" https://your-ninedeploy.example.com/v1/sources/1/test
# → { "ok": true, "provider": "github", "login": "your-handle", "name": "Your Name" }
# or { "ok": false, "provider": "github", "status": 401, "error": "Bad credentials" }5. Deploy the private repo
5.1 Web UI (the one-click way)
- Services → New Service (the wizard button on the top right).
- Step 1 — Source:
- Pick Git repo as the source type.
- In the Source (Git Credential) dropdown, pick the credential you added in §4. (The new "Add credential" button right next to the dropdown does it inline if you skipped ahead.)
- The dropdown next to it lists the repos the credential can reach — pick yours, or paste the URL directly.
- The panel clones the repo on the server to framework-analyse it (a "Framework analysis" panel appears with detected language, package manager, suggested install/build/start commands, port, and whether a Dockerfile was found).
- Step 2 — Runtime: pick
docker(the default). Port is pre-filled from the analysis; tweak if your app actually listens on a different one. Build pack defaults toauto— see §6 for what that means. - Step 3 — Environment: add env vars (any
KEY=valuelines your app needs at runtime). - Step 4 — Resources: CPU shares, memory limit, persistent volume mount, direct host port (only if you must bypass Traefik).
- Step 5 — Review → Deploy.
You can also click Add webhook in the Review step — the wizard prints a GitHub-ready URL and a one-time secret.
5.2 CLI (one command)
ninedeploy deploy create-from-github https://github.com/your-org/your-appWhat this does, in order:
- Source resolution — picks the first matching GitHub credential, or creates one if you have none and
NINEDEPLOY_GITHUB_TOKENis set, or prompts you. - Clone & analyse — the panel server clones the repo, runs framework detection, and shows you:
- Language, Node version, package manager
- Detected framework (Next.js / Express / Vite / etc.)
- Has Dockerfile / Has compose file / Is monorepo
- Suggested
install,build,startcommands and port
- Confirm / override the build config (build pack, port, health path, custom commands).
- Env vars — keep typing
KEY+valuelines, leave key empty to stop. - Create the service.
- Trigger the first deploy (default yes).
- Optional webhook — one more
y/Nand it prints the URL + secret for GitHub.
You can also run it non-interactively for CI / scripts by setting env vars ahead of time and answering n to the prompts that the CLI can't infer:
NINEDEPLOY_GITHUB_TOKEN=... ninedeploy deploy create-from-github https://github.com/org/app5.3 REST API
# 1. Create the service with the source attached
curl -fsS -X POST https://your-ninedeploy.example.com/v1/services \
-H "Authorization: Bearer $ND_TOKEN" -H "Content-Type: application/json" \
-d '{
"name": "my-app",
"type": "docker",
"repoUrl": "https://github.com/your-org/your-app.git",
"branch": "main",
"sourceId": 1,
"port": 3000,
"healthPath": "/health",
"build": { "buildPack": "auto" }
}'
# 2. (optional) set env
curl -fsS -X POST https://your-ninedeploy.example.com/v1/services/42/env \
-H "Authorization: Bearer $ND_TOKEN" -H "Content-Type: application/json" \
-d '{"key":"DATABASE_URL","value":"postgres://…","isSecret":true}'
# 3. trigger the first deploy
curl -fsS -X POST https://your-ninedeploy.example.com/v1/services/42/deploys \
-H "Authorization: Bearer $ND_TOKEN" -H "Content-Type: application/json" -d '{}'6. How the build pack is chosen
buildPack: "auto" (the default) is the magic switch. The panel does, in this order:
- Is there a
Dockerfileat the configuredbaseDir? If yes →docker builddirectly with the BuildKit image builder. - Did the user pin a
dockerfilePath? (e.g.apps/api/Dockerfilefor a monorepo) — if that file exists, use it. - Otherwise, walk the repo up to 2 levels deep looking for any
Dockerfile. The closest one to the root wins. This makes a monorepo withapps/api/Dockerfileand a bare/package.json"just work" without the user having to set any field. - If no Dockerfile is found anywhere: fall through to Nixpacks (the buildpack used by Railway / Fly / Render), which auto-detects Node, Python, Go, Rust, Ruby, PHP, Java and produces a runnable image using your repo's own
package.json/requirements.txt/go.mod/ etc. For Node repos it also honorsengines.nodeand apnpm-lock.yaml/yarn.lock/package-lock.json/bun.lockblockfile to pick the install command.
If you ever need to override:
buildPack: "dockerfile"— forcedocker build, fail if no Dockerfile exists.buildPack: "nixpacks"— force buildpack-only, ignore any Dockerfile.buildPack: "railpack"— build with Railpack (Railway's successor to Nixpacks). Both install modes ship the pinned, checksum-verified Railpack CLI (the container image since 0.10.38), but Railpack builds through its own BuildKit client, so the panel also needs a BuildKit daemon: start one (docker run -d --name buildkit --restart unless-stopped --privileged moby/buildkit) and setBUILDKIT_HOST=docker-container://buildkitin the panel's environment (the install directory's.envon bare metal,-e/composeenvironment:for the container), then restart the panel. Until then the panel refuses the build pack with that fix named. On a remote node with agent v0.15.2 or newer, Railpack builds on the node itself, through the node's own BuildKit, and the panel needs noBUILDKIT_HOSTfor it. That needs the node's Docker to use the containerd image store, orNINEDEPLOY_AGENT_BUILDKIT_HOSTon the agent; otherwise build it on the panel. An older agent builds the repository Dockerfile instead (MULTI_NODE.md §4).buildPack: "paketo"/buildPack: "heroku"(G4.4) — build with Cloud Native Buildpacks through thepackCLI.- Builders: the Paketo base builder (amd64 hosts only) or the Heroku builder (
heroku/builder:24, amd64 and arm64). Each is pinned by digest, as the Nixpacks and Railpack CLIs are pinned by checksum. - Install: both install modes ship
pack0.40.9, checksum-verified. An older container image has nopack, and the panel refuses the build pack with that reason. - Where it builds: on the panel host only. A service that a node builds is refused when it is saved and again when it is deployed. Choose Build on: panel to build it there and ship the image to the node.
- Isolation:
packruns with--trust-builder=false, so the build phase (the repository's code) never shares a container with the Docker socket; only the analyze and export phases get it. - Build env: every service variable reaches the build through a private env file, never a command line. Buildpacks do not write them into the image config. A value that spans several lines cannot be passed and is left out, with a note in the log.
- Caches: each service keeps one pair of cache volumes,
nd-pack-ninedeploy_<slug>-buildandnd-pack-ninedeploy_<slug>-launch. They are removed when the service is deleted. - Containerd image store: buildpacks and Docker's containerd image store (the default for new Docker 29 installs) do not always work together. With the Heroku builder, any build env makes the export fail with
failed to fetch base layers. The deploy log then names the fix: turn the containerd image store off on the panel host ("features": {"containerd-snapshotter": false}in/etc/docker/daemon.json, then restart Docker), or usepaketo. Note that Railpack through a node's Docker needs that store on, so the two settings concern different hosts.
- Builders: the Paketo base builder (amd64 hosts only) or the Heroku builder (
The CLI's deploy create-from-github shows the analysis result and lets you override the choice interactively; the wizard does the same.
Build-time variables (0.16.1)
Nixpacks, Railpack, buildpacks (paketo, heroku) and the static pack see every variable of the service while they build, so NEXT_PUBLIC_* values are inlined by next build without any setup. A Dockerfile build receives only the variables you name under Service → Settings → Build → Build arguments (build.buildArgs in the API), each as --build-arg NAME=value. The Dockerfile reads them with ARG:
ARG NEXT_PUBLIC_API_URL
RUN npm run build- A listed name that has no value in the service's environment is skipped and named in the deploy log.
- Build arguments stay readable in the image's history (
docker history). Do not list credentials; use a BuildKit secret mount for those. A secret listed anyway is flagged in the log, and a build that pushes its image to a registry refuses it. - A Dockerfile build on a remote node passes them too when its agent has
docker.buildOptions(agent 0.18.10 or newer). The values travel inside the sealed request and are masked in the build output. An older agent builds without them, and the deploy log says so. - A service that fans out to more nodes ships the image built here to them (0.16.2), instead of having each node rebuild without the arguments.
Build stage of a multi-stage Dockerfile (0.16.2)
A Dockerfile with several stages builds its last stage by default. To ship another one, for example the runtime stage of a file whose last stage is a dev image, name it under Service → Settings → Build → Build stage (build.buildTarget in the API; "" or null clears it). The build runs docker build --target runtime.
FROM node:22 AS build
RUN npm ci && npm run build
FROM node:22-slim AS runtime
COPY --from=build /app/dist ./dist
FROM runtime AS dev
RUN npm i -g nodemon- A stage name starts with a letter and holds letters, digits,
_,.or-, as Docker requires. - The setting applies to Dockerfile builds only; Nixpacks and Railpack ignore it.
- A node builds the stage when its agent has
docker.buildOptions(agent 0.18.10 or newer). On an older agent a node build with a stage set is refused before anything is cloned, with the version to install: building the last stage instead would ship a different image. Fan-out nodes get the image built on the panel.
When to choose what
| Repo shape | Recommended buildPack | Why |
|---|---|---|
Single Dockerfile at the root | auto | Detects the Dockerfile, uses it. |
apps/api/Dockerfile in a monorepo, no other Dockerfile | auto | Walks 2 levels, finds it, no config needed. |
apps/api/Dockerfile in a monorepo, plus a Dockerfile in infra/ | auto + baseDir: "/apps/api" (or dockerfilePath: "apps/api/Dockerfile") | Stops the walker from picking the wrong one. |
| Plain Next.js / Express / Vite / SvelteKit / Astro with no Dockerfile | auto | Falls through to Nixpacks, no config needed. |
| Custom build that Nixpacks doesn't model (esoteric base image, complex multi-stage) | dockerfile | You write the Dockerfile, the panel runs docker build. |
Repo with a Dockerfile and a docker-compose.yml | Use type: "compose" instead of type: "docker" | Compose deploys run the full compose stack, not just one service. |
7. Set up the auto-deploy webhook
Without a webhook, deploys are manual (Deploy now button / ninedeploy services deploy <id> / POST /v1/services/:id/deploys). With one, every push to your branch triggers a fresh build.
7.1 Generate the webhook in NineDeploy
# CLI
ninedeploy webhooks add 42 main
# → URL: https://your-ninedeploy.example.com/v1/hooks/7
# → Secret: a1b2c3… (printed exactly once)The same works in the UI under Service → Webhooks → Add. The secret is stored encrypted; the CLI / UI only shows it once.
7.2 Register it in GitHub
- Repo → Settings → Webhooks → Add webhook.
- Payload URL: the URL printed by NineDeploy.
- Content type:
application/json. - Secret: the secret printed by NineDeploy.
- SSL verification: enabled (the panel sits behind Traefik with Let's Encrypt by default; if you run without TLS, set
NINEDEPLOY_PUBLIC_URLto anhttps://…you terminate elsewhere and front the panel with that). - Which events: "Just the push event." (PR events are also handled if you want preview environments — see DEPLOYMENTS.md §4).
- Active: ✓.
- Add webhook.
GitHub immediately sends a ping event; NineDeploy responds with { ok: "pong" } and the webhook shows green in the GitHub UI. Your next git push is the real test.
7.3 Watch-paths (monorepos)
If your monorepo contains multiple deployable apps, you almost certainly want the webhook to only fire for changes under your service's path. Add a watch path when creating the webhook:
ninedeploy webhooks add 42 main "apps/api/**\npackages/shared/**"Pushes that don't touch those globs (e.g. a docs-only commit) are silently ignored — no wasted builds.
You can also use [skip ci] or [skip cd] in the commit message to opt a specific commit out of auto-deploy, matching standard CI conventions.
When the Git server cannot reach the panel. A webhook needs a route from the Git server to this panel. For a repository on a private network, or a self-hosted Git server behind NAT, turn on Service → Settings → Git polling instead: the panel asks the Git server for the head of the branch on an interval you choose, and deploys a new commit as a push would. Watch paths and the skip markers do not apply to a poll, which reads the head and nothing else. Details are in the deployments guide, under Git polling.
7.4 Webhook smoke test
# Push a tiny commit:
git commit --allow-empty -m "chore: trigger deploy"
git push origin main
# Watch live in the CLI:
ninedeploy deploys watch 42 <deploymentId>
# (or: ninedeploy services logs 42, after the deploy finishes)
# In the UI:
# Service → Deploys → click the new row → live log streamIf the deploy never queues, the most common cause is wrong secret on the GitHub side: NineDeploy's HMAC-SHA-256 verification rejects the request with HTTP 401, but GitHub does not retry on 401. Re-paste the secret (start over: delete the webhook in both places, add it again).
8. Security notes
With a GitHub App there is no long-lived token at all: every clone mints a repository-scoped
contents: readtoken that expires within an hour and is never stored (GITHUB_APP.md §7).The token is encrypted at rest (AES-256-GCM, master key in
NINEDEPLOY_MASTER_KEYenv or the auto-generatedmaster.keyfile). The DB row only ever holds the ciphertext.The token is decrypted only at the moment a clone runs, and only inside the pipeline process — it never reaches the
.git/configof the checkout. After the clone, the panel resetsoriginback to the clean URL.Tokens are never logged. The runtime log sanitizer (in
lib/docker.ts) redacts common credential shapes (passwords, tokens,api_key=…,://user:pass@…) before anything is written to a deploy log.The webhook secret is also encrypted at rest, and the raw secret is only ever returned once at creation time. If you lose it, delete and recreate the webhook.
A PAT is read-only by default. NineDeploy never writes to your repo — it only clones, checks out a commit, and runs the build. You can use a
Contents: Readfine-grained PAT, or a classic PAT with only thereposcope (noworkflow, noadmin:org).For least-privilege, use a fine-grained PAT scoped to a single repo instead of a classic PAT that grants access to everything your user can see.
An SSH deploy-key source can pin the Git host's SSH keys so a host that later presents a different key is refused (§4.4). It is opt-in; switching it off or resetting the keys needs your password.
9. Troubleshooting quick links
- "Repository not found" at clone time → see TROUBLESHOOTING.md → Private repository 401/404 on clone.
- "Nixpacks CLI unavailable" at build time → see TROUBLESHOOTING.md → Nixpacks CLI not found.
- Auto-deploy never fires after a push → see TROUBLESHOOTING.md → Webhook signature rejected.
- The wizard detected no Dockerfile but there is one in a subdirectory →
buildPack: "auto"walks two levels deep; for deeper structures setbaseDirordockerfilePathexplicitly.
10. Private repositories on remote nodes
A service placed on a remote node clones its repository on that node. A PAT or deploy key never leaves the panel unless you allow it, so a deploy of such a service answers 400 remote_deploy_unsupported with two ways forward:
- Build on the panel (recommended). Service → Settings → Build → Build on: panel, or
PUT /v1/services/:id/placement {"buildOn": "panel"}(operator, panel 0.15.3). The panel clones and builds with the credential exactly as for a panel-host service, and only the built image travels to the node. - Allow the credential on nodes. System → Sources → Allow on nodes,
ninedeploy sources allow-on-nodes <id> on, orPATCH /v1/sources/:id {"allowOnNodes": true, "password": "…"}. It needs an interactive session and your password, and it is audited (source.allow_on_nodes). The node then receives the credential for one clone at a time:- it needs agent v0.15.2 or newer over the sealed transport (
422 node_agent_outdatedotherwise), and the node's owner can refuse every PAT and deploy key withNINEDEPLOY_AGENT_STATIC_CREDENTIALS=offon the agent; - a PAT goes into the git process's environment, never into a command line or
.git/config, and is redacted from the log; - a deploy key is written to a temporary directory in memory (
/dev/shm) for that one clone and removed afterwards; host keys are accepted on first use for that clone; - a
github,gitlaborbitbucketsource, or one with a base URL, is never sent to a repository on another host.
- it needs agent v0.15.2 or newer over the sealed transport (
While the clone runs, the PAT or key is on the node, and a PAT stays valid afterwards. Prefer option 1 for nodes you trust less than the panel. GitHub App repositories need neither: each node clone gets a short-lived token (GITHUB_APP.md §6). Turning the toggle off needs no password. See MULTI_NODE.md §6 for the details.
11. Commit statuses on GitLab, Gitea and Bitbucket
A service that clones through a GitLab, Gitea or Bitbucket token source can report each deploy on its commit, the way the GitHub App does for GitHub (GITHUB_APP.md §5). Turn it on under Service → Settings → Commit statuses, or with PUT /v1/services/:id/commit-status { "enabled": true } (service admin). In the SDK, use services.commitStatus.get and set.
What is sent
- When a deploy starts with a known commit, the commit is marked as running. When the deploy ends, it is marked success, failure or cancelled.
- The status is named
ninedeploy/<slug>. A PR preview reports through its parent's setting, asninedeploy/<parent-slug>/preview. - When the service has a domain, the status links to it.
| Provider | Request | Token |
|---|---|---|
| GitLab (gitlab.com or self-hosted) | POST /api/v4/projects/<path>/statuses/<sha> on the repository host | PRIVATE-TOKEN; needs the api scope |
| Gitea | POST /api/v1/repos/<owner>/<repo>/statuses/<sha> on the repository host | Authorization: token …; needs repository write |
| Bitbucket Cloud | POST https://api.bitbucket.org/2.0/repositories/<workspace>/<repo>/commit/<sha>/statuses/build | Authorization: Bearer …, a repository or workspace access token with repository write |
Limits and safety
- The token goes only to the repository's own host, which is the host the clone already sends it to. A self-hosted source with a base URL never reports to a repository on another host. Bitbucket Server and Data Center are not supported.
- A preview of a fork never reports: its commit is not in the parent's repository.
- Requests go through the egress guard. A git server on a private address needs
NINEDEPLOY_ALLOW_PRIVATE_EGRESS=1, as other outbound integrations do. - Statuses are observational. A provider that is down, or a token without the scope, is logged (without the token) and never fails or delays a deploy.
- The setting is the settings row
commit_status:<serviceId>; there is no migration. Changes are audited asservice.commit_status.enableandservice.commit_status.disable.
Source guide (installer links and live inventory counts are normalized for this site): docs/PRIVATE_REPO_GUIDE.md.