Updated for ɳSelf v0.4.8
Essential CLI commands for deploying and managing ɳSelf in production environments with the v0.4.8 environment management, security hardening, and deployment capabilities.
ɳSelf prod statusShow production environment status (default subcommand):
# Show production status
ɳSelf prod status
ɳSelf prod
# Displays:
# - Environment settings (ENV, domain, debug mode)
# - Secrets file status
# - SSL certificate status and expiry
# - Docker Compose file statusɳSelf prod initInitialize production configuration:
# Initialize production for your domain
ɳSelf prod init yourdomain.com --email admin@yourdomain.com
# What it does:
# - Sets ENV=production
# - Disables debug mode
# - Enables SSL with Let's Encrypt
# - Disables Hasura dev mode and console
# - Creates docker-compose.prod.ymlɳSelf prod check / auditRun comprehensive security audit:
# Run security audit
ɳSelf prod check
ɳSelf prod audit --verbose
# Checks performed:
# - Environment settings (DEBUG, LOG_LEVEL, etc.)
# - Secrets strength and configuration
# - SSL certificate validity and expiry
# - Docker security settings
# - Network security (HSTS, XSS protection, etc.)
# - File permissions
# Exit codes:
# 0 - All checks passed
# 1 - Critical failures detected
# 2 - Warnings only (no critical failures)ɳSelf prod secretsManage production secrets:
# Generate all production secrets
ɳSelf prod secrets generate
ɳSelf prod secrets generate --force # Overwrite existing
# Validate secrets file
ɳSelf prod secrets validate
# Rotate a specific secret
ɳSelf prod secrets rotate POSTGRES_PASSWORD
# Show secrets (masked by default)
ɳSelf prod secrets show
ɳSelf prod secrets show --unmask
# Generated secrets:
# - POSTGRES_PASSWORD
# - HASURA_GRAPHQL_ADMIN_SECRET
# - JWT_SECRET
# - COOKIE_SECRET
# - MINIO_ROOT_PASSWORD
# - REDIS_PASSWORD
# - GRAFANA_ADMIN_PASSWORDɳSelf prod sslManage SSL/TLS certificates:
# Check SSL certificate status
ɳSelf prod ssl status
# Request Let's Encrypt certificate
ɳSelf prod ssl request yourdomain.com --email admin@yourdomain.com
ɳSelf prod ssl request yourdomain.com --staging # For testing
# Renew SSL certificates
ɳSelf prod ssl renew
ɳSelf prod ssl renew --force
# Generate self-signed certificate
ɳSelf prod ssl self-signed yourdomain.com
# Verify certificate chain
ɳSelf prod ssl verifyɳSelf prod firewallConfigure and manage firewall rules:
# Check firewall status
ɳSelf prod firewall status
# Configure recommended rules
ɳSelf prod firewall configure --dry-run
ɳSelf prod firewall configure
# Allow/block specific ports
ɳSelf prod firewall allow 8080
ɳSelf prod firewall allow 53 udp
ɳSelf prod firewall block 3306
# Show security recommendations
ɳSelf prod firewall recommendationsɳSelf prod hardenApply all security hardening measures:
# Apply all hardening
ɳSelf prod harden
# Preview changes without applying
ɳSelf prod harden --dry-run
# Skip firewall configuration
ɳSelf prod harden --skip-firewall
# Hardening steps:
# 1. Generate secrets (if missing)
# 2. Apply production environment settings
# 3. Fix SSL key permissions
# 4. Check firewall status
# 5. Fix sensitive file permissionsnself deployDeploy your ɳSelf project to remote servers via SSH:
# Deploy to staging (full stack including frontends)
nself deploy staging
# Deploy to production (backend only by default)
nself deploy prod
# Preview deployment without executing
nself deploy staging --dry-run
nself deploy prod --dry-run
# Force deployment without confirmation
nself deploy staging --force
# Skip health checks after deployment
nself deploy prod --skip-health
# Include/exclude frontends
nself deploy prod --include-frontends
nself deploy staging --exclude-frontends
# Rolling deployment (zero-downtime)
nself deploy prod --rollingnself deploy check-accessVerify SSH access to environments:
# Check access to all environments
nself deploy check-access
# Check before deploying
nself deploy staging --check-accessnself deploy healthCheck deployment health:
# Check staging health
nself deploy health staging
# Check production health
nself deploy health prodnself deploy rollbackRollback to previous deployment:
# Rollback if something goes wrong
nself deploy rollbacknself deploy logsView deployment logs:
# View deployment logs
nself deploy logsnself envManage deployment environments:
# List all environments
nself env list
# Create new environment
nself env create staging staging
nself env create production prod
# Switch environment
nself env switch dev
nself env switch staging
nself env switch prod
# Show current environment status
nself env status
# Compare environments
nself env diff staging prod
nself env diff dev staging --values
# Validate environment configuration
nself env validate staging
# Delete environment
nself env delete qa
# Export/import environments
nself env export staging --output staging-env.tar.gz
nself env import staging-env.tar.gznself updateUpdate ɳSelf to the latest version:
# Update to latest version
nself update
# Check current version
nself versionnself statusCheck comprehensive system status:
# Basic status check
nself status
# Show all service URLs
nself urlsnself logsAccess and monitor service logs:
# View all service logs
nself logs
# Follow logs in real-time
nself logs -f
# View specific service logs
nself logs postgres
nself logs hasuranself execExecute commands in service containers:
# Shell into a container
nself exec postgres
# Run specific command
nself exec postgres psql -U postgresnself monitorOpen monitoring dashboards:
# Open Grafana (default)
nself monitor
nself monitor grafana
# Open Prometheus
nself monitor prometheus
# Open Alertmanager
nself monitor alerts
# Open Loki in Grafana
nself monitor loki
# CLI service status view
nself monitor services
# CLI resource usage view
nself monitor resources
# Tail service logs
nself monitor logs
nself monitor logs postgresnself metricsConfigure monitoring profiles:
# Enable monitoring profiles
nself metrics enable minimal # 4 services (~500MB)
nself metrics enable standard # 7 services (~1GB)
nself metrics enable full # 10 services (~2GB)
nself metrics enable auto # Auto-detect based on ENV
# Show current profile
nself metrics statusnself backupCreate system backups:
# Create full system backup
nself backup
# Database only backup
nself db backup
# Include configuration files
nself backup --include-config
# Compressed backup
nself backup --compress
# Remote backup to S3
nself backup --remote s3://my-backups/nself/nself restoreRestore from backups:
# Restore from latest backup
nself restore
# Restore from specific backup
nself restore --from backup-20250806-140000
# Restore database only
nself db restore backup.sql
# Restore with verification
nself restore --verifyɳSelf securitySecurity auditing and hardening:
# Run security audit
ɳSelf security audit
# Check for vulnerabilities
ɳSelf security scan
# Update security configurations
ɳSelf security harden
# Generate new secrets
ɳSelf security rotate-secrets
# SSL certificate management
ɳSelf security ssl-renew
ɳSelf security ssl-statusɳSelf encryptData encryption utilities:
# Encrypt sensitive files
ɳSelf encrypt .env.prod
# Decrypt files
ɳSelf decrypt .env.prod.enc
# Rotate encryption keys
ɳSelf encrypt rotate-keysɳSelf cleanupSystem cleanup and optimization:
# Clean up unused resources
ɳSelf cleanup
# Deep clean (removes old images, volumes)
ɳSelf cleanup --deep
# Clean specific components
ɳSelf cleanup docker
ɳSelf cleanup logs
ɳSelf cleanup backups
# Dry run (show what would be cleaned)
ɳSelf cleanup --dry-runɳSelf optimizePerformance optimization:
# Optimize database performance
ɳSelf optimize database
# Optimize Docker images
ɳSelf optimize images
# Full system optimization
ɳSelf optimize --all
# Generate optimization report
ɳSelf optimize --reportnself configProduction configuration management:
# Validate configuration
nself config validate
# Show configuration (sanitized)
nself config show
# Update configuration value
nself config set POSTGRES_MAX_CONNECTIONS 200
# Generate new configuration template
nself config generate --environment production
# Import configuration from file
nself config import production.env
# Export configuration
nself config export --sanitize > config-backup.envnself scaleScale services for production load:
# Scale specific service
nself scale hasura 3
# Auto-scale based on load
nself scale --auto
# Scale all services
nself scale --replicas 2
# Scale with resource limits
nself scale hasura 3 --memory 512MB --cpu 0.5ɳSelf reloadReload services without downtime:
# Reload specific service
ɳSelf reload hasura
# Reload configuration
ɳSelf reload --config
# Rolling reload (zero downtime)
ɳSelf reload --rollingɳSelf networkNetwork diagnostics and configuration:
# Test network connectivity
ɳSelf network test
# Show network configuration
ɳSelf network show
# Test external connectivity
ɳSelf network test-external
# Diagnose network issues
ɳSelf network diagnose#!/bin/bash
# production-deploy.sh
set -e
echo "🚀 Starting production deployment..."
# Backup current state
echo "Creating backup..."
nself backup --name "pre-deploy-$(date +%Y%m%d-%H%M%S)"
# Update system
echo "Updating nself..."
nself update
# Deploy new version
echo "Deploying services..."
ɳSelf prod
cp .env.prod-template .env
nself build
nself up --no-deps
# Run health checks
echo "Running health checks..."
sleep 30
nself doctor
# Verify deployment
if nself status --check; then
echo "✅ Deployment successful!"
else
echo "❌ Deployment failed, rolling back..."
nself restore
exit 1
fi#!/bin/bash
# monitor.sh - Add to cron for continuous monitoring
# Check system health
if ! nself doctor --quick; then
echo "Health check failed" | mail -s "ɳSelf Alert" admin@example.com
fi
# Check resource usage
CPU_USAGE=$(ɳSelf resources --format json | jq '.total.cpu')
if (( $(echo "$CPU_USAGE > 80" | bc -l) )); then
echo "High CPU usage: $CPU_USAGE%" | mail -s "ɳSelf Resource Alert" admin@example.com
fi
# Check disk space
DISK_USAGE=$(df / | tail -1 | awk '{print $5}' | sed 's/%//')
if [ "$DISK_USAGE" -gt 85 ]; then
ɳSelf cleanup --auto
fi
# Rotate logs
find logs/ -name "*.log" -mtime +7 -delete# .github/workflows/deploy.yml
name: Deploy to Production
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install ɳSelf
run: |
curl -sSL https://install.nself.org | bash
- name: Deploy to production
run: |
echo "${{ secrets.ENV_PROD }}" > .env
nself build
nself up --detach
- name: Health check
run: |
sleep 30
nself doctornself doctor regularly via cron