forked from Femcoders-Travellers/DreamRoute
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-compose-test.yml
More file actions
99 lines (82 loc) · 3.62 KB
/
docker-compose-test.yml
File metadata and controls
99 lines (82 loc) · 3.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# Docker Compose configuration for DreamRoute testing with Maven image
# This configuration runs tests using the official Maven Docker image
# without building a custom container image
services:
# Test service using official Maven image
dreamroute-test:
# Use official Maven image with Eclipse Temurin JDK 21
image: maven:3.9.11-eclipse-temurin-21
# Set working directory inside container
working_dir: /src
# Mount source code as read-only volume for testing
volumes:
- type: bind
source: . # Current directory (project root)
target: /src # Mount point inside container
read_only: true # Prevent modifications to source code
# Run Maven test command with test profile
# Using -Ptest profile to avoid building JAR files (allows read-only source mounting)
entrypoint: ["mvn", "-Ptest", "clean", "verify", "--no-transfer-progress"]
# Custom container name for easier identification
container_name: dreamroute-test
# Environment variables passed to the SpringBoot application
environment:
- SHOW_SQL=false
- SERVER_PORT=8080 # Sets the server port inside container
- DB_URL=jdbc:mysql://dreamroute-test-db:3306/dreamroute # Database connection URL using service name
- DB_USERNAME=dreamroute # Database username
- DB_PASSWORD=dreamroute123 # Database password
# Restart policy - never restart (single-run test container)
restart: no
# Service dependencies - ensures database is healthy before starting app
depends_on:
dreamroute-test-db:
condition: service_healthy # Wait for DB health check to pass
# Health check configuration for the SpringBoot application
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health"] # Health check command
interval: 30s # Check every 30 seconds
timeout: 10s # Timeout after 10 seconds
retries: 3 # Retry 3 times before marking as unhealthy
start_period: 60s # Wait 60 seconds before starting health checks
# Connect to custom network
networks:
- dreamroute-network
# MySQL database service for testing
dreamroute-test-db:
# Use official MySQL 8.0 image from Docker Hub
image: mysql:8.0
# Custom container name for easier identification
container_name: dreamroute-test-db
# MySQL environment variables for database initialization
environment:
MYSQL_DATABASE: dreamroute # Creates database named 'dreamroute'
MYSQL_USER: dreamroute # Creates user 'dreamroute'
MYSQL_PASSWORD: dreamroute123 # Sets password for 'dreamroute' user
MYSQL_ROOT_PASSWORD: root123 # Sets root user password
# Restart policy - never restart (single-run test container)
# No external port mapping - database only accessible from within the network
restart: no
# Health check configuration for MySQL database
healthcheck:
test: [
"CMD",
"mysqladmin", # MySQL admin utility
"ping", # Ping command to check if MySQL is responding
"-h",
"localhost", # Connect to localhost
"-u",
"dreamroute", # Use dreamroute user for health check
"-pdreamroute123", # Password for dreamroute user
]
interval: 10s # Check every 10 seconds
timeout: 5s # Timeout after 5 seconds
retries: 5 # Retry 5 times before marking as unhealthy
start_period: 30s # Wait 30 seconds before starting health checks
# Connect to custom network
networks:
- dreamroute-network
# Network configuration
networks:
dreamroute-network:
driver: bridge # Use bridge driver for container-to-container communication