Comments (5)
The profiles are used to decide which services, if any, Spring Boot's integration should start. If one or more of the services in the compose.yaml file is already running, this step is skipped and Spring Boot uses all of the already running services.
Why are you manually starting the services rather than allowing Spring Boot to control their lifecycle? If you omit this step, I believe things should works as you want. Would that meet your needs?
from spring-boot.
Adding to that, I'm not sure we can find out when the services are running to what profile they belong, so filtering them on the profile after they have been started might not be possible.
from spring-boot.
@wilkinsona, I encountered an issue in one of my practice projects with three applications (authorization, client, and resource), each requiring a separate database (hence, multiple DB services). I've organized the project with the following structure:
oauth2
- authorization
- src
- client
- src
- resource
- src
compose.yaml
You can find the project on GitHub: oauth2. The goal is for the authorization application to use only the authorization_database
service and the client application to use the client_database
service.
The authorization application should exclusively utilize the authorization_database
service, while the client application is intended to rely on the client_database
service. Initially, I contemplated utilizing the profile feature in Docker to achieve this segregation. However, upon initiating the first application (authorization), everything seemed to be in order, as it selectively launched the authorization_database
service from the Docker Compose configuration. Subsequently, upon starting the client application, I observed that it failed to initiate the other database service (client_database
). The log displayed a message stating "There are already Docker Compose services running, skipping startup," and the client application's schema files were overwritten on the authorization_database
. To address this, I manually started both services, expecting that specifying an active profile would make Spring Boot pick only the relevant service from Docker Compose. Unfortunately, both services were considered.
I believe there are two issues at play here:
- The profile matching between Spring Boot and Docker Compose is not functioning as expected.
- When starting the second application (client), the
spring.docker.compose.profiles.active=client_database
property is ignored, and it ends up considering the already running service (authorization_database
), leading to schema file conflicts.
from spring-boot.
Thanks for the additional details. The profile matching may not be working as you would like but it is working as expected and, unfortunately, I don't think it will be possible for us to make it work as you would like.
We use docker compose ps
to examine the running services. Unfortunately, it doesn't include any information about the profiles that were active and resulted in the service being started. As such, we can't filter out any existing running services based on the profiles that are active when you start the second application.
For your situation where you have three separate apps and three separate services, I think you would be better using three separate compose.yaml files, one for each app. I also think it would align more closely with the spirit of the Docker Compose documentation and the recommendation that "the core services of your application shouldn't be assigned profiles so they are always enabled and automatically started". As far as I can tell, your current approach relies on every service being assigned to a profile.
from spring-boot.
@wilkinsona Originally, I intended to employ individual compose.yaml
file for each application. However, when initiating the authorization application, it failed to retrieve the file located in the authorization
folder. Consequently, I reverted to placing the compose.yaml
file in the root directory (oauth2
). Just now, I retried the process, but this time, I included the property spring.docker.compose.file=authorization/compose.yaml
. This adjustment successfully enabled the application to recognize and utilize the specified service. I replicated the same modification in the client application, and it is also started working. Thank you!
from spring-boot.
Related Issues (20)
- Gradle test - Out of memory after upgrading from 3.1.6 to 3.2.4 HOT 10
- Jetty support doesn't set virtual thread name
- Spring-boot 3.2.3 Not working as a windows wrapper service HOT 4
- Suggest testAndDevelopmentOnly configuration when using Docker Compose support in tests HOT 6
- Enhance Readability: Add Comments to H2ConsoleAutoConfiguration Class HOT 2
- Kafka consumer related auto-config takes effect even if we are overdefining it HOT 3
- @ConfigurationProperties doesn't properly support Yaml null values HOT 1
- spring.jpa.generate-ddl: true cause schema update even if hibernate options not set HOT 11
- Log4j2LoggingSystem pollutes Log4j2's environment with a SpringEnvironmentPropertySource that is never removed HOT 7
- How to run spring boot web app with http2? HOT 4
- Update JOOQ documentation to explain the compatibility between Spring and JOOQ HOT 1
- JDK 22 & Gradle 8.7 HOT 2
- Readd Jolokia dependency management HOT 2
- Spring Boot application fails to start with Unable to start docker process
- `WebMvcTest` tests fails with `405` when `SpringBootTest` invoked first because of package-private abstract class implementing endpoint in `RestController` hierarchy
- Upgrade to commons-compress 1.26.1 HOT 1
- @WebMvcTest leads to zero interaction with mocked bean HOT 1
- Support generating CDS-Based image HOT 6
- ability to bind property as prefix to Java class with @ConfigurationProperties and as value to property
- Multiple segments in additional health endpoint path
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spring-boot.