Skip to content
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

Add property to ignore running Docker Compose services #39749

Closed
martin-tarjanyi opened this issue Feb 25, 2024 · 4 comments
Closed

Add property to ignore running Docker Compose services #39749

martin-tarjanyi opened this issue Feb 25, 2024 · 4 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@martin-tarjanyi
Copy link

To reduce startup/shutdown time for local development I'm currently using the start-only option for Docker Compose:

spring.docker.compose.lifecycle-management: start-only

However, I noticed that if I change the existing services in the associated Docker Compose file (change port, volume, env vars, etc.), then these changes are not picked up automatically on the next Spring Boot application startup and I need to manually stop/restart the Compose services to take effect. Of course this is not a very common scenario but I think it's something which could be supported.

I see two possible options to handle this:

  1. In the start-only mode instead of just checking if services are already running, always run a docker compose up or docker compose start which will not do anything if the services are already running but will recreate them if there were changes (when the start command is configured to up )
  2. Add a new option like restart-on-change which under the hood could just call docker compose up which already does this logic: if no changes, use already running service, if there are changes, recreate them. Although, there is a possible conflict here if someone configures the start command to be start instead of up but maybe that can be documented.
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 25, 2024
@sameerbsau

This comment was marked as off-topic.

@scottfrederick
Copy link
Contributor

Something like this was mentioned in a comment on another issue.

I don't think we could change the behavior of the start-only mode without potentially causing problems for users that rely on the way it currently works.

We could consider a new mode like restart that calls docker compose up without verifying services that are already running. restart-on-change would not be a good name for a Spring Boot mode, because it would imply that Boot inspects the docker-compose.yml file to look for changes, which we wouldn't want to do.

@scottfrederick scottfrederick added type: enhancement A general enhancement status: pending-design-work Needs design work before any code can be developed and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 1, 2024
@scottfrederick scottfrederick added this to the 3.x milestone Apr 1, 2024
@mhalbritter
Copy link
Contributor

mhalbritter commented Apr 4, 2024

How about we add a property named spring.docker.compose.start.force, which, if set to true, forces the execution of the start command even if there are services running?

spring.docker.compose.start.force=true
spring.docker.compose.start.command=start

would start additional services.

spring.docker.compose.start.force=true
spring.docker.compose.start.command=up

would start additional services and restart existing services if their configuration changes.

I sketched that in https://github.com/mhalbritter/spring-boot/tree/mh/39749-restart-changed-services-in-docker-compose-when-using-start-only-lifecycle.

@philwebb philwebb changed the title Restart changed services in Docker Compose when using start-only lifecycle Restart changed services in Docker Compose when using start-only lifecycle Apr 4, 2024
@mhalbritter
Copy link
Contributor

We talked about that, and we're going to add a new property spring.docker.compose.start.skip with possible enum values never and if_running.

@mhalbritter mhalbritter self-assigned this Apr 4, 2024
@mhalbritter mhalbritter modified the milestones: 3.x, 3.3.x Apr 4, 2024
@mhalbritter mhalbritter removed the status: pending-design-work Needs design work before any code can be developed label Apr 4, 2024
@mhalbritter mhalbritter changed the title Restart changed services in Docker Compose when using start-only lifecycle Add property to ignore running Docker Compose services Apr 5, 2024
@mhalbritter mhalbritter modified the milestones: 3.3.x, 3.3.0-RC1 Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

5 participants