Skip to content

Commit 6fd1509

Browse files
committed
ci(docker-compose-test.yml): update docker compose test
1 parent 8a360be commit 6fd1509

1 file changed

Lines changed: 15 additions & 68 deletions

File tree

docker-compose-test.yml

Lines changed: 15 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,46 @@
1-
# Docker Compose configuration for SitMe testing with Maven image
2-
# This configuration runs tests using the official Maven Docker image
3-
# without building a custom container image
4-
51
services:
6-
# Test service using official Maven image
72
test:
8-
# Use official Maven image with Eclipse Temurin JDK 21
93
image: maven:3.9.11-eclipse-temurin-21
104

11-
# Set working directory inside container
125
working_dir: /src
136

14-
# Mount source code as read-only volume for testing
157
volumes:
168
- type: bind
17-
source: . # Current directory (project root)
18-
target: /src # Mount point inside container
19-
read_only: true # Prevent modifications to source code
9+
source: .
10+
target: /src
11+
read_only: true
2012

21-
# Run Maven test command with test profile
22-
# Using -Ptest profile to avoid building JAR files (allows read-only source mounting)
23-
entrypoint: ["mvn", "-Ptest", "clean", "verify", "--no-transfer-progress"]
13+
entrypoint: ["mvn", "-Ptest", "clean", "verify", "-Dspring.profiles.active=test", "--no-transfer-progress"]
2414

25-
# Custom container name for easier identification
2615
container_name: test
2716

28-
# Environment variables passed to the SpringBoot application
2917
environment:
30-
- SPRING_PROFILES_ACTIVE=docker # Activates Docker-specific configuration profile
31-
- SERVER_PORT=8080 # Sets the server port inside container
32-
- DB_URL=jdbc:mysql://test-db:3306/sitme # Database connection URL using service name
33-
- DB_USERNAME=sitme # Database username
34-
- DB_PASSWORD=sitme123 # Database password
18+
- SPRING_PROFILES_ACTIVE=test
19+
- SERVER_PORT=8080
3520

36-
# Restart policy - never restart (single-run test container)
3721
restart: no
3822

39-
# Service dependencies - ensures database is healthy before starting app
4023
depends_on:
41-
test-db:
42-
condition: service_healthy # Wait for DB health check to pass
43-
44-
# Health check configuration for the SpringBoot application
45-
healthcheck:
46-
test: ["CMD", "curl", "-f", "http://localhost:8080/actuator/health"] # Health check command
47-
interval: 30s # Check every 30 seconds
48-
timeout: 10s # Timeout after 10 seconds
49-
retries: 3 # Retry 3 times before marking as unhealthy
50-
start_period: 60s # Wait 60 seconds before starting health checks
24+
mailhog:
25+
condition: service_started
5126

52-
# Connect to custom network
5327
networks:
5428
- test-network
5529

56-
# MySQL database service for testing
57-
test-db:
58-
# Use official MySQL 8.0 image from Docker Hub
59-
image: mysql:8.0
30+
mailhog:
31+
image: mailhog/mailhog:latest
6032

61-
# Custom container name for easier identification
62-
container_name: test-db
33+
container_name: test-mailhog
6334

64-
# MySQL environment variables for database initialization
65-
environment:
66-
MYSQL_DATABASE: sitme # Creates database named 'sitme'
67-
MYSQL_USER: sitme # Creates user 'sitme'
68-
MYSQL_PASSWORD: sitme123 # Sets password for 'sitme' user
69-
MYSQL_ROOT_PASSWORD: root123 # Sets root user password
35+
ports:
36+
- "1025:1025"
37+
- "8025:8025"
7038

71-
# Restart policy - never restart (single-run test container)
72-
# No external port mapping - database only accessible from within the network
7339
restart: no
7440

75-
# Health check configuration for MySQL database
76-
healthcheck:
77-
test: [
78-
"CMD",
79-
"mysqladmin", # MySQL admin utility
80-
"ping", # Ping command to check if MySQL is responding
81-
"-h",
82-
"localhost", # Connect to localhost
83-
"-u",
84-
"sitme", # Use sitme user for health check
85-
"-psitme123", # Password for sitme user
86-
]
87-
interval: 10s # Check every 10 seconds
88-
timeout: 5s # Timeout after 5 seconds
89-
retries: 5 # Retry 5 times before marking as unhealthy
90-
start_period: 30s # Wait 30 seconds before starting health checks
91-
92-
# Connect to custom network
9341
networks:
9442
- test-network
9543

96-
# Network configuration
9744
networks:
9845
test-network:
99-
driver: bridge # Use bridge driver for container-to-container communication
46+
driver: bridge

0 commit comments

Comments
 (0)