spring-boot icon indicating copy to clipboard operation
spring-boot copied to clipboard

Add support for DevContainers

Open dieter-medium opened this issue 6 months ago • 3 comments

I am using DevContainers in my development setup with Docker Compose, but I am encountering difficulties in integrating it seamlessly with Spring Boot's Docker Compose support. Specifically, my devcontainer.json configuration looks like this:

{
  "dockerComposeFile": [
    "../compose.yaml",
    "./compose.override.yaml"
  ],
  "mounts": [
    "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind"
  ]
}

Due to this setup, I can't use Spring Boot's Docker Compose integration directly. Currently, I have to disable Docker Compose with:

spring.docker.compose.enabled=false

Then, I manually configure a DockerCompose bean:

@Bean
public DockerCompose dockerCompose() {
    return DockerCompose.get(
            DockerComposeFile.find(new File(".")),
            null,
            new HashSet<String>()
    );
}

While this allows me to get a list of all services, to obtain service connections, I need to copy and modify for instance RedisDockerComposeConnectionDetailsFactory, change some access modifiers, and tweak RunningService slightly.

Suggested Solution:

  • Native DevContainers Support: Enhance Spring Boot's Docker Compose integration to natively support DevContainers configurations. This includes recognizing dockerComposeFile and mounts from devcontainer.json.

  • Improved Service Connection Handling: Simplify the process to get service connections without needing to copy and modify existing connection details factories. Providing a more flexible API or built-in support for common DevContainers setups would be beneficial.

Benefits:

  • Seamless Integration: Developers using DevContainers can leverage Spring Boot's Docker Compose support without extensive custom configurations.
  • Improved Developer Experience: Reduces the need for workarounds, making it easier to manage services and connections in a DevContainer setup.
  • Consistent Configuration: Aligns Spring Boot's Docker Compose functionality with modern development practices involving DevContainers.

dieter-medium avatar Aug 02 '24 18:08 dieter-medium