-
Notifications
You must be signed in to change notification settings - Fork 41.1k
Inconsistent docker-compose path resolution in multi-module project #45169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hello @devmizz Unfortunately, you haven't provided details about exactly how you're running your application, but I'll assume you're using IntelliJ IDEA. When you run However, when executing tests, IntelliJ IDEA uses the module directory as the working directory ( I've tried running your application directly via Gradle: cd app
gradle bootRun However, it fails due to the same issue:
If you remove the application.yaml: spring:
docker:
compose:
enabled: true
service: spring-practice
lifecycle-management: start_only
stop:
command: down
skip:
in-tests: false
file: docker/docker-compose.yaml docker-compose.yaml: services:
mysql:
container_name: practice-mysql
image: mysql:8.0
ports:
- '3308:3306'
environment:
MYSQL_DATABASE: practice
MYSQL_USER: user
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: password
restart: always
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
- --skip-character-set-client-handshake
redis:
image: redis:alpine
ports:
- "6380:6379" Then both Gradle tasks, You can also specify the working directory when running your Spring Boot application: ![]() |
@nosan Thank you very much for your detailed response. It seems the issue was caused by how IntelliJ IDEA sets the working directory at runtime. I’ll make sure to configure the working directory properly when setting up the Docker environment in a multi-module project. Thanks again for the thorough explanation — I’ll close the issue. |
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
root/app/src/main/resources/application.yaml
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
Even 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
The text was updated successfully, but these errors were encountered: