This document describes how to run the Stellar Solar Grid backend using Docker Compose.
- Docker Desktop (Windows/Mac) or Docker Engine (Linux)
- Docker Compose v2 or later
- Clone the repository:
git clone https://github.com/your-org/stellar-solar-grid.git
cd stellar-solar-grid- Configure environment variables:
cp backend/.env.example backend/.env
# Edit backend/.env with your Stellar contract and admin keys- Start the development stack:
docker-compose up --buildThe backend will be available at http://localhost:3001 and the MQTT broker at mqtt://localhost:1883.
The Docker Compose setup includes two services:
| Service | Description | Port |
|---|---|---|
backend |
Node.js REST API server | 3001 |
mqtt |
Eclipse Mosquitto MQTT broker | 1883 (MQTT), 9001 (WebSocket) |
docker-compose logs -fTo follow logs for a specific service:
docker-compose logs -f backend
docker-compose logs -f mqtt# Open a shell in the backend container
docker-compose exec backend sh
# Run npm commands
docker-compose exec backend npm run dev# Restart all services
docker-compose restart
# Restart specific service
docker-compose restart backendEnsure the MQTT_BROKER environment variable is set to mqtt://mqtt:1883 (not localhost). The backend connects to the MQTT service via Docker's internal network.
If ports 1883 or 3001 are already in use, modify the port mappings in docker-compose.yml:
services:
mqtt:
ports:
- "1884:1883" # Map host 1884 to container 1883
backend:
ports:
- "3002:3001" # Map host 3002 to container 3001Ensure you're in the project root directory and have the .env file configured:
ls docker-compose.yml backend/.envFor production, you should:
- Use a proper MQTT broker with authentication
- Configure TLS/SSL for MQTT and API endpoints
- Use a secrets management system instead of
.envfiles - Consider using Docker Swarm or Kubernetes for orchestration