-
-
Notifications
You must be signed in to change notification settings - Fork 2
SERVICE_TEMPLATES
Comprehensive guide to all 40 built-in service templates for microservices and custom backends
nself provides 40+ production-ready service templates spanning 10 programming languages. Each template includes Docker configuration, health checks, CORS support, graceful shutdown, and follows language-specific best practices.
# Enable custom services
SERVICES_ENABLED=true
# Add a service using a template
CS_1=api:fastapi:3001:/api
# Build and start
nself build && nself start- JavaScript/TypeScript: 19 templates (Node, Express, Fastify, NestJS, Hono, Socket.IO, BullMQ, Temporal, Bun, Deno, tRPC)
- Python: 7 templates (Flask, FastAPI, Django REST, Celery, Ray, AI Agents)
- Go: 4 templates (Gin, Echo, Fiber, gRPC)
- Other Languages: 10 templates (Rust, Java, C#, C++, Ruby, Elixir, PHP, Kotlin, Swift)
CS_N=name:template:port:route- name: Service identifier (alphanumeric + hyphens)
- template: Template from the list below
- port: Container port (optional, auto-assigns)
- route: URL path prefix or domain (optional)
-
node-js- Plain Node.js HTTP server (JavaScript) -
node-ts- Plain Node.js HTTP server (TypeScript)
-
express-js- Express.js web framework (JavaScript) -
express-ts- Express.js web framework (TypeScript) -
fastify-js- High-performance Fastify framework (JavaScript) -
fastify-ts- High-performance Fastify framework (TypeScript) -
hono-js- Ultra-light edge-optimized framework (JavaScript) -
hono-ts- Ultra-light edge-optimized framework (TypeScript)
-
nest-js- NestJS enterprise framework (JavaScript) -
nest-ts- NestJS enterprise framework (TypeScript)
-
socketio-js- Socket.IO real-time bidirectional communication (JavaScript) -
socketio-ts- Socket.IO real-time bidirectional communication (TypeScript)
-
bullmq-js- Redis-backed job queues with BullMQ (JavaScript) -
bullmq-ts- Redis-backed job queues with BullMQ (TypeScript)
-
temporal-js- Temporal workflow orchestration (JavaScript) -
temporal-ts- Temporal workflow orchestration (TypeScript)
-
bun- Bun runtime server (JavaScript) -
deno- Deno runtime server (TypeScript)
-
trpc- Type-safe RPC framework (TypeScript only)
# Express API with TypeScript
CS_1=api:express-ts:3001:/api
# Real-time WebSocket service
CS_2=chat:socketio-ts:3002
# Background job processor
CS_3=jobs:bullmq-ts:3003
# High-performance API
CS_4=fast:fastify-ts:3004:/v1
# Enterprise microservice
CS_5=service:nest-ts:3005-
flask- Lightweight Flask microframework -
fastapi- Async type-hinted FastAPI framework -
django-rest- Django REST Framework APIs
-
celery- Distributed task queue with Redis backend -
ray- Distributed ML compute and model serving
-
agent-llm- LLM agent orchestration starter with OpenAI integration -
agent-data- Data-centric agent with pandas, scikit-learn, and DuckDB
# FastAPI microservice
CS_1=api:fastapi:8001:/api
# Background task processor
CS_2=tasks:celery:8002
# ML model serving
CS_3=ml:ray:8003:/models
# AI agent service
CS_4=agent:agent-llm:8004:/chat
# Data processing service
CS_5=data:agent-data:8005:/process-
gin- High-performance Gin web framework -
echo- Minimal Echo API framework -
fiber- Express-inspired, speed-focused Fiber framework -
grpc- Official Go gRPC implementation with Protocol Buffers
# High-performance API
CS_1=api:gin:8001:/api
# Minimal microservice
CS_2=service:echo:8002
# Fast web service
CS_3=web:fiber:8003
# gRPC service
CS_4=grpc:grpc:50051-
rust/axum- Modern async Rust web framework with Tokio
-
java/spring-boot- Enterprise Java Spring Boot framework
-
csharp/aspnet- ASP.NET Core Web API
-
cpp/oatpp- Modern C++ web framework with high performance
-
ruby/rails- Ruby on Rails in API mode
-
elixir/phoenix- Productive Elixir Phoenix framework
-
php/laravel- Laravel PHP framework
-
kotlin/ktor- Asynchronous Kotlin Ktor framework
-
swift/vapor- Swift Vapor server-side framework
# Rust high-performance API
CS_1=api:rust/axum:8001
# Java enterprise service
CS_2=enterprise:java/spring-boot:8002
# C# .NET API
CS_3=dotnet:csharp/aspnet:8003
# Ruby on Rails API
CS_4=rails:ruby/rails:8004
# Elixir Phoenix service
CS_5=phoenix:elixir/phoenix:8005Every template includes:
- Multi-stage builds for smaller images
- Non-root container users
- Optimized layer caching
- Health check endpoints
- Security headers (X-Frame-Options, X-Content-Type-Options, etc.)
- CORS configuration
- Input validation patterns
- No secrets in container images
- Health check endpoints at
/health - Structured logging support
- Environment-based configuration
- Version information in responses
- Graceful shutdown handling
- Connection pooling where applicable
- Production-optimized dependencies
- Efficient resource utilization
- Template variable placeholders (
{{SERVICE_NAME}},{{SERVICE_PORT}}, etc.) - Consistent file structure across languages
- Clear documentation comments
- Ready-to-customize code
Create your own templates in src/templates/services/custom/:
# Use custom template
CS_1=myservice:custom:8001
# nself will look for:
# src/templates/services/custom/Dockerfile.template
# src/templates/services/custom/[source files]# Per-service environment variables
CS_1_ENV=NODE_ENV=production,LOG_LEVEL=info,API_KEY=${API_KEY}
# Health check customization
CS_1_HEALTH_PATH=/api/health
CS_1_HEALTH_TIMEOUT=30s# Internal service (no external access)
CS_1=internal:fastapi:8001
# Public service with domain
CS_2=api:fastapi:8002:api.example.com
# Service with custom route
CS_3=v1:fastapi:8003:/v1/api# Multiple instances of the same service
CS_1=api-1:fastapi:8001:/api
CS_2=api-2:fastapi:8002:/api
CS_3=api-3:fastapi:8003:/api- All 40 templates are now fully validated and production-ready
- Template names are standardized (use hyphens, not underscores)
- TypeScript versions available for most JavaScript frameworks
-
nodejs-raw→node-js -
nodejs-raw-ts→node-ts - Removed incomplete templates from previous versions
-
High Performance:
fastify-ts,gin,rust/axum -
Enterprise:
nest-ts,java/spring-boot -
Rapid Development:
fastapi,express-ts -
Real-time:
socketio-ts,elixir/phoenix -
Background Jobs:
bullmq-ts,celery
# Use environment-specific settings
CS_1_ENV=NODE_ENV=${ENV},LOG_LEVEL=debug,DATABASE_URL=${DATABASE_URL}# Configure appropriate timeouts
CS_1_HEALTH_TIMEOUT=30s
CS_1_HEALTH_INTERVAL=30s# Set appropriate memory limits
CS_1_MEMORY=512m
CS_1_CPUS=0.5# List available templates
find src/templates/services/ -name "Dockerfile.template"
# Verify template structure
ls src/templates/services/js/express-ts/# Check template validation
nself validate
# Review build logs
nself logs CS_1# Check service logs
nself logs [service-name]
# Verify port availability
nself status- Configuration Reference - Detailed service configuration
- Examples - Real-world usage examples
- Architecture - How services fit into nself
- Template Validation - Quality assurance report
Need a new template? Submit a feature request or contribute your own template following the existing patterns.
ɳSelf CLI v1.0.9. MIT licensed. Docs CC BY 4.0.
GitHub · Issues · Discussions · nself.org · nself.org/docs
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-nTV, Media Player
- 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
- Config-Optional-Services
- Config-Custom-Services
- Config-System
Plugins (87 + 10 monitoring)
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-nself-ai-gateway
- plugin-nself-ai-mcp
- plugin-nself-ai-mcp
- plugin-analytics
- plugin-auth
- plugin-backup-pro
- 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-cron-pro
- plugin-ddns
- plugin-devices
- plugin-documents
- plugin-donorbox-pro
- plugin-entitlements
- plugin-epg
- 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-notify-pro
- plugin-object-storage
- plugin-observability
- plugin-paypal-pro
- plugin-photos
- plugin-podcast
- plugin-post
- plugin-realtime
- plugin-recording
- plugin-retro-gaming
- plugin-rom-discovery
- plugin-shopify-pro
- plugin-social
- plugin-sports
- plugin-stream-gateway
- plugin-streaming
- plugin-stripe-pro
- 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
Reference
- API-Reference
- error-codes, Error Codes
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 (52)
- A: cmd-access · cmd-account · cmd-admin
- B: cmd-backup · cmd-build · cmd-bundle
- C: cmd-ci · cmd-clean · cmd-completion · cmd-config
- D: cmd-db · cmd-deploy · cmd-dev · cmd-doctor
- E: cmd-env · cmd-exec
- F: cmd-functions
- G: cmd-generate
- H: cmd-health · cmd-help-topics
- I: cmd-init · cmd-install
- L: cmd-license · cmd-login · cmd-logout · cmd-logs
- M: cmd-man · cmd-mcp · cmd-migrate
- O: cmd-oauth · cmd-ops
- P: cmd-plugin · cmd-promote
- R: cmd-remove · cmd-reset · cmd-restart · cmd-runner
- S: cmd-secrets · cmd-security · cmd-self-heal · cmd-server · cmd-service · cmd-start · cmd-status · cmd-stop
- T: cmd-telemetry · cmd-template · cmd-trust
- U: cmd-update · cmd-urls
- V: cmd-verify-sbom · cmd-version