spring-projects / spring-projects/spring-boot

Add support for DevContainers

Open
#41,692 3 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

theme: containers type: enhancement
Dominant language
Java
Stars
81.5k
Forks
42.7k
Avg merge
2d 4h
Merged PRs (30d)
65

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review Spring Boot's Docker Compose integration around DockerCompose, RedisDockerComposeConnectionDetailsFactory, and RunningService, then compare its assumptions with the reported devcontainer.json dockerComposeFile and mounts. Done means DevContainers can use the integration without disabling it or copying connection-details factories, with service connections remaining available through a supported API.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, docker-compose, java, spring-boot
Domain
developer-experience, devops, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.