Repository navigation
Guide Custom Services
Add up to 10 custom Docker services (CS_1 through CS_10) to your ɳSelf stack. Use this for app-specific services that aren't covered by the plugin ecosystem.
Each service needs a nonempty CS_N=name:template[:port][:route] definition. ɳSelf reads its supported CS_N_* overrides and generates the corresponding Docker Compose service block on nself build. Overrides alone do not register a service.
# CS_1: an existing application image containing /app/server.js
CS_1=my-api:node:3100:api
CS_1_IMAGE=registry.example.com/my-api:1.0.0
CS_1_COMMAND=node server.js
# Pass environment variables to the service
CS_1_ENV=NODE_ENV=production
# DATABASE_URL is injected automatically.The image must set its own working directory (for example WORKDIR /app in its Dockerfile) and provide a /health endpoint plus wget, or set CS_1_HEALTHCHECK to a suitable probe. CS_N_ENABLED, CS_N_NAME, CS_N_WORKDIR, and arbitrary CS_N_ENV_* keys are not read. Remove the CS_N definition to stop generating that slot.
nself build # generates updated docker-compose.yml
nself start # creates/recreates containers from the generated confignself status # should show my-api as running
nself logs -f -S my-api # follows logs by the Compose service nameThe route api exposes the service at api.<BASE_DOMAIN> by default. Omit the route for a service without an Nginx route.
The custom-service scaffolder supports go, node, python, static, rust, and other:
nself service add --help # doc-check: skip registered in cmd/commands/service.go; no command-signature fixture yetUse nself service add <name> --template <language> to create services/<name>/ and register the next free slot in .env.dev. See Config-Custom-Services for healthcheck setup.
CS_2=worker:python:8002
# An existing image containing Celery and the application's worker code
CS_2_IMAGE=registry.example.com/worker:1.0.0
CS_2_COMMAND=python -m celery worker
CS_2_ENV=CELERY_BROKER_URL=redis://redis:6379/0
CS_2_HEALTHCHECK=disabledThis example requires Redis to be enabled and reachable at the configured broker URL; include its credentials if required. Use a worker-specific probe instead of disabled when one is available.
A service in a monorepo often needs the whole workspace as its build context (shared packages, a lockfile at the root) while its Dockerfile lives deep inside. Four keys express that, with no hand-written compose file:
# Project at <repo>/apps/api. The repository root is two levels up.
CS_1=worker:node:9500
CS_1_PATH=../..
CS_1_DOCKERFILE=apps/api/services/worker/Dockerfile
CS_1_BUILD_TARGET=runtime
CS_1_ENV_FILE=.env.dev,.env.secrets
CS_1_DEPENDS_ON=hasura:healthy
CS_1_COMMAND=node dist/server.jsWhat nself build generates for it: build context ../.. with that Dockerfile and target, depends_on for postgres and hasura (both service_healthy), the command as a list, and the environment from both files with .env.secrets winning on a repeated key.
Because the build context is the repository root, the builder receives everything under it. Put a .dockerignore at that root with the lines **/.env* and **/.secrets (a bare .env* only matches the root, so nested .env files would still be sent). nself build refuses an ancestor context without one (E528), and refuses a context above the directory that holds .git.
nself buildCS_N_DEPENDS_ON accepts the name of any service an installed plugin adds, so a service can wait for it:
CS_2=reports:node:9501
CS_2_DEPENDS_ON=claw-api:startedThe name is resolved after the plugin step of nself build. A name that does not exist fails the build with E500.
A third-party stack that has several containers (a message broker and a UI, say) maps to one CS_N definition with CS_N_IMAGE per container, or to a plugin when one exists. Services already share the default project network. To attach an extra network, use CS_N_NETWORKS=<PROJECT_NAME>_shared and create it before starting the stack. For PROJECT_NAME=myapp:
docker network create myapp_sharedSet CS_N_NETWORKS=myapp_shared on each service that needs it. The generator declares these extra networks external; it does not create them. See Custom-Services-Migration for what CS_N does not cover yet.
| Variable | Description |
|---|---|
CS_N |
Required definition: name:template[:port][:route]
|
CS_N_IMAGE |
Docker image reference |
CS_N_PORT |
Internal port the service listens on |
CS_N_COMMAND |
Override container command (exec form, split on whitespace, no shell) |
CS_N_PATH |
Build context: a path inside the project, or an ancestor such as ../.. (see Config-Custom-Services) |
CS_N_DOCKERFILE |
Dockerfile path relative to the build context |
CS_N_BUILD_TARGET |
Multi-stage build target |
CS_N_ENV_FILE |
One or more dotenv files, comma-separated, later wins |
CS_N_DEPENDS_ON |
name[:started|healthy|completed], comma-separated |
CS_N_NETWORKS |
Extra <PROJECT_NAME>_* networks (must already exist) |
CS_N_ENV |
Comma-separated KEY=VALUE pairs passed to the service |
CS_N_ENV_PASSTHROUGH |
Comma-separated allowlist of project environment variables to forward |
CS_N_HEALTHCHECK |
Probe path, CMD/CMD-SHELL command, or disabled
|
- Config-Custom-Services, full env var reference
-
Custom-Services-Migration, moving hand-written compose fragments to
CS_N - cmd-service, service command reference
- Architecture, how custom services fit the stack
Getting Started
Commands
- Commands, Overview
- Lifecycle: cmd-init · cmd-build · cmd-start · cmd-stop · cmd-restart · cmd-dev
- Monitoring: cmd-status · cmd-logs · cmd-health · cmd-urls · cmd-doctor · cmd-monitor · cmd-alerts · cmd-sentry · cmd-watchdog
- Data: cmd-db · cmd-backup · cmd-dr · cmd-queue · cmd-webhooks
- Config: cmd-config · cmd-service · cmd-env · cmd-promote
- Networking: cmd-ssl · cmd-trust · cmd-dns-setup
- Security: cmd-access · cmd-security · cmd-secrets
- Tenancy: cmd-tenant · cmd-billing
- Plugins: cmd-plugin · cmd-license · cmd-dogfood (extracted, CLI-R11) · cmd-k8s (extracted, CLI-R11) · cmd-encryption (extracted, CLI-R11) · cmd-waf (extracted, CLI-R11) · cmd-federation (extracted, CLI-R11) · cmd-mail (extracted, CLI-R11) · cmd-dlq (extracted, CLI-R11)
- AI: cmd-ai · cmd-claw · cmd-model
- Templates: cmd-template
- Utilities: cmd-exec · cmd-clean · cmd-reset · cmd-update · cmd-upgrade · cmd-version · cmd-admin · cmd-migrate · cmd-migrate-firebase · cmd-migrate-supabase · cmd-completion
Features
- Features, Overview
- Feature-Auth
- Feature-Storage
- Feature-Search
- Feature-Functions
- Feature-Email
- Feature-Monitoring
- Feature-Plugins
- Feature-nClaw, AI Assistant
- Feature-nChat, Messaging
- Feature-nFamily, Family Social
- Feature-nCloud, Managed Hosting
- Feature-Memory-Rooms, Knowledge Organization
- Feature-Agent-Dashboard, Agent Metrics
- Feature-Image-Generation, AI Image Generation
Configuration
- Configuration, Overview
- Config-Env-Vars
- Config-Postgres
- Config-Hasura
- Config-Auth
- Config-Nginx
- Shared-Proxy
- Config-Optional-Services
- Config-Custom-Services
- Config-System
Plugins (87 + 10 monitoring)
- Plugin-Overview
- Plugin-Catalog
- Plugin-Install
- Plugin-Licensing
- Plugin-Architecture
- Plugin-Dev-Guide
- Plugin-Migrations-Contract
Free (25)
- plugin-backup
- plugin-content-acquisition
- plugin-content-progress
- plugin-cron
- plugin-donorbox
- plugin-feature-flags
- plugin-github
- plugin-github-runner
- plugin-invitations
- plugin-jobs
- plugin-link-preview
- plugin-mdns
- plugin-mlflow
- plugin-monitoring
- plugin-notifications
- plugin-notify
- plugin-paypal
- plugin-search
- plugin-shopify
- plugin-stripe
- plugin-subtitle-manager
- plugin-tokens
- plugin-torrent-manager
- plugin-vpn
- plugin-webhooks
Pro (62)
- plugin-access-controls
- plugin-activity-feed
- plugin-admin-api
- plugin-analytics
- plugin-auth
- plugin-bots
- plugin-browser
- plugin-calendar
- plugin-cdn
- plugin-chat
- plugin-claw
- plugin-claw-budget
- plugin-claw-news
- plugin-claw-web
- plugin-cloudflare
- plugin-cms
- plugin-compliance
- plugin-ddns
- plugin-devices
- plugin-documents
- plugin-entitlements
- plugin-file-processing
- plugin-game-metadata
- plugin-geocoding
- plugin-geolocation
- plugin-google
- plugin-home
- plugin-idme
- plugin-knowledge-base
- plugin-linkedin
- plugin-livekit
- plugin-media-processing
- plugin-meetings
- plugin-moderation
- plugin-mux
- plugin-object-storage
- plugin-observability
- plugin-photos
- plugin-podcast
- plugin-post
- plugin-realtime
- plugin-retro-gaming
- plugin-rom-discovery
- plugin-social
- plugin-sports
- plugin-support
- plugin-tmdb
- plugin-voice
- plugin-web3
- plugin-workflows
Planned (26)
plugin-auditplugin-blogplugin-checkoutplugin-commerceplugin-drmplugin-exportplugin-flowplugin-importplugin-ldapplugin-mailgunplugin-mediaplugin-oauth-providersplugin-pagesplugin-postmarkplugin-rate-limitplugin-reportsplugin-samlplugin-schedulerplugin-sendgridplugin-ssoplugin-subscriptionplugin-thumbplugin-transcoderplugin-twilioplugin-wafplugin-watermark
Guides
- Guide-Production-Deployment
- Guide-SSL-Setup
- Guide-Multi-Tenancy
- Guide-Security-Hardening
- Guide-Monitoring-Setup
- Guide-Backup-Restore
- Guide-Custom-Services
- Guide-Migration-from-v1
Architecture
- Architecture
- Architecture-Guardrails
- Service-Graph
- Compose-Generation
- Nginx-Generation
- Plugin-Architecture
Reference
Machine interface
-
JSON-Output,
--jsonenvelope -
Command-Registry,
nself help --json - Exit-Codes
- error-codes, Error Codes
-
Compat-V15,
NSELF_V15gate
Licensing
Security
Brand
Operations
- operations/release-cascade, Release Cascade
- operations/self-healing, Self-Healing Schema
- operations/redis-tuning, Redis Pool Tuning
- operations/meilisearch-warmup, MeiliSearch Warm-Up
- operations/jwt-rotation, JWT Key Rotation
- operations/windows-wsl2-setup, Windows / WSL2 Setup
- operations/gemini-oauth-reauth, Gemini OAuth Reauth
Contributing
Admin
- USER-ACTION-QUEUE, Pending Admin Actions
All commands (21)
- A: cmd-add · cmd-admin
- B: cmd-backup · cmd-build
- C: cmd-clean · cmd-config
- D: cmd-db · cmd-deploy · cmd-doctor
- E: cmd-exec
- I: cmd-init
- L: cmd-license · cmd-logs
- M: cmd-mcp
- R: cmd-remove · cmd-reset · cmd-restart
- S: cmd-start · cmd-status · cmd-stop
- U: cmd-update