Docker Development
This guide focuses on setting up a development environment for OpenAlgo using Docker.
Prerequisites
Docker Engine
Docker Compose
Git
Essential .env Changes for Docker Setup
1. Flask Host Configuration
2. WebSocket Configuration
3. ZeroMQ Configuration
Summary of Changes
From (Local Development):
To (Docker):
Why These Changes?
0.0.0.0 vs 127.0.0.1:
127.0.0.1only allows connections from within the container0.0.0.0allows connections from outside the container (host machine)
WEBSOCKET_URL:
Remains as
ws://localhost:8765because this is the URL clients use from the host machineDocker maps the container's port to the host's localhost
No other changes needed:
All other settings (API keys, database URLs, etc.) remain the same
The docker-compose.yaml already maps the ports correctly
Files Required
1. Dockerfile
2. docker-compose.yml
3. .dockerignore
Quick Start
Create Environment File:
Copy
.sample.envto.env:Build and Start:
View Logs:
Development Features
Hot reload enabled (code changes reflect immediately)
Debug mode active
Console logging
Port 5000 exposed
Volume mounting for live code updates
Common Commands
Directory Structure
Development Tips
Live Reload:
Code changes will automatically reload
Check logs for errors after changes
Database Access:
SQLite database persists in ./db directory
Can be accessed from both host and container
Debugging:
Logs are printed to console
Debug mode enables detailed error pages
Dependencies:
Add new packages to requirements-nginx.txt
Rebuild container after adding dependencies:
Troubleshooting
Port Already In Use:
Database Issues:
Container Won't Start:
Package Installation Issues:
Note
This configuration is optimized for development. For production deployment, additional security measures and optimizations would be necessary.
Last updated
Was this helpful?