-
Notifications
You must be signed in to change notification settings - Fork 41.8k
Description
Hello,
I’m currently using the docker-compose dependency in a multi-module project.
In one of the submodules, I configured the application.yaml to reference the path to the Docker Compose file, and it works correctly when running the main application. However, I encountered an issue when writing tests that also rely on the same docker-compose setup: an exception is thrown indicating that the Compose file cannot be found at the specified path.
For example, assuming the root project is named root, the submodule is app, and the Docker Compose file is located at root/app/docker/docker-compose.yaml
root/app/docker/docker-compose.yaml
services:
mysql:
container_name: practice-mysql
image: mysql:8.0
environment:
MYSQL_DATABASE: practice
MYSQL_USER: user
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: passwordroot/app/src/main/resources/application.yaml
spring:
docker:
compose:
enabled: true
service: spring-practice
stop:
command: down
skip:
in-tests: false
file: app/docker/docker-compose.yaml
- When running the main application, FS.userDir is set to root
- But when running tests, FS.userDir is set to root/app
Because of this difference, the path resolution behaves inconsistently between main and test executions. As a workaround, I ended up duplicating the application.yaml under the test resources and customizing the path manually for tests.
root/app/test/resources/application.yaml
spring:
docker:
compose:
# ...
file: docker/docker-compose.yamlEven though the Docker Compose file is located in the same path, the behavior varies depending on whether the main application or tests are being run. This inconsistency can lead to confusion and misconfiguration.
Would it be possible to improve this so that the Compose file path resolution is consistent within the same module, regardless of whether it’s running as part of the main application or during tests?
Here is my sub-module link