All writing
16 min

NextDeploy VPS Deployment Guide: Zero-Downtime Linux Releases Grounded in Go

Deploy Next.js apps to any VPS with zero downtime, automatic SSL, and a daemon-managed release pipeline. No containers, no Kubernetes, no cloud lock-in — just SSH, systemd, and Caddy.


Deploy Next.js apps to any VPS with zero downtime, automatic SSL, and a daemon-managed release pipeline. No containers, no Kubernetes, no cloud lock-in — just SSH, systemd, and Caddy.

This document is the source of truth for VPS deployment infrastructure, grounded in the actual implementation. It focuses on what you do and what happens under the hood.

No containers, no Kubernetes, no cloud lock-in — just SSH, systemd, and Caddy driven by a dual-binary architecture.
⚡
Prerequisite — Install the NextDeploy CLI: Before provisioning servers or running release commands, ensure the CLI is installed on your workstation: Install via curl -fsSL https://hersi.dev/install.sh | bash (macOS/Linux) or irm https://hersi.dev/install.ps1 | iex (Windows). For architecture details, manual binaries, and setup verification, see the What is NextDeploy? Complete Installation Guide.

Architecture at a Glance

Diagram · System Flow
Rendering diagram...

Architecture:Two binaries, two roles:

  • nextdeploy (CLI) — Runs on your machine. Builds the Next.js app, uploads the tarball over SSH, and tells the daemon to deploy it. Never runs containers or touches the server's process manager directly.
  • nextdeployd (daemon) — Runs on the VPS as a systemd service. Receives signed commands over a Unix socket, orchestrates the release pipeline (extract, systemd unit, health check, Caddy config, atomic cutover), and manages lifecycle (status, logs, rollback, secrets, destroy).
  • Communication: The CLI SSHes into the server and runs sudo nextdeployd ship --tarball=<path>. The daemon subcommand is itself a socket client — it dials the running daemon, HMAC-signs the command, and sends it. The daemon verifies the signature, checks for replays, rate-limits, and dispatches.


    Quick Start

    bash· 16 lines
    1# 1. In your Next.js project:
    2nextdeploy init          # generates nextdeploy.yml
    3
    4# 2. Edit nextdeploy.yml — set your server IP, SSH key, and domain
    5
    6# 3. Provision the server (installs Node, Caddy, daemon, hardening):
    7nextdeploy prepare
    8
    9# 4. Point your domain's A record at the server IP
    10
    11# 5. Build and deploy:
    12nextdeploy ship
    13
    14# 6. Check on it:
    15nextdeploy status
    16nextdeploy logs

    1. Initialize a Project (nextdeploy init)

    What it does:

  • Validates the current directory is a Next.js project (checks for package.json with a next dependency).
  • Reads the app name from package.json and sanitizes it to a slug (^[a-z0-9-]+$, 3–63 chars).
  • Prompts for the target type: VPS, AWS serverless, or Cloudflare serverless.
  • For VPS: writes nextdeploy.yml from the VPS template, substituting your app name.
  • Optionally enables the Go sidecar.
  • What it does NOT do:

  • Does not scaffold a Dockerfile. VPS deploys use Next.js standalone output + systemd, not containers.
  • Does not create a .env or modify your next.config.js. You configure output: "standalone" yourself if you want that mode (VPS also supports default mode).
  • The generated nextdeploy.yml (VPS template):

    yaml· 19 lines
    1target_type: vps
    2
    3app:
    4  name: example-app          # slug, NOT a domain
    5  environment: production
    6  domain: app.example.com    # your public domain
    7  port: 3000                  # internal port the app listens on
    8
    9  gosidecar:
    10    enabled: false
    11    image_optimization: true
    12    isr_cache: true
    13    max_image_workers: 4
    14
    15servers:
    16  - name: "production-01"
    17    host: 1.2.3.4
    18    username: ubuntu
    19    key_path: ~/.ssh/id_rsa

    The template also includes commented-out blocks for logging, monitoring, backup, and webhooks. See Configuration Reference below for the full schema.

    Key fields to set before your first deploy:

    FieldPurpose
    app.nameThe app identifier — used for the systemd unit name, app directory, and Caddy fragment filename. Must be a slug.
    app.domainThe public domain Caddy will serve. Can be a bare hostname or a block with DNS provider info.
    app.portThe internal port your Node process listens on. Caddy proxies to this. Default: 3000.
    servers[].hostIP or hostname of your VPS.
    servers[].usernameSSH user (must have passwordless sudo).
    servers[].key_pathPath to your SSH private key.

    2. Prepare the Server (nextdeploy prepare)

    Provisions a fresh Linux VPS end-to-end. Every step checks before it changes, so re-running converges instead of redoing work.

    Default mode is "agent mode" — no Ansible, no Python on the target. The CLI SSHes to the server, downloads the latest nextdeployd binary from GitHub releases, installs it, and runs nextdeployd prepare on the server. The target needs only a shell and curl (or wget).

    Provisioning steps (in dependency order):

    StepWhat it installs/creates
    Base packagescurl, tar, ca-certificates, unzip (via apt/dnf/yum — auto-detected)
    Service usernextdeploy system group + user (shell: /sbin/nologin, no home)
    Directory tree/opt/nextdeploy/{apps,uploads,tmp} (0750, owned nextdeploy:nextdeploy)
    Node.js 22Via NodeSource signed repo (pinned major). Symlinked to /usr/local/bin.
    Corepackcorepack enable + pnpm@latest + yarn@stable. Symlinked to /usr/local/bin.
    Doppler CLIOptional — fetched from cli.doppler.com/install.sh. Failure is non-fatal.
    CaddyVia Cloudsmith apt repo or COPR (rpm), with a static-binary fallback. caddy user added to nextdeploy group for directory traversal.
    Coraza WAFCaddy binary replaced with one compiled with the Coraza WAF module (coraza-caddy/v2).
    Main CaddyfileSeeded at /etc/caddy/Caddyfile with order coraza_waf first + import /etc/caddy/nextdeploy.d/*.caddy.
    Daemon config/etc/nextdeployd/config.json with a random 32-byte HMAC secret (0600).
    Daemon unitnextdeployd.service — runs nextdeployd --foreground=true as root, ordered After=network.target caddy.service, with RuntimeDirectory=nextdeployd.
    Daemon socket/run/nextdeployd/nextdeployd.sock (0660, root:nextdeploy) — the whole local authorization model.
    Hardeningfail2ban with two jails: caddy-auth (repeated 401/403 in Caddy access log) and caddy-waf (Coraza interventions in audit log). Plus logrotate for /var/log/caddy/*.log.

    Flags:

    bash· 8 lines
    1nextdeploy prepare                    # default: agent mode, first configured server
    2nextdeploy prepare --all              # prepare every configured server
    3nextdeploy prepare --server prod-02   # prepare a specific server by name
    4nextdeploy prepare --skip-runtimes    # skip Node/Corepack (host manages runtimes)
    5nextdeploy prepare --skip-hardening   # skip fail2ban + logrotate
    6nextdeploy prepare --allow-root       # allow provisioning over root SSH (not recommended)
    7nextdeploy prepare --ansible          # legacy Ansible playbook (needs ansible-playbook + python3)
    8nextdeploy prepare --timeout 15m      # overall timeout (default: 10m)

    Requirements:

  • A Linux VPS (apt/dnf/yum based — Ubuntu, Debian, RHEL, AlmaLinux, Fedora, etc.)
  • A non-root SSH user with passwordless sudo
  • Your SSH key on the server
  • The server needs curl or wget and a shell — nothing else

  • 3. Build (nextdeploy build)

    Builds the Next.js app and packages it into app.tar.gz — the artifact the daemon deploys.

    The build flow (buildflow.Run):

  • 1. Incremental skip (unless --force): checks the git commit AND a config fingerprint. If both are unchanged, skips next build but still regenerates metadata and repackages the tarball — so the artifact always reflects the current config.
  • 2. Generate metadata: reads next.config, route manifests, and prerender manifests into metadata.json (app name, domain, output mode, detected features, git commit, package manager, port, health path, resource limits, sidecar config).
  • 3. Validate for target: serverless requires output: "standalone". Server Actions + export mode is rejected. VPS works with both standalone and default modes.
  • 4. Run next build if needed: if no valid standalone build exists, runs next build. If a valid build exists, trusts it. (Cloudflare forces --webpack; VPS uses your default bundler.)
  • 5. VPS artifact: for standalone mode, copies public/ → .next/standalone/public/, .next/static/ → .next/standalone/.next/static/, and metadata.json into the release directory. Then tars it to app.tar.gz.
  • 6. Bundle audit: warns at 200MB, flags at 250MB (Lambda's limit — checked for all targets as a future-proofing signal).
  • bash· 2 lines
    1nextdeploy build          # build + package
    2nextdeploy build --force  # force a full rebuild even if inputs are unchanged
    🔍
    nextdeploy inspect is a standalone read-only size audit of .next/standalone — no build, no side effects.

    4. Ship (nextdeploy ship)

    Builds (if needed), uploads, and triggers the daemon to deploy. This is the command you run.

    Step by step, from the CLI:

  • 1. Loads config, applies --environment override if set.
  • 2. Warns if the git working tree is dirty.
  • 3. Runs buildflow.Run — builds or reuses the cached build, packages app.tar.gz.
  • 4. Generates a Caddy config preview for logging.
  • 5. Opens an SSH connection to the deployment server.
  • 6. If a domain is set, generates a DNS guide (dns.md) telling you to point an A record at the server IP.
  • 7. Verifies the artifact exists and its embedded metadata.json app name matches cfg.App.Name — a stale-build guard.
  • 8. Uploads the tarball over SSH to /opt/nextdeploy/uploads/nextdeploy_<app>_<timestamp>.tar.gz (10-minute timeout).
  • 9. Triggers the daemon: sudo nextdeployd ship --tarball=<remotePath> --socket-path=/run/nextdeployd/nextdeployd.sock.
  • 10. Generates a visual deployment report with the DNS action item.
  • Flags:

    bash· 4 lines
    1nextdeploy ship                    # build + upload + deploy
    2nextdeploy ship --force            # force a full rebuild first
    3nextdeploy ship -e staging         # deploy to a named environment
    4nextdeploy ship -v                 # verbose deployment logs

    Zero-Downtime Deployment: How It Works

    This is the core of the system. The new release is started and health-checked on its own port BEFORE the current symlink and Caddy routing move. A failed deploy never leaves the server serving a broken release.

    Diagram · System Flow
    Rendering diagram...

    Step 1: Extract & validate

  • Extracts the tarball to a temp dir under /opt/nextdeploy/tmp/.
  • Reads metadata.json — validates app name (^[a-z0-9-]+$) and domain.
  • Acquires a per-app lock — serializes ship/rollback/destroy so symlink flips and port writes can't interleave. Fails fast rather than queueing.
  • Creates the release directory: /opt/nextdeploy/apps/<app>/releases/<timestamp>-<shortSha>.
  • Moves the unpacked content there (with a copy fallback for cross-device).
  • Fixes ownership: nextdeploy:nextdeploy, dirs 0750, files 0644, .env.nextdeploy stays 0600.
  • Step 2: Port allocation

  • Reuses the previous port (from state.json or the app's port file) if still available.
  • Otherwise finds a free port by binding a listener (reserves it), closes it before the service starts.
  • Persists the port to state.
  • Step 3: Render secrets

  • Renders /opt/nextdeploy/secrets/<app>.json into the release's .env.nextdeploy (plus any DOPPLER_TOKEN).
  • Fails hard — no release starts without its known secrets.
  • Step 4: Generate systemd unit

  • Unit name: nextdeploy-<app>-<releaseID>.service
  • User=nextdeploy, WorkingDirectory=<releaseDir>
  • ExecStart per output mode: standalone (/usr/local/bin/node server.js), default (/usr/local/bin/npm start or pnpm/yarn), export (no service generated — Caddy serves static files directly). If Doppler is configured: wrapped in doppler run --.
  • Environment=PORT=<port> NODE_ENV=production and EnvironmentFile=-<releaseDir>/.env.nextdeploy
  • Opt-in resource limits (cgroup directives) and heavy security sandboxing.
  • Runs systemctl daemon-reload
  • Step 5: Start & health check

  • systemctl enable --now <service>
  • Health check (waitForHealthy, up to 5 minutes with exponential backoff): Gate 1 (TCP dial — cheap liveness while the process is binding) and Gate 2 (HTTP GET on healthPath, default /, requiring status < 500 to catch processes that accept TCP but crash on every request).
  • Only proceeds if the health check passes.
  • Step 6: Sync static assets

  • Copies .next/static/ → /opt/nextdeploy/apps/<app>/shared_static/
  • So old client bundles keep loading hashed assets after the cutover (a user with a cached page still gets their JS/CSS).
  • Step 7: Go sidecar (optional)

  • If gosidecar.enabled and not export mode: starts a Go sidecar on its own port to serve eligible prerendered pages + image requests.
  • Failures fall back to Node-only (Caddy proxies directly to the Node port).
  • Step 8: Caddy fragment

  • Writes /etc/caddy/nextdeploy.d/<app>.caddy via commitFragmentSafely: supersedes any other app's fragment claiming the same domain, mirrors live fragments into a sandbox, validates the candidate Caddyfile with caddy validate, and only then atomically renames the fragment into the live dir.
  • Reloads Caddy (systemctl reload caddy, falls back to caddy reload).
  • Step 9: Atomic symlink flip (THE zero-downtime switch)

  • Creates current.tmp → new release directory.
  • os.Rename(current.tmp, current) — a single atomic rename on the same filesystem.
  • This is the cutover. The old service keeps running through the handoff.
  • Step 10: Cleanup

  • Writes the app port file, sets activationCommitted = true.
  • Stops the previous release's sidecar and removes old nextdeploy-<app>-*.service units.
  • Prunes to 5 retained releases, prunes unreferenced shared static assets, and deletes the uploaded tarball.
  • Rollback on failure

    A defer watches activationCommitted. If any step after a commit point fails, it restores the previous current symlink, restores the old Caddy fragment + reloads Caddy, stops the candidate sidecar, removes the candidate service, and restores the port state.

    🛡️
    The invariant: a failed deploy never changes what the server is serving.

    5. Status (nextdeploy status)

    Queries the daemon for the active service state:

    bash
    nextdeploy status
  • Finds the active service (nextdeploy-<app>-*.service — sorts by release ID, returns the latest active one).
  • Runs systemctl show --property=ActiveState,MainPID,MemoryCurrent.
  • Reports: Online / Failed / Offline + PID + memory usage.
  • Distinguishes "decommissioned" (app directory gone) from "not deployed yet".

  • 6. Logs (nextdeploy logs)

    Streams logs from the server. All over SSH — no log shipping agent needed.

    bash· 5 lines
    1nextdeploy logs                # app logs (journalctl -u <service> -f -n 50)
    2nextdeploy logs --route /api   # filter by route pattern (grep)
    3nextdeploy logs --audit        # daemon audit log (who ran what command)
    4nextdeploy logs --daemon       # daemon system log
    5nextdeploy logs --all          # all three streams simultaneously

    Log locations on the server:

    LogPathContent
    Appjournalctl -u nextdeploy-<app>-<releaseID>Next.js application output
    Daemon/var/log/nextdeployd/nextdeployd.logDaemon lifecycle events
    Audit/var/log/nextdeployd/audit.logEvery command: type, who ran it, success/failure
    Caddy access/var/log/caddy/access.logHTTP access (JSON format)
    Caddy WAF/var/log/caddy/audit.logCoraza WAF interventions
    Caddy debug/var/log/caddy/debug.logCoraza rule evaluation (level 1)

    7. Rollback (nextdeploy rollback)

    Reverts to a previous release. Uses the same activateRelease flow as a fresh ship — health check, Caddy, symlink flip, cleanup.

    bash· 3 lines
    1nextdeploy rollback              # roll back one step (the previous release)
    2nextdeploy rollback --steps 3    # roll back 3 steps (max 5, the retention limit)
    3nextdeploy rollback --to 7c8350a # roll back to a specific git commit (full or short SHA)

    How it works:

  • 1. Reads /opt/nextdeploy/apps/<app>/releases/ — release IDs are <timestamp>-<shortSha>, so lexical sort = chronological sort.
  • 2. Resolves the target: --steps N (the release N positions before the active one) or --to <commit> (walks releases newest-first, matching by release-dir suffix, falling back to reading metadata.json).
  • 3. Calls activateRelease with the chosen release directory — same health check + Caddy + symlink + cleanup as a fresh ship.
  • 4. --to and --steps are mutually exclusive. The old active release's service is stopped and cleaned up after the target release passes health checks.

  • 8. Secrets (nextdeploy secrets)

    Manage environment variables for your deployed app. VPS secrets are stored on the server at /opt/nextdeploy/secrets/<app>.json (0600, root only).

    bash· 7 lines
    1nextdeploy secrets set DATABASE_URL=postgres://...    # set one or more
    2nextdeploy secrets set API_KEY=xxx STRIPE_KEY=yyy      # set multiple at once
    3nextdeploy secrets get DATABASE_URL                     # get a value (plaintext)
    4nextdeploy secrets list                                 # list all secret names
    5nextdeploy secrets unset DATABASE_URL                   # remove one or more
    6nextdeploy secrets load                                 # load from .env file
    7nextdeploy secrets load .env.production                 # load from a specific file
  • set/unset re-render the active release's .env.nextdeploy from the secret store and hot-reload by restarting the active service — no re-deploy needed.
  • get returns the plaintext value; list returns sorted key names (no values).
  • load parses a local .env file and uploads all key-value pairs.
  • Values are quoted for systemd's EnvironmentFile parser.
  • Secrets are rendered into each new release's .env.nextdeploy at deploy time — a release never starts without its known secrets (hard failure).

  • 9. Destroy (nextdeploy destroy)

    Permanently removes the app and all its resources from the server. Destructive and guarded.

    bash· 4 lines
    1nextdeploy destroy              # interactive: type the app name to confirm
    2nextdeploy destroy --force      # override deletion_protection
    3nextdeploy destroy --yes         # skip the confirmation prompt
    4nextdeploy destroy -e staging    # destroy a specific environment

    What it removes:

  • 1. Stops the Go sidecar (if running).
  • 2. Finds and removes all nextdeploy-<app>-*.service systemd units.
  • 3. Removes the Caddy fragment + reloads Caddy.
  • 4. Deletes /opt/nextdeploy/apps/<app>/ entirely (all releases, current symlink, shared static, port file).
  • 5. Removes matching uploads and clears the port from state.
  • Guards:

  • deletion_protection: true in config blocks destroy unless --force is passed.
  • Interactive confirmation requires typing the exact app name (--yes skips the prompt for CI).
  • App name is validated before any filesystem operation (path traversal protection).

  • Environments

    Deploy isolated stacks of the same app using --environment / -e:

    bash· 3 lines
    1nextdeploy ship -e staging
    2nextdeploy ship -e pr-42
    3nextdeploy destroy -e staging
  • Validates the environment name: ^[a-z0-9][a-z0-9-]{0,30}[a-z0-9]$.
  • Sets cfg.App.Environment so all resource names namespace under it.
  • A preview/staging teardown can never reach production: different environment = different app directory, different systemd unit, different Caddy fragment.

  • Go Sidecar

    An optional Go binary that runs alongside your Node.js app to serve eligible prerendered pages and image requests without waking the Node process.

    yaml· 6 lines
    1app:
    2  gosidecar:
    3    enabled: true
    4    image_optimization: true   # serve optimized images (default: true)
    5    isr_cache: true             # cache ISR pages (default: true)
    6    max_image_workers: 4        # concurrent image workers (default: 4, max: 64)
  • The sidecar runs on its own port.
  • Caddy load-balances between the sidecar and Node: reverse_proxy localhost:<sidecarPort> localhost:<nodePort> with health checks.
  • Requests requiring middleware or SSR continue to use Node.js.
  • If the sidecar fails to start, the system falls back to Node-only (Caddy proxies directly to the Node port).
  • On daemon restart, RestoreSidecars re-activates sidecars for all apps that have them enabled.

  • Resource Limits

    Opt-in cgroup throttling for VPS deploys, mapped to systemd directives in the generated unit file:

    yaml· 5 lines
    1app:
    2  resources:
    3    cpu_quota: "80%"       # percentage (may exceed 100% on multi-core)
    4    memory_max: "1G"       # hard cap — OOM-killed past this
    5    memory_high: "800M"    # soft throttle — reclaim pressure, not a kill

    Values are validated against systemd's resource-control grammar before they reach the unit file (cpu_quota: ^[1-9][0-9]*%$, memory_max / memory_high: ^[0-9]+(\.[0-9]+)?([KMGT])?$), preventing a hostile or fat-fingered config from injecting arbitrary unit directives.


    SSL / TLS

    SSL is automatic via Caddy's built-in Let's Encrypt integration. No manual certificate handling.

  • The site address in the generated Caddy fragment is the bare domain; Caddy provisions and renews the certificate itself.
  • If the domain starts with www., both www.example.com and example.com are listed; otherwise example.com and www.example.com are both listed.
  • Caddy handles the ACME challenge, certificate storage, and auto-renewal.
  • DNS-01 challenges (wildcard certs): Configure the ssl_config or ssl block in nextdeploy.yml with a DNS provider and email:

    yaml· 6 lines
    1ssl_config:
    2  domain: "*.example.com"
    3  email: ops@example.com
    4  dns_provider: cloudflare
    5  wildcard: true
    6  staging: false   # use Let's Encrypt staging for testing
    🌐
    Before first deploy: Point your domain's A record at the server IP. The ship command generates a dns.md guide with the exact records to add.

    Security Model

    Daemon command authentication

    Every command sent to the daemon is HMAC-SHA256 signed:

  • 1. Rate limiting — default 10 req/s, burst 20, per client identity.
  • 2. IP allow-listing — TCP peers only. Unix socket peers bypass (already gated by filesystem permissions).
  • 3. HMAC signature verification — the command payload (type, args, timestamp, nonce) is signed with the shared secret from /etc/nextdeployd/config.json. Fails closed on empty secret.
  • 4. Replay protection — timestamp + nonce are part of the signed payload. Rejects stale (>5 min) or already-seen pairs.
  • Socket permissions

  • /run/nextdeployd/nextdeployd.sock — 0660, root:nextdeploy
  • Only root and the nextdeploy group can connect. This is the whole local authorization model.
  • systemd unit hardening

    Every app service runs with:

    layout· 16 lines
    ProtectSystem=strict
    ProtectHome=yes
    PrivateTmp=yes
    NoNewPrivileges=yes
    ProtectControlGroups=yes
    ProtectKernelModules=yes
    ProtectKernelTunables=yes
    RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
    RestrictNamespaces=yes
    RestrictRealtime=yes
    LockPersonality=yes
    ReadWritePaths=<releaseDir>
    KillMode=control-group
    TimeoutStopSec=10s
    FinalKillSignal=SIGKILL
    OOMPolicy=stop
  • ProtectSystem=strict makes the entire filesystem read-only except ReadWritePaths (the release dir).
  • KillMode=control-group + FinalKillSignal=SIGKILL guarantees fast, complete port release on rollout — no hung child process lingers.
  • Edge security (Caddy) & Path sanitization

  • Coraza WAF with OWASP CRS loaded (SecRuleEngine On, request body inspection, audit logging).
  • Security headers: HSTS, X-Content-Type-Options, X-Frame-Options, X-XSS-Protection, Referrer-Policy, Permissions-Policy, CSP (generated from detected features via nextcore.BuildCSP), plus zstd + gzip compression.
  • fail2ban jails: caddy-auth (repeated 401/403) and caddy-waf (Coraza interventions).
  • Path sanitization: Tarball paths must be within /opt/nextdeploy/uploads; app names and domains are strictly validated before any filesystem or Caddy operation.

  • Server Filesystem Layout

    layout· 46 lines
    /opt/nextdeploy/
    ├── apps/
    │   └── <app-name>/
    │       ├── releases/
    │       │   ├── 1730798400-7c8350a/    # immutable release directory
    │       │   ├── 1730802000-a1b2c3d/
    │       │   └── ...                     # up to 5 retained (pruned automatically)
    │       ├── current -> releases/<id>   # atomic symlink — THE active release
    │       ├── shared_static/              # synced .next/static (survives cutover)
    │       └── port                        # the port the active service is on
    ├── uploads/
    │   └── nextdeploy_<app>_<timestamp>.tar.gz  # uploaded tarballs (deleted after deploy)
    ├── tmp/                                 # unpack workspace
    └── secrets/
        └── <app>.json                       # secret store (0600, root only)
    
    /etc/nextdeployd/
    └── config.json                          # daemon config + HMAC secret (0600)
    
    /etc/caddy/
    ├── Caddyfile                            # main config (imports fragments)
    └── nextdeploy.d/
        └── <app>.caddy                      # per-app fragment (generated on deploy)
    
    /etc/systemd/system/
    ├── nextdeployd.service                  # the daemon
    └── nextdeploy-<app>-<releaseID>.service # app services (one per active release)
    
    /run/nextdeployd/
    └── nextdeployd.sock                     # Unix socket (0660, root:nextdeploy)
    
    /var/log/nextdeployd/
    ├── nextdeployd.log                      # daemon system log
    └── audit.log                            # command audit log
    
    /var/log/caddy/
    ├── access.log                           # HTTP access (JSON)
    ├── audit.log                            # Coraza WAF interventions
    └── debug.log                            # Coraza debug (level 1)
    
    /usr/local/bin/
    ├── nextdeployd                          # the daemon binary
    ├── node                                 # Node.js 22
    ├── npm / npx / pnpm / yarn              # package managers (via Corepack)
    ├── caddy                                # Caddy with Coraza WAF module
    └── doppler                              # Doppler CLI (optional)

    Configuration Reference

    The full nextdeploy.yml schema for VPS deployments. Only app and servers are required; everything else is opt-in.

    Core fields

    yaml· 36 lines
    1version: "1.0"
    2target_type: vps
    3
    4app:
    5  name: example-app                      # REQUIRED — slug (^[a-z0-9-]+$), 3-63 chars
    6  environment: production                 # REQUIRED — production | staging | development
    7  domain: app.example.com                # public domain (bare hostname or block)
    8  port: 3000                             # REQUIRED — internal app port
    9
    10  # Domain as a block (optional — for DNS guidance):
    11  # domain:
    12  #   name: app.example.com
    13  #   provider: cloudflare                # namecheap | cloudflare | other
    14  #   dns: auto                           # auto (provider API) | manual (print records)
    15  #   zone: example.com
    16
    17  deletion_protection: true               # guards `destroy` (default: false)
    18
    19  gosidecar:                              # optional Go sidecar
    20    enabled: false
    21    image_optimization: true
    22    isr_cache: true
    23    max_image_workers: 4
    24
    25  resources:                              # optional cgroup limits
    26    cpu_quota: "80%"
    27    memory_max: "1G"
    28    memory_high: "800M"
    29
    30servers:
    31  - name: "production-01"                # REQUIRED — friendly name
    32    host: 1.2.3.4                         # REQUIRED — IP or hostname
    33    username: ubuntu                      # REQUIRED — SSH user (needs passwordless sudo)
    34    key_path: ~/.ssh/id_rsa              # path to SSH private key
    35    # password: ""                        # optional (key_path takes precedence)
    36    # port: 22                             # optional SSH port

    Optional blocks (SSL, Logging, Monitoring, Backup, Webhooks)

    yaml· 45 lines
    1ssl_config:
    2  domain: "*.example.com"
    3  email: ops@example.com
    4  dns_provider: cloudflare               # for DNS-01 challenges
    5  wildcard: true
    6  staging: false                          # use Let's Encrypt staging for testing
    7  force: false                            # force re-issuance
    8
    9# Legacy ssl block (still supported):
    10ssl:
    11  enabled: true
    12  provider: letsencrypt
    13  email: ops@example.com
    14  auto_renew: true
    15
    16logging:
    17  enabled: true
    18  provider: nextdeploy
    19  stream_logs: true
    20  log_path: /var/log/containers/example-app.log
    21
    22monitoring:
    23  enabled: true
    24  cpu_threshold: 80
    25  memory_threshold: 75
    26  disk_threshold: 90
    27  alert:
    28    email: ops@example.com
    29    slack_webhook: https://hooks.slack.com/services/...
    30    notify_on: [crash, healthcheck_failed, high_cpu, high_memory]
    31
    32backup:
    33  enabled: true
    34  frequency: daily                        # hourly | daily | weekly
    35  retention_days: 7
    36  storage:
    37    provider: s3
    38    bucket: nextdeploy-backups
    39    region: us-east-1
    40
    41webhook:
    42  on_success:
    43    - curl -X POST https://your-api.com/deploy/success
    44  on_failure:
    45    - curl -X POST https://your-api.com/deploy/failure

    Command Quick Reference

    CommandWhat it does
    nextdeploy initScaffold nextdeploy.yml for your project
    nextdeploy prepareProvision a VPS (Node, Caddy, daemon, hardening)
    nextdeploy buildBuild + package app.tar.gz
    nextdeploy build --forceForce a full rebuild
    nextdeploy shipBuild + upload + deploy to VPS
    nextdeploy ship --forceForce rebuild then deploy
    nextdeploy ship -e <env>Deploy to a named environment
    nextdeploy statusShow active service state (PID, memory, status)
    nextdeploy logsStream app logs
    nextdeploy logs --route /apiFilter logs by route
    nextdeploy logs --allStream app + audit + daemon logs
    nextdeploy rollbackRoll back one step
    nextdeploy rollback --steps 3Roll back 3 steps
    nextdeploy rollback --to <sha>Roll back to a specific commit
    nextdeploy secrets set K=VSet secrets (hot-reloads the active service)
    nextdeploy secrets listList secret names
    nextdeploy secrets get KGet a secret value
    nextdeploy secrets unset KRemove secrets
    nextdeploy secrets loadLoad from .env file
    nextdeploy destroyRemove app + resources (guarded)
    nextdeploy destroy --forceOverride deletion_protection
    nextdeploy inspectRead-only bundle size audit

    Infrastructure simplicity is developer independence. True zero downtime requires disciplined, release-pinned state orchestration.