-
Notifications
You must be signed in to change notification settings - Fork 1
DEPLOYMENT
This guide covers deploying nself-admin in production environments.
- Prerequisites
- Deployment Methods
- Docker Deployment
- Environment Configuration
- SSL/TLS Configuration
- Reverse Proxy Setup
- Health Checks
- Monitoring & Logging
- Backup Strategy
- Security Hardening
- Scaling & High Availability
- Troubleshooting
Minimum:
- Docker 20.10+
- 2GB RAM
- 10GB disk space
- Linux, macOS, or Windows (WSL2)
Recommended:
- Docker 24+
- 4GB RAM
- 50GB SSD
- Ubuntu 22.04 long-term support or similar
- Root or sudo access
- Docker daemon running
- Port 3021 available (or custom port)
- Internet access for Docker pulls
- Domain name (e.g., admin.example.com)
- DNS A record pointing to your server
- SSL certificate (Let's Encrypt or custom)
The easiest way to deploy nself-admin is through the nself CLI:
# On your server
curl -fsSL https://raw.githubusercontent.com/nself-org/cli/main/install.sh | bash
nself admin --port=3021The nself CLI handles:
- Docker image pulling
- Volume mounting
- Environment setup
- Health checks
For manual control:
docker run -d \
--name nself-admin \
--restart unless-stopped \
-p 3021:3021 \
-v /path/to/project:/workspace:rw \
-v /var/run/docker.sock:/var/run/docker.sock:rw \
-v nself-admin-data:/app/data \
-e NSELF_PROJECT_PATH=/workspace \
-e NODE_ENV=production \
nself/nself-admin:0.5.0Create docker-compose.yml:
version: '3.8'
services:
nself-admin:
image: nself/nself-admin:0.5.0
container_name: nself-admin
restart: unless-stopped
ports:
- '3021:3021'
volumes:
- /path/to/project:/workspace:rw
- /var/run/docker.sock:/var/run/docker.sock:rw
- nself-admin-data:/app/data
environment:
- NSELF_PROJECT_PATH=/workspace
- NODE_ENV=production
- PORT=3021
healthcheck:
test: ['CMD', 'wget', '--quiet', '--tries=1', '--spider', 'http://localhost:3021/api/health']
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
volumes:
nself-admin-data:Start with:
docker-compose up -dAlways use specific version tags in production:
# Good - specific version
docker pull nself/nself-admin:0.5.0
# Avoid - latest tag can change
docker pull nself/nself-admin:latestCritical volumes:
-
Project Directory (
/workspace)
- Contains your nself project
- Must be mounted read-write
- Example:
-v /home/user/myproject:/workspace:rw
-
Docker Socket (
/var/run/docker.sock)
- Required for container management
- Security consideration: grants Docker control
- Example:
-v /var/run/docker.sock:/var/run/docker.sock:rw
-
Data Directory (
/app/data)
- Stores nAdmin database (nadmin.db)
- Sessions, audit logs, cache
- Example:
-v nself-admin-data:/app/data
Mounting the Docker socket gives nself-admin full control over Docker. Mitigate risks:
Option 1: Docker group (recommended)
# Add your user to the docker group
sudo usermod -aG docker $USER
newgrp docker
# Verify
docker psOption 2: Socket permissions (less secure)
# Adjust socket permissions (not recommended for production)
sudo chmod 666 /var/run/docker.sockOption 3: Docker Socket Proxy (most secure)
Use a socket proxy like tecnativa/docker-socket-proxy:
services:
docker-proxy:
image: tecnativa/docker-socket-proxy
environment:
- CONTAINERS=1
- IMAGES=1
- NETWORKS=1
- VOLUMES=1
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
ports:
- '127.0.0.1:2375:2375'
nself-admin:
image: nself/nself-admin:0.5.0
environment:
- DOCKER_HOST=tcp://docker-proxy:2375NSELF_PROJECT_PATH=/workspace # Path to your nself project
NODE_ENV=production # Enable production mode
PORT=3021 # Server port (default: 3021)ADMIN_VERSION=0.5.0 # Version string (for display)
LOG_LEVEL=info # Logging level (debug, info, warn, error)
SESSION_DURATION=604800 # Session duration in seconds (default: 7 days)
RATE_LIMIT_WINDOW=900000 # Rate limit window in ms (default: 15 min)
RATE_LIMIT_MAX=100 # Max requests per windowDocker run:
docker run -d \
-e NSELF_PROJECT_PATH=/workspace \
-e NODE_ENV=production \
-e LOG_LEVEL=info \
nself/nself-admin:0.5.0Docker Compose:
services:
nself-admin:
environment:
- NSELF_PROJECT_PATH=/workspace
- NODE_ENV=production
- LOG_LEVEL=infoEnvironment file:
Create .env.production:
NSELF_PROJECT_PATH=/workspace
NODE_ENV=production
LOG_LEVEL=infoLoad with:
docker run -d --env-file .env.production nself/nself-admin:0.5.0nself-admin includes built-in Let's Encrypt support via the SSL Configuration page.
Prerequisites:
- Public domain name
- DNS pointing to your server
- Ports 80 and 443 accessible
Steps:
- Access nself-admin at
http://your-domain:3021 - Navigate to Config > SSL
- Click Configure Let's Encrypt
- Enter your email and domain
- Click Generate Certificate
Certificates auto-renew 30 days before expiry.
If you have your own certificate:
-
Place certificate files on the server:
/etc/ssl/certs/admin.example.com.crt /etc/ssl/private/admin.example.com.key
-
Configure via nself-admin UI or environment variables.
For local HTTPS:
- Navigate to Config > SSL
- Click Generate Local Certificate
- Click Trust Certificate (macOS/Linux)
- Restart nself-admin
Create /etc/nginx/sites-available/nself-admin:
upstream nself_admin {
server localhost:3021;
}
server {
listen 80;
server_name admin.example.com;
# Redirect HTTP to HTTPS
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
server_name admin.example.com;
# SSL Configuration
ssl_certificate /etc/letsencrypt/live/admin.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/admin.example.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
# Security Headers
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
# Proxy Configuration
location / {
proxy_pass http://nself_admin;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 300s;
proxy_connect_timeout 75s;
}
# WebSocket Support
location /socket.io/ {
proxy_pass http://nself_admin;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_read_timeout 86400;
}
}Enable and restart:
sudo ln -s /etc/nginx/sites-available/nself-admin /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginxCreate Caddyfile:
admin.example.com {
reverse_proxy localhost:3021 {
header_up X-Real-IP {remote}
header_up X-Forwarded-For {remote}
header_up X-Forwarded-Proto {scheme}
}
# WebSocket support (automatic in Caddy)
}Start Caddy:
sudo caddy run --config CaddyfileAdd labels to Docker Compose:
services:
nself-admin:
image: nself/nself-admin:0.5.0
labels:
- 'traefik.enable=true'
- 'traefik.http.routers.nself-admin.rule=Host(`admin.example.com`)'
- 'traefik.http.routers.nself-admin.entrypoints=websecure'
- 'traefik.http.routers.nself-admin.tls.certresolver=letsencrypt'
- 'traefik.http.services.nself-admin.loadbalancer.server.port=3021'nself-admin provides a health check endpoint:
curl http://localhost:3021/api/healthResponse:
{
"status": "healthy",
"timestamp": "2026-01-31T12:34:56.789Z",
"version": "0.5.0",
"checks": {
"docker": true,
"filesystem": true,
"database": true,
"cli": true
}
}Add to docker-compose.yml:
healthcheck:
test: ['CMD', 'wget', '--quiet', '--tries=1', '--spider', 'http://localhost:3021/api/health']
interval: 30s
timeout: 10s
retries: 3
start_period: 40sOr with curl:
healthcheck:
test: ['CMD', 'curl', '-f', 'http://localhost:3021/api/health']
interval: 30s
timeout: 10s
retries: 3Check health status:
docker inspect --format='{{.State.Health.Status}}' nself-adminView health logs:
docker inspect --format='{{range .State.Health.Log}}{{.Output}}{{end}}' nself-adminView logs:
docker logs nself-admin
docker logs -f nself-admin # Follow
docker logs --tail 100 nself-admin # Last 100 linesConfigure log rotation:
services:
nself-admin:
logging:
driver: 'json-file'
options:
max-size: '10m'
max-file: '3'nself-admin logs to stdout/stderr. Log levels:
-
DEBUG- Detailed debugging information -
INFO- General information (default) -
WARN- Warning messages -
ERROR- Error messages
Set log level:
-e LOG_LEVEL=infoPrometheus:
nself-admin exposes metrics at /api/metrics (planned for v0.6.0).
Grafana:
Integrated Grafana dashboards accessible via the Monitoring page.
Uptime Monitoring:
Use services like:
- UptimeRobot
- Pingdom
- StatusCake
Configure to check https://admin.example.com/api/health every 5 minutes.
-
nAdmin Database (
nadmin.db)
- Sessions, passwords, cache
- Located at
/app/data/nadmin.db
-
Project Directory (
/workspace)
- Your nself project configuration
- Environment files
- Docker Compose configs
- Docker Volumes
- Named volumes used by services
- PostgreSQL data, MinIO buckets, etc.
Automated daily backup:
#!/bin/bash
# backup.sh
BACKUP_DIR="/backups/nself-admin/$(date +%Y%m%d)"
mkdir -p "$BACKUP_DIR"
# Backup nAdmin database
docker cp nself-admin:/app/data/nadmin.db "$BACKUP_DIR/"
# Backup project directory
cp -r /path/to/project "$BACKUP_DIR/"
# Backup Docker volumes
docker run --rm \
-v nself-admin-data:/data \
-v "$BACKUP_DIR":/backup \
alpine tar czf /backup/data.tar.gz /data
# Keep only last 7 days
find /backups/nself-admin -type d -mtime +7 -exec rm -rf {} +Schedule with cron:
crontab -e
# Add:
0 2 * * * /path/to/backup.sh# Stop container
docker stop nself-admin
# Restore database
docker cp nadmin.db nself-admin:/app/data/
# Restore project
cp -r backup/project /path/to/project
# Start container
docker start nself-adminOnly expose necessary ports:
# UFW (Ubuntu)
sudo ufw allow 22/tcp # SSH
sudo ufw allow 80/tcp # HTTP
sudo ufw allow 443/tcp # HTTPS
sudo ufw enable
# Block direct access to port 3021
sudo ufw deny 3021/tcpUse a reverse proxy (Nginx/Caddy) to terminate SSL.
Set a strong password on first login:
- Minimum 12 characters
- Uppercase, lowercase, numbers, special characters
- Avoid common patterns
Sessions expire after 7 days by default. Adjust:
-e SESSION_DURATION=259200 # 3 days in secondsPrevent brute-force attacks:
-e RATE_LIMIT_WINDOW=900000 # 15 minutes
-e RATE_LIMIT_MAX=100 # Max 100 requestsKeep Docker images up to date:
docker pull nself/nself-admin:latest
docker-compose down
docker-compose up -dEnable audit logging:
Navigate to System > Security > Audit Log to review:
- Login attempts
- Configuration changes
- Service restarts
- Database operations
Use a Docker socket proxy (see Docker Socket Security).
Run nself-admin in a dedicated network:
networks:
nself-admin-net:
driver: bridge
services:
nself-admin:
networks:
- nself-admin-netRun multiple instances behind a load balancer:
services:
nself-admin-1:
image: nself/nself-admin:0.5.0
# ... config
nself-admin-2:
image: nself/nself-admin:0.5.0
# ... config
nginx:
image: nginx:alpine
ports:
- '443:443'
volumes:
- ./nginx.conf:/etc/nginx/nginx.confNote: Session persistence requires sticky sessions or shared session storage (planned for v0.6.0).
For high availability:
- Use external PostgreSQL with replication
- Configure via Database > Configuration
- Set up read replicas
Set up alerts for:
- Container health failures
- High resource usage (CPU > 80%, RAM > 90%)
- Disk space < 10%
- Failed login attempts > 10/min
Use Prometheus + Alertmanager or similar.
Check logs:
docker logs nself-adminCommon issues:
- Port 3021 already in use
- Docker socket permission denied
- Volume mount path doesn't exist
Solutions:
# Check port usage
sudo lsof -i :3021
# Fix Docker permissions
sudo usermod -aG docker $USER
# Verify volume paths
ls -la /path/to/project
ls -la /var/run/docker.sockCheck container status:
docker ps -a | grep nself-adminCheck health:
docker inspect --format='{{.State.Health.Status}}' nself-adminTest locally:
curl http://localhost:3021/api/healthFirewall blocking:
sudo ufw status
sudo ufw allow 3021/tcpReset database:
docker exec nself-admin rm /app/data/nadmin.db
docker restart nself-adminNote: This will log you out and reset all sessions.
Check resource usage:
docker stats nself-adminIncrease container resources:
services:
nself-admin:
deploy:
resources:
limits:
cpus: '2'
memory: 4G
reservations:
cpus: '1'
memory: 2GVerify certificate:
openssl s_client -connect admin.example.com:443 -servername admin.example.comCheck Let's Encrypt logs:
docker logs nself-admin | grep letsencryptRenew manually:
Navigate to Config > SSL > Renew Certificate
After deploying nself-admin:
- Configure Services - Set up PostgreSQL, Hasura, etc.
- Set Up Backups - Automate database backups
- Configure Monitoring - Enable Grafana dashboards
- Invite Team Members - Add users (v0.6.0+)
- Deploy to Staging - Test deployment workflow
For more information, see:
Need help? Open an issue on GitHub.
Version: 1.0.0 | Updated: 2026-09-16 11:21 UTC | GitHub