Skip to content

Commit a3181de

Browse files
authored
Merge pull request #69 from devondragon/feature/68-refactor-compose-naming
Refactor Docker Compose file naming to avoid V2 precedence conflict
2 parents 0729720 + a538671 commit a3181de

File tree

7 files changed

+122
-110
lines changed

7 files changed

+122
-110
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
1212
## 2026-03-22
1313

1414
### Changed
15+
- Refactored Docker Compose file naming to avoid V2 precedence conflict (#68)
16+
- `compose.yaml``compose.dev.yaml` (dev dependencies for `bootRun`)
17+
- `docker-compose.yml``compose.yaml` (full deployable stack)
18+
- Added `spring.docker.compose.file` to `application-local.yml-example`
19+
- Updated README with compose file descriptions and Docker Compose V2 syntax
1520
- Refactored `TestDataController` to use `Instant` instead of `Date` for registration dates, aligning with library changes (#65)
1621

1722
### Dependencies

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ The fastest way to get started is using Docker Compose:
117117
# Clone and start everything
118118
git clone https://github.com/devondragon/SpringUserFrameworkDemoApp.git
119119
cd SpringUserFrameworkDemoApp
120-
docker-compose up --build
120+
docker compose up --build
121121
```
122122

123123
**Access the Application**: `http://localhost:8080`
@@ -166,7 +166,7 @@ docker-compose up --build
166166
```
167167
- Using Docker Compose with Keycloak stack:
168168
```bash
169-
docker-compose -f docker-compose-keycloak.yml up --build
169+
docker compose -f docker-compose-keycloak.yml up --build
170170
```
171171

172172
5. **Access the Application**
@@ -510,13 +510,18 @@ mvn spring-boot:run
510510
511511
The project includes a complete Docker setup with the application, MariaDB database, and a mail server.
512512
513+
**Docker Compose files:**
514+
- **`compose.yaml`** — Full deployable stack (app + database + mail server). Use this to run the entire application in Docker.
515+
- **`compose.dev.yaml`** — Dev dependencies only (database). Used automatically by Spring Boot's Docker Compose integration during `bootRun` for local development.
516+
- **`docker-compose-keycloak.yml`** — Full stack with Keycloak for OIDC authentication testing.
517+
513518
```bash
514-
docker-compose up --build
519+
docker compose up --build
515520
```
516521
517522
To launch the Keycloak stack:
518523
```bash
519-
docker-compose -f docker-compose-keycloak.yml up --build
524+
docker compose -f docker-compose-keycloak.yml up --build
520525
```
521526
522527
**Note**: Test emails sent from the local Postfix server may not be accepted by all email providers. Use a real SMTP server for production use.
@@ -695,7 +700,7 @@ Solution:
695700
1. Check SMTP configuration in application.yml
696701
2. Verify mail server credentials
697702
3. Check spam/junk folders
698-
4. Use Docker mail server for testing: docker-compose logs mailserver
703+
4. Use Docker mail server for testing: docker compose logs mailserver
699704
```
700705
701706
#### Application Won't Start

compose.dev.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Local Development Database Configuration
2+
# WARNING: These credentials are for LOCAL DEVELOPMENT ONLY.
3+
# Production deployments MUST use secure credentials managed through
4+
# environment variables or secrets management systems.
5+
6+
services:
7+
mariadb:
8+
image: mariadb:12.2
9+
environment:
10+
MARIADB_DATABASE: springuser
11+
MARIADB_USER: springuser
12+
MARIADB_PASSWORD: springuser
13+
MARIADB_ROOT_PASSWORD: rootpassword
14+
ports:
15+
- "3306:3306"
16+
volumes:
17+
- mariadb-data:/var/lib/mysql
18+
19+
volumes:
20+
mariadb-data:

compose.yaml

Lines changed: 82 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,91 @@
1-
# Local Development Database Configuration
2-
# WARNING: These credentials are for LOCAL DEVELOPMENT ONLY.
3-
# Production deployments MUST use secure credentials managed through
4-
# environment variables or secrets management systems.
51

62
services:
7-
mariadb:
3+
myapp-db:
84
image: mariadb:12.2
5+
container_name: springuser-db
6+
volumes:
7+
- userdb:/var/lib/mysql
98
environment:
10-
MARIADB_DATABASE: springuser
11-
MARIADB_USER: springuser
12-
MARIADB_PASSWORD: springuser
13-
MARIADB_ROOT_PASSWORD: rootpassword
9+
MYSQL_ROOT_PASSWORD: root
10+
MYSQL_DATABASE: springuser
11+
MYSQL_USER: springuser
12+
MYSQL_PASSWORD: springuser
13+
MYSQL_TCP_PORT: 3306
1414
ports:
1515
- "3306:3306"
16+
healthcheck:
17+
test: [ "CMD", "healthcheck.sh", "--connect", "--innodb_initialized" ]
18+
start_period: 1m
19+
start_interval: 10s
20+
interval: 1m
21+
timeout: 5s
22+
retries: 3
23+
24+
mailserver:
25+
image: docker.io/mailserver/docker-mailserver:latest
26+
container_name: springuser-mail
27+
hostname: mailserver
28+
domainname: local
29+
env_file: mailserver.env
30+
ports:
31+
- "25:25"
32+
- "587:587"
1633
volumes:
17-
- mariadb-data:/var/lib/mysql
34+
- maildata:/var/mail
35+
- mailstate:/var/mail-state
36+
- maillogs:/var/log/mail
37+
- ./config/:/tmp/docker-mailserver/${SELINUX_LABEL}
38+
environment:
39+
PERMIT_DOCKER: connected-networks
40+
ONE_DIR: 1
41+
DMS_DEBUG: 0
42+
SPOOF_PROTECTION: 0
43+
REPORT_RECIPIENT: 1
44+
ENABLE_SPAMASSASSIN: 0
45+
ENABLE_CLAMAV: 0
46+
ENABLE_FAIL2BAN: 1
47+
ENABLE_POSTGREY: 0
48+
SMTP_ONLY: 1
49+
cap_add:
50+
- NET_ADMIN
51+
- SYS_PTRACE
52+
healthcheck:
53+
test: ["CMD", "nc", "-z", "localhost", "25"]
54+
interval: 30s
55+
timeout: 10s
56+
retries: 5
57+
58+
myapp-main:
59+
image: spring-user-framework-demo
60+
container_name: springuser-app
61+
build:
62+
context: .
63+
dockerfile: Dockerfile
64+
depends_on:
65+
myapp-db:
66+
condition: service_healthy
67+
mailserver:
68+
condition: service_healthy
69+
ports:
70+
- "8080:8080"
71+
environment:
72+
SPRING_DATASOURCE_URL: jdbc:mariadb://myapp-db:3306/springuser?createDatabaseIfNotExist=true
73+
SPRING_DATASOURCE_USERNAME: springuser
74+
SPRING_DATASOURCE_PASSWORD: springuser
75+
SPRING_PROFILES_ACTIVE: dev
76+
SPRING_MAIL_HOST: mailserver
77+
SPRING_MAIL_PORT: 25
78+
SPRING_MAIL_PROPERTIES_MAIL_SMTP_AUTH: "false"
79+
SPRING_MAIL_PROPERTIES_MAIL_SMTP_STARTTLS_ENABLE: "false"
80+
SPRING_MAIL_PROPERTIES_MAIL_SMTP_STARTTLS_REQUIRED: "false"
81+
healthcheck:
82+
test: ["CMD", "wget", "-qO-", "http://localhost:8080/actuator/health"]
83+
interval: 30s
84+
timeout: 10s
85+
retries: 5
1886

1987
volumes:
20-
mariadb-data:
88+
maildata:
89+
mailstate:
90+
maillogs:
91+
userdb:

docker-compose-keycloak.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: "3.8"
22

33
services:
44
myapp-db:
5-
image: mariadb:11.6.2
5+
image: mariadb:12.2
66
container_name: springuser-db #
77
volumes:
88
- userdb:/var/lib/mysql

docker-compose.yml

Lines changed: 0 additions & 91 deletions
This file was deleted.

src/main/resources/application-local.yml-example

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ logging:
77
org:
88
springframework:
99
web: DEBUG # Set logging level for web
10-
filter:
11-
CommonsRequestLoggingFilter: DEBUG # Set logging level for CommonsRequestLoggingFilter
10+
web.filter.CommonsRequestLoggingFilter: DEBUG # Set logging level for CommonsRequestLoggingFilter
1211
security: DEBUG # Set logging level for security
1312

1413
spring:
14+
docker:
15+
compose:
16+
file: compose.dev.yaml
1517
application:
1618
name: Spring User Framework Demo App # Change this as per your convenience
1719
datasource:

0 commit comments

Comments
 (0)