Skip to content

Inconsistent docker-compose path resolution in multi-module project #45169

@devmizz

Description

@devmizz

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: password

root/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.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

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: invalidAn issue that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions