Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b1666f0

Browse files
authored
Merge pull request #7 from kasramp/spring-boot-docker-compose
#6 Spring Boot Docker Compose integration
2 parents 1b775d1 + da9f1e3 commit b1666f0

File tree

5 files changed

+59
-20
lines changed

5 files changed

+59
-20
lines changed

‎README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,21 @@ For this example, we created a Book controller that allows doing the following o
1717

1818
## How to run
1919

20-
The first thing to do is to start Elasticsearch. For that, you can use the `docker-compose` file in this project and run it like this:
20+
### Spring Boot 3.1
21+
22+
Since this project uses Spring Boot 3.1, all you need to do is to run the application:
23+
24+
```bash
25+
$ ./mvnw spring-boot:run
26+
```
27+
28+
Spring Boot automatically detects the `docker-compose` file and starts the Elasticsearch container.
29+
30+
### Spring Boot 3.0 and prior
31+
32+
The older version of this project uses Spring Boot 3.0 which does not have Spring Boot Docker Compose integration.
33+
34+
To run an older version of the application, the first thing to do is to start Elasticsearch. For that, you can use the `docker-compose` file in this project and run it like this:
2135

2236
```bash
2337
$ docker-compose -f docker-compose up -d
@@ -48,4 +62,4 @@ To run the integration test (using Testcontainers) just run the below command:
4862
$ mvn clean verify
4963
```
5064

51-
Make sure you have your docker running.
65+
Make sure you have your docker running.

‎docker-compose-fix-port.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
services:
2+
elasticsearch:
3+
image: elasticsearch:8.11.3
4+
container_name: elasticsearch
5+
ports:
6+
- "9200:9200"
7+
environment:
8+
- discovery.type=single-node
9+
- cluster.name=elasticsearch
10+
# Since ES 8, SSL is on by default, disabling on local
11+
- xpack.security.enabled=false

‎docker-compose.yml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
elasticsearch:
2-
image: elasticsearch:8.7.0
3-
container_name: elasticsearch
4-
ports:
5-
- "9200:9200"
6-
environment:
7-
- discovery.type=single-node
8-
- cluster.name=elasticsearch
9-
# Since ES 8, SSL is on by default, disabling on local
10-
- xpack.security.enabled=false
1+
services:
2+
elasticsearch:
3+
image: elasticsearch:8.11.3
4+
container_name: elasticsearch
5+
ports:
6+
# Map the 9200 port to a random port on host
7+
- "9200"
8+
environment:
9+
- discovery.type=single-node
10+
- cluster.name=elasticsearch
11+
# Since ES 8, SSL is on by default, disabling on local
12+
- xpack.security.enabled=false

‎pom.xml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.springframework.boot</groupId>
77
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>3.1.0</version>
8+
<version>3.2.1</version>
99
</parent>
1010
<groupId>com.madadipouya.elasticsearch.springdata.example</groupId>
1111
<artifactId>elasticsearch-springdata</artifactId>
@@ -15,8 +15,8 @@
1515

1616
<properties>
1717
<java.version>17</java.version>
18-
<mockito.version>5.3.1</mockito.version>
19-
<testcontainers.version>1.18.3</testcontainers.version>
18+
<mockito.version>5.8.0</mockito.version>
19+
<testcontainers.version>1.19.3</testcontainers.version>
2020
</properties>
2121

2222
<dependencies>
@@ -35,7 +35,12 @@
3535
<dependency>
3636
<groupId>org.springdoc</groupId>
3737
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
38-
<version>2.1.0</version>
38+
<version>2.3.0</version>
39+
</dependency>
40+
<dependency>
41+
<groupId>org.springframework.boot</groupId>
42+
<artifactId>spring-boot-docker-compose</artifactId>
43+
<optional>true</optional>
3944
</dependency>
4045
<dependency>
4146
<groupId>org.springframework.boot</groupId>
@@ -45,7 +50,7 @@
4550
<dependency>
4651
<groupId>org.junit.jupiter</groupId>
4752
<artifactId>junit-jupiter-engine</artifactId>
48-
<version>5.9.3</version>
53+
<version>5.10.1</version>
4954
<scope>test</scope>
5055
</dependency>
5156
<dependency>
@@ -88,12 +93,12 @@
8893
<plugin>
8994
<groupId>org.apache.maven.plugins</groupId>
9095
<artifactId>maven-surefire-plugin</artifactId>
91-
<version>3.1.2</version>
96+
<version>3.2.3</version>
9297
</plugin>
9398
<plugin>
9499
<groupId>org.apache.maven.plugins</groupId>
95100
<artifactId>maven-failsafe-plugin</artifactId>
96-
<version>3.1.2</version>
101+
<version>3.2.3</version>
97102
<configuration>
98103
<skipTests>false</skipTests>
99104
<rerunFailingTestsCount>3</rerunFailingTestsCount>
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
spring.data.elasticsearch.repositories.enabled=true
22
# comma-separated list of the Elasticsearch instances to use.
3+
# since Spring Boot 3.1 with docker-compose support, the properties override automatically
4+
# documentation: https://spring.io/blog/2023/06/21/docker-compose-support-in-spring-boot-3-1
35
spring.elasticsearch.uris=${ES_URI:localhost}:9200
46

57
management.endpoints.web.base-path=/
68
management.endpoints.jmx.exposure.include=*
79
management.endpoint.health.show-details=always
8-
management.health.elasticsearch.enabled=false
10+
management.health.elasticsearch.enabled=false
11+
12+
# custom docker compose file
13+
# spring.docker.compose.file=./docker-compose-fix-port.yml
14+
# to disable docker compose
15+
# spring.docker.compose.enabled=false

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /