This document describes the Docker Compose setup for the Momentum Scanner application.
- Image:
mysql:8.0(official MySQL image) - Port:
3306 - Database:
momentum_scanner - User:
momentum_user - Password:
momentum_password - Root Password:
rootpassword
- Port:
8000 - Depends on: MySQL
- Environment: Development mode
- Port:
3000 - Depends on: Backend
- Environment: Development mode
- Docker
- Docker Compose
-
Start all services:
docker-compose up -d
-
View logs:
docker-compose logs -f
-
Stop all services:
docker-compose down
-
Stop and remove volumes:
docker-compose down -v
- Host:
localhost - Port:
3306 - Database:
momentum_scanner - Username:
momentum_user - Password:
momentum_password
- Host:
mysql - Port:
3306 - Database:
momentum_scanner - Username:
momentum_user - Password:
momentum_password
Create a .env file in the root directory with the following variables:
# Database Configuration
MYSQL_ROOT_PASSWORD=rootpassword
MYSQL_DATABASE=momentum_scanner
MYSQL_USER=momentum_user
MYSQL_PASSWORD=momentum_password
# Backend Configuration
DATABASE_URL=mysql://momentum_user:momentum_password@mysql:3306/momentum_scanner
NODE_ENV=development
# Frontend Configuration
REACT_APP_API_URL=http://localhost:8000Place SQL initialization scripts in the ./backend/init/ directory. These scripts will be executed when the MySQL container starts for the first time.
mysql_data: Persistent storage for MySQL data./backend:/app: Backend source code mounting./frontend:/app: Frontend source code mounting
All services are connected through the momentum-network bridge network for internal communication.
- Update
MYSQL_ROOT_PASSWORD - Update
MYSQL_PASSWORD - Use strong, unique passwords
- Consider using Docker secrets for production
-
Check if MySQL container is running:
docker-compose ps
-
View MySQL logs:
docker-compose logs mysql
-
Connect to MySQL container:
docker-compose exec mysql mysql -u momentum_user -p momentum_scanner
If ports are already in use, modify the port mappings in docker-compose.yml:
- MySQL: Change
3306:3306to3307:3306 - Backend: Change
8000:8000to8001:8000 - Frontend: Change
3000:3000to3001:3000
- Start services:
docker-compose up -d - Make code changes in
./backendor./frontend - Changes are automatically reflected due to volume mounting
- Restart services if needed:
docker-compose restart [service-name]