Self-Hosting Apito with Docker
Self-hosting Apito gives you complete control over your API platform with unlimited projects, no license fees, and the ability to run on your own infrastructure using our production-ready Docker images.
Prerequisites
- Docker Engine 20.10+
- Docker Compose 2.0+
- At least 2GB RAM
- 10GB free disk space
- Domain name (optional, for production)
- Basic knowledge of Docker and command line
Quick Start
1. Download Docker Compose Configuration
Create a new directory for your Apito instance:
mkdir apito-self-hosted
cd apito-self-hosted
Download our production-ready Docker Compose configuration:
curl -O https://apito.io/docker-compose.yml
2. Environment Configuration
Create a .env file for your environment variables:
# Create environment file
touch .env
Edit the .env file with your configuration:
# Database Configuration
ARANGO_ROOT_PASSWORD=your_secure_arangodb_password
REDIS_PASSWORD=your_secure_redis_password
# Domain Configuration (replace with your domain)
DOMAIN=your-domain.com
API_SUBDOMAIN=api
CONSOLE_SUBDOMAIN=console
DB_SUBDOMAIN=db
# CORS and Cookie Configuration
CORS_ORIGIN=https://console.your-domain.com
COOKIE_DOMAIN=your-domain.com
# System Database Configuration
SYSTEM_DB_HOST=http://db.your-domain.com
SYSTEM_DB_PORT=80
PROJECT_DB_HOST=http://db.your-domain.com
PROJECT_DB_PORT=80
# Redis Configuration
KV_HOST=redis.your-domain.com
3. Update Docker Compose Configuration
Edit the docker-compose.yml file to replace domain references:
# Replace all instances of 'udbhabon' with your domain
sed -i 's/udbhabon/your-domain/g' docker-compose.yml
sed -i 's/udb_/apito_/g' docker-compose.yml
4. Start the Services
docker-compose up -d
This will start:
- Apito Engine (API server) on port 5050
- Apito Console (Frontend) on port 8080
- ArangoDB database on port 8529
- Redis cache on port 6379
- Traefik reverse proxy on ports 80, 6379, 8080
5. Access Your Instance
- Apito Console: http://console.your-domain.com (or http://localhost:8080)
- API Endpoint: http://api.your-domain.com (or http://localhost:5050)
- Database Admin: http://db.your-domain.com (or http://localhost:8529)
- Traefik Dashboard: http://localhost:8080
Production Deployment
1. SSL/HTTPS Setup with Traefik
For production, configure SSL certificates with Traefik. Update your docker-compose.yml:
# Add SSL configuration to Traefik
reverse-proxy:
image: traefik:v3.0
command:
- "--api.dashboard=true"
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
- "--certificatesresolvers.letsencrypt.acme.tlschallenge=true"
- "--certificatesresolvers.letsencrypt.acme.email=your-email@your-domain.com"
- "--certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json"
ports:
- "80:80"
- "443:443"
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "./letsencrypt:/letsencrypt"
Update service labels for SSL:
labels:
- "traefik.http.routers.apito-api.rule=Host(`api.your-domain.com`)"
- "traefik.http.routers.apito-api.entrypoints=websecure"
- "traefik.http.routers.apito-api.tls.certresolver=letsencrypt"
2. Database Backup
Set up automated ArangoDB backups:
#!/bin/bash
# backup-arangodb.sh
docker exec apito-arangodb arangodump --server.database apito --output-directory /backup/$(date +%Y%m%d_%H%M%S)
3. Monitoring
Add monitoring with Prometheus and Grafana:
# monitoring.yml
version: "3"
services:
prometheus:
image: prom/prometheus
ports:
- "9090:9090"
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
grafana:
image: grafana/grafana
ports:
- "3001:3000"
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin
Configuration Options
Database Options
Apito uses ArangoDB as the primary database:
# ArangoDB Configuration
ARANGO_ROOT_PASSWORD=your_secure_password
ARANGO_DATABASE=apito
ARANGO_USER=apito
ARANGO_PASSWORD=your_user_password
Redis Configuration
# Redis with password and persistence
REDIS_PASSWORD=your_secure_redis_password
REDIS_APPENDONLY=yes
Environment Variables
Key environment variables for the Apito Engine:
# Core Configuration
ENVIRONMENT=production
CORS_ORIGIN=https://console.your-domain.com
COOKIE_DOMAIN=your-domain.com
# Database Connections
SYSTEM_DB_HOST=http://db.your-domain.com
SYSTEM_DB_PORT=80
PROJECT_DB_HOST=http://db.your-domain.com
PROJECT_DB_PORT=80
# Cache Configuration
KV_HOST=redis.your-domain.com
Frontend Configuration
Apito Console environment variables:
# API Endpoints
VITE_REST_API=https://api.your-domain.com
VITE_GRAPH_API=https://api.your-domain.com/system/graphql
VITE_PUBLIC_GRAPH_API=https://api.your-domain.com/secured/graphql
VITE_GRAPH_SUBS_API=wss://api.your-domain.com/system/graphql/subscription
# Authentication
VITE_AUTH_PROVIDER=apito
Advanced Configuration
Custom Environment File
Create a custom environment file for the Apito Engine:
# Create engine.env file
cat > engine.env << EOF
# Add your custom environment variables here
CUSTOM_SETTING=value
EOF
Load Balancing
For high availability, use multiple Apito Engine instances:
services:
apito-1:
image: registry.gitlab.com/apito.io/engine:v2.1.6
environment:
- INSTANCE_ID=1
apito-2:
image: registry.gitlab.com/apito.io/engine:v2.1.6
environment:
- INSTANCE_ID=2
Scaling
Scale horizontally with Docker Swarm:
# Scale API instances
docker-compose up -d --scale apito=3
# Scale with Docker Swarm
docker stack deploy -c docker-compose.yml apito-stack
Troubleshooting
Common Issues
ArangoDB Connection Failed
# Check if ArangoDB is running
docker-compose ps apito-arangodb
# View logs
docker-compose logs apito-arangodb
# Test connection
docker exec apito-arangodb arangosh --server.database apito
Redis Connection Issues
# Check Redis status
docker-compose ps apito-redis
# Test Redis connection
docker exec apito-redis redis-cli ping
Traefik Routing Problems
# Check Traefik dashboard
curl http://localhost:8080/api/http/routers
# View Traefik logs
docker-compose logs reverse-proxy
Out of Memory
# Increase Docker memory limits
docker-compose up -d --memory=4g
Performance Optimization
ArangoDB Optimization
// Connect to ArangoDB and optimize
db._query(`
FOR collection IN COLLECTIONS()
OPTIMIZE COLLECTION collection.name
`)
Redis Optimization
# Redis configuration
REDIS_MAXMEMORY=512mb
REDIS_MAXMEMORY_POLICY=allkeys-lru
Security Considerations
1. Firewall Configuration
# Allow only necessary ports
ufw allow 22 # SSH
ufw allow 80 # HTTP
ufw allow 443 # HTTPS
ufw deny 8080 # Block direct access to Traefik dashboard
ufw deny 8529 # Block direct access to ArangoDB
2. Database Security
# Use strong passwords
ARANGO_ROOT_PASSWORD=your_very_secure_password_here
REDIS_PASSWORD=your_very_secure_redis_password
3. API Security
# CORS configuration
CORS_ORIGIN=https://your-domain.com
# Cookie security
COOKIE_DOMAIN=your-domain.com
COOKIE_SECURE=true
Backup and Recovery
Automated Backups
#!/bin/bash
# daily-backup.sh
BACKUP_DIR="/backups/apito"
DATE=$(date +%Y%m%d_%H%M%S)
# ArangoDB backup
docker exec apito-arangodb arangodump --server.database apito --output-directory $BACKUP_DIR/arangodb_$DATE
# Redis backup
docker exec apito-redis redis-cli --rdb $BACKUP_DIR/redis_$DATE.rdb
# Cleanup old backups (keep 30 days)
find $BACKUP_DIR -name "arangodb_*" -mtime +30 -exec rm -rf {} \;
find $BACKUP_DIR -name "redis_*.rdb" -mtime +30 -delete
Recovery Process
# Restore ArangoDB
docker exec -i apito-arangodb arangorestore --server.database apito --input-directory /backup/arangodb_20240101_120000
# Restore Redis
docker exec -i apito-redis redis-cli --pipe < backup_20240101_120000.rdb
Migration from Cloud
If you’re migrating from Apito Cloud:
1. Export Data
# Export projects and data via API
curl -H "Authorization: Bearer YOUR_TOKEN" \
https://api.apito.io/export/projects > projects.json
2. Import to Self-Hosted
# Import data to your self-hosted instance
curl -X POST -H "Content-Type: application/json" \
-d @projects.json https://api.your-domain.com/api/import/projects
Support and Community
- GitHub Issues: Report bugs and request features
- Discord Community: Join our developer community
- Documentation: Full API documentation
License
Apito is open source and available under the MIT License. You can use it for personal, commercial, or enterprise projects without any restrictions.
Need help? Join our Discord community or check out our GitHub repository for the latest updates and community support.