Docker Compose Deployment Architecture
Overview
Docker Compose deployment provides a manual, command-line approach to deploying Chatty AI. This method gives administrators direct control over the deployment process without requiring Portainer infrastructure.
Architecture
┌─────────────────────────────────────────────────────┐
│ Docker Host │
│ │
│ ┌────────────────────────────────────────────┐ │
│ │ Administrator (SSH/Direct Access) │ │
│ └────────────────┬───────────────────────────┘ │
│ │ docker-compose commands │
│ ▼ │
│ ┌────────────────────────────────────────────┐ │
│ │ Docker Engine │ │
│ │ - Reads docker-compose.yaml │ │
│ │ - Reads .env file │ │
│ │ - Manages containers and volumes │ │
│ └────────────────┬───────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌────────────────────────────────────────────┐ │
│ │ Chatty AI Stack │ │
│ │ - nginx, chattyai, db, qdrant, n8n, etc. │ │
│ └────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────┘
Deployment Package
The Docker Compose deployment uses files from the deploy/ folder:
Core Files
- docker-compose.yaml: Stack definition with all services
- .env.example: Template environment file
- README.md: Deployment instructions
Deployment Process
- Copy Deployment Package to Docker host
- Create .env File from .env.example
- Configure Environment Variables in .env
- Prepare Certificates and mount directories
- Run
docker-compose up -dto start stack - Verify Deployment using docker-compose and docker commands
Manual Operations
Starting the Stack
cd /path/to/deploy
docker-compose up -d
Stopping the Stack
docker-compose down
Viewing Logs
docker-compose logs -f [service-name]
Checking Status
docker-compose ps
Updating Images
docker-compose pull
docker-compose up -d
Environment Configuration
.env File
All configuration is managed through the .env file:
# Copy example
cp .env.example .env
# Edit with your values
vi .env
Required Variables
Must be set before deployment:
- Domain names (CHATTYAI_DOMAIN, N8N_DOMAIN, DATABASES_DOMAIN)
- URLs (CHATTYAI_URL, N8N_URL, DATABASES_URL)
- Database password (DB_PASSWORD)
- JWT secret (CHATTYAI_JWT_SECRET_KEY)
- API keys (CHATTYAI_API_KEY, CHATTYAI_AI_API_KEY)
- Admin password (CHATTYAI_ADMIN_PASSWORD)
Certificate Management
Certificate Structure
/path/to/certs/
├── chattyai/
│ ├── fullchain.pem
│ └── privkey.pem
├── n8n/
│ ├── fullchain.pem
│ └── privkey.pem
└── databases/
├── fullchain.pem
└── privkey.pem
Mounting Certificates
Certificates are mounted in docker-compose.yaml:
volumes:
- /etc/nginx/certs:/etc/nginx/certs:ro
Ensure certificates exist at /etc/nginx/certs on the host before starting.
Advantages of Docker Compose Deployment
Direct Control
- Full Transparency: See exactly what commands are executed
- No Abstraction: Direct interaction with Docker
- Customization: Easy to modify compose file for specific needs
- Debugging: Direct access to Docker commands and logs
Minimal Dependencies
- No Portainer Required: Only Docker and Docker Compose needed
- Simpler Infrastructure: Fewer moving parts
- Standard Tools: Uses widely-known Docker tooling
Flexibility
- Custom Modifications: Easy to add custom services or configurations
- Script Integration: Can be integrated into custom deployment scripts
- CI/CD Friendly: Works well with automated deployment pipelines
When to Use Docker Compose
✅ Use Docker Compose when:
- Portainer infrastructure is not available
- You prefer command-line operations
- You need maximum transparency
- You have custom deployment requirements
- You're integrating with existing automation
- You have only one or few deployments
❌ Consider Portainer when:
- You manage multiple environments
- You prefer GUI-based management
- You need remote management capabilities
- You want simplified update processes
Operational Responsibilities
With Docker Compose deployment, administrators are responsible for:
Deployment
- Copying deployment package to host
- Creating and configuring .env file
- Preparing certificate directories
- Running docker-compose commands
- Verifying successful startup
Updates
- Obtaining new deployment package
- Comparing new and old compose files
- Updating .env file with new variables
- Pulling new images
- Recreating containers
- Validating update success
Monitoring
- Checking container health manually
- Reviewing logs for errors
- Monitoring disk usage
- Tracking resource consumption
Troubleshooting
- Diagnosing container failures
- Reviewing Docker logs
- Fixing configuration issues
- Resolving network problems
Best Practices
- Version Control .env Template: Keep .env.example in version control, not actual .env
- Document Custom Changes: If you modify docker-compose.yaml, document why
- Test Before Production: Test deployment in staging environment
- Backup Configuration: Keep backups of .env and custom configurations
- Use Absolute Paths: Use absolute paths for volume mounts
- Monitor Logs: Regularly check logs for errors
- Plan Upgrades: Review changelog before upgrading
- Keep Notes: Document deployment-specific decisions
Security Considerations
.env File Security
- Permissions: Set restrictive permissions (600 or 640)
- No Version Control: Never commit .env to git
- Secure Storage: Store backups securely
- Access Control: Limit who can read .env file
Docker Socket Access
- SSH Security: Secure SSH access to Docker host
- User Permissions: Limit who can run docker commands
- Audit Logging: Log docker command execution
Certificate Security
- File Permissions: Ensure certificates are readable by Docker
- Secure Transfer: Use secure methods to transfer certificates to host
- Rotation: Plan for certificate renewal and rotation
Comparison with Portainer
| Aspect | Docker Compose | Portainer |
|---|---|---|
| Deployment Method | Command-line | GUI |
| Remote Management | Requires SSH | Via Edge Agent |
| Update Process | Manual | One-click |
| Learning Curve | Low (if familiar with Docker) | Moderate |
| Infrastructure | Minimal | Requires Portainer Server |
| Transparency | High | Moderate |
| Operational Overhead | Higher | Lower |
| Multi-Environment | Per-environment management | Centralized |
| Audit Trail | Manual | Built-in |
| Rollback | Manual | Simple |
Troubleshooting
Common Issues
Containers Not Starting
- Check .env file for missing variables
- Verify certificate paths exist
- Review logs:
docker-compose logs
Port Conflicts
- Check if ports are already in use
- Modify port mappings in .env or compose file
Volume Permission Issues
- Ensure volume directories exist
- Check directory permissions
- Verify Docker has access to mount paths
Image Pull Failures
- Verify internet connectivity
- Check Docker registry access
- Ensure correct image tags in compose file
Cross-Reference
- See Limitations for Docker Compose constraints
- See Installation Guide for setup steps
- See Upgrade Process for update procedures