Deploy the nSelf stack to a named remote environment over SSH. Pairs with nself promote for environment-promotion workflows.
# Deploy to production
nself deploy prod
# Deploy to staging
nself deploy staging
# Check what would be deployed (dry run)
nself deploy prod --dry-runnself deploy <ENV_NAME> [FLAGS]nself deploy SSHes into the host configured for the target environment, copies the generated Docker Compose config, pulls updated images, and restarts services with zero-downtime rolling logic. The environment name is a positional argument — any environment defined in your env cascade (e.g. staging, prod, eu-prod) is a valid target.
Before deploying, the CLI runs nself doctor against the target environment and blocks if critical checks fail. Pass --skip-doctor to bypass (not recommended for production).
After a successful deploy, run nself deploy prod status to verify all services are healthy, or use nself promote staging prod to promote a tested staging build forward.
Deploy to the named environment. The env name maps to NSELF_DEPLOY_HOST and SSH key configuration.
nself deploy prod
nself deploy staging
nself deploy eu-prodCheck the live health of a deployed environment without running a new deploy.
nself deploy prod status
# ✓ PostgreSQL healthy (5 connections)
# ✓ Hasura healthy (GraphQL endpoint responding)
# ✓ Auth healthy
# ✓ Nginx healthy (SSL valid)Tail service logs from the remote host.
nself deploy prod logs
nself deploy prod logs --service postgres --tail 100Roll back to the previous deploy on the remote host.
nself deploy prod rollbackPromote the current environment to another (shorthand for nself promote).
nself deploy staging promote prodVerify SSH connectivity and permissions for the target host before a deploy.
nself deploy prod check-access
# ✓ SSH connection to 5.75.235.42 successful
# ✓ Docker accessible on remote
# ✓ Required directories writableRun a post-deploy health check on the remote environment.
nself deploy prod health| Flag | Type | Default | Description |
|---|---|---|---|
--dry-run | bool | false | Show what would be deployed without making changes |
--skip-doctor | bool | false | Skip pre-deploy doctor check (not recommended for prod) |
--force | bool | false | Force deploy even if doctor detects issues |
--no-pull | bool | false | Skip Docker image pull (use cached images) |
--timeout | int | 300 | Seconds to wait for services to become healthy |
--ssh-key | string | Path to SSH private key (overrides NSELF_SSH_KEY) | |
--host | string | Override the deploy host (overrides NSELF_DEPLOY_HOST) | |
--service | string | Deploy or tail logs for a specific service only | |
--tail | int | 50 | Number of log lines to tail (logs subcommand) |
| Variable | Description |
|---|---|
NSELF_DEPLOY_HOST | Remote host for the target environment (e.g. 5.75.235.42) |
NSELF_SSH_KEY | Path to SSH private key used to connect to deploy host |
NSELF_SSH_USER | SSH user on the remote host (default: root) |
NSELF_DEPLOY_DIR | Remote directory where compose files are placed (default: /opt/nself) |
# Verify SSH access first
nself deploy prod check-access
# Preview what changes
nself deploy prod --dry-run
# Deploy
nself deploy prod
# Verify all services healthy
nself deploy prod health# Test on staging first
nself deploy staging
nself deploy staging health
# Promote the tested build to prod
nself promote staging prodnself deploy prod rollback
# Reverts to the previous compose snapshot on the remote hostnself deploy prod --ssh-key ~/.ssh/nself_deploy_ed255190 — deploy succeeded, all services healthy1 — deploy failed (SSH error, image pull failed, service unhealthy)2 — doctor check failed and --skip-doctor not passed3 — invalid arguments or unknown environment name