Açıklaması şöyle
When your app is starting up, the Docker Compose integration will look for a configuration file in the current working directory. The following files are supported:- compose.yaml- compose.yml- docker-compose.yaml- docker-compose.ymlTo use a non-standard file, set the spring.docker.compose.file property.
Maven
Şöyle yaparız
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-docker-compose</artifactId><optional>true</optional></dependency>
Gradle
Şöyle yaparız
dependencies {
developmentOnly("org.springframework.boot:spring-boot-docker-compose")
}Örnek - docker-compose.yaml
Şöyle yaparız. Böylece uygulamayı çalıştırırken veri tabanı da çalışır
version: '3.1'
services:
db:
image: postgres
restart: always
ports:
- "5432:5432"
environment:
POSTGRES_USERNAME: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: merchant_dbspring.docker.compose.lifecycle-management Alanı
Açıklaması şöyle
none: Do not start or stop the docker-compose filestart-only: Start the docker-compose file when the application starts and leave itstart-and-stop: Start Docker Compose when the application starts and stop it when the JVM exits (This is the default behavior)
Örnek
Şöyle yaparız
spring.docker.compose.lifecycle-management = START_AND_STOP
spring.docker.compose.file Alanı
application.propertes ile belirtilen docker compose dosyasını da çalıştırır. Eğer istenirse docker-compose.yml dosyasında profile da tanımlanabilir. Böylece spring profile ile eşleşiyorsa bir container çalıştırılır
Örnek
Şöyle yaparız.
spring:
docker:
compose:
file: "./docker/compose.yml"spring.docker.compose.profiles.active Alanı
Örnek
Şöyle yaparız.
docker:
compose:
file: "./docker/docker-compose.yml"
profiles.active: "indexer"