This project includes multiple Docker Compose configurations for different purposes. Each configuration serves a specific use case and has different characteristics.
Purpose: Run the complete DreamRoute application with database for production or development.
Command:
docker compose up --buildWhat it does:
- Builds the SpringBoot application from
Dockerfile - Starts a MySQL 8.0 database with persistent storage
- Exposes the application on port 8080
- Exposes the database on port 3306 for external access
- Uses
restart: unless-stoppedpolicy for high availability - Includes health checks for both services
- Creates a custom network for service communication
Key differences:
- Full production-ready setup with persistent data volumes
- Includes port mappings for external access
- Automatic restart policies
- Health checks and service dependencies
Purpose: Run tests using a custom test-specific Dockerfile.
Command:
docker compose --file docker-compose-test-with-dockerfile.yml run --rm dreamroute-testWhat it does:
- Builds a custom test image from
Dockerfile-test - Starts a test database (no external port exposure)
- Runs the test suite within the custom container
- Automatically removes containers after execution
Key differences:
- Uses custom
Dockerfile-testfor test environment - Allows for test-specific dependencies and configurations
- More control over the test environment
restart: neverpolicy (single-run containers)- No external database port exposure
Purpose: Run tests using the official Maven Docker image without building a custom image.
Command:
docker compose --file docker-compose-test.yml run --rm dreamroute-testWhat it does:
- Uses the official
maven:3.9.11-eclipse-temurin-24image - Mounts the source code as a read-only volume
- Runs
mvn -Ptest clean verifywith test profile to execute tests - Uses test profile to avoid building/writing JAR files to source directory
- Starts a test database (no external port exposure)
- Automatically removes containers after execution (
--rmflag)
Key differences:
- No custom Docker image building required
- Faster startup (uses pre-built Maven image)
- Read-only source code mounting (safe because test profile doesn't write JAR)
- Test profile prevents artifact generation in source directory
restart: neverpolicy (single-run containers)- No external database port exposure
- Ideal for CI/CD pipelines
| Configuration | Use Case | Database Port | App Port | Restart Policy | Image Source |
|---|---|---|---|---|---|
docker-compose.yml |
Production/Development | 3306 | 8080 | unless-stopped | Custom Dockerfile |
docker-compose-test-with-dockerfile.yml |
Testing (Custom) | None | None | never | Custom Dockerfile-test |
docker-compose-test.yml |
Testing (Maven) | None | None | never | Maven official image |
All configurations use the same environment variables:
SPRING_PROFILES_ACTIVE=dockerSERVER_PORT=8080DB_URL=jdbc:mysql://[service-name]:3306/mynotesDB_USERNAME=rootDB_PASSWORD=root