mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-20 22:35:49 +00:00
add Dockerfile and compose
This commit is contained in:
parent
f94f36f8d8
commit
b189ef36e3
4 changed files with 33 additions and 12 deletions
6
Dockerfile
Normal file
6
Dockerfile
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
FROM openjdk:8-stretch
|
||||||
|
|
||||||
|
COPY target/*.jar /app.jar
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
CMD ["java","-Dspring.profiles.active=mysql","-jar","/app.jar"]
|
|
@ -1,5 +1,8 @@
|
||||||
|
version: "2.2"
|
||||||
|
services:
|
||||||
mysql:
|
mysql:
|
||||||
image: mysql:5.7
|
image: mysql:5.7
|
||||||
|
container_name: db
|
||||||
ports:
|
ports:
|
||||||
- "3306:3306"
|
- "3306:3306"
|
||||||
environment:
|
environment:
|
||||||
|
@ -7,3 +10,15 @@ mysql:
|
||||||
- MYSQL_DATABASE=petclinic
|
- MYSQL_DATABASE=petclinic
|
||||||
volumes:
|
volumes:
|
||||||
- "./conf.d:/etc/mysql/conf.d:ro"
|
- "./conf.d:/etc/mysql/conf.d:ro"
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 5
|
||||||
|
petclinic:
|
||||||
|
image: petclinic:mysql
|
||||||
|
depends_on:
|
||||||
|
mysql:
|
||||||
|
condition: service_healthy
|
||||||
|
ports:
|
||||||
|
- "8080:8080"
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -10,7 +10,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>2.1.4.RELEASE</version>
|
<version>2.1.3.RELEASE</version>
|
||||||
</parent>
|
</parent>
|
||||||
<name>petclinic</name>
|
<name>petclinic</name>
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# database init, supports mysql too
|
# database init, supports mysql too
|
||||||
database=mysql
|
database=mysql
|
||||||
spring.datasource.url=jdbc:mysql://localhost/petclinic
|
spring.datasource.url=jdbc:mysql://db/petclinic
|
||||||
spring.datasource.username=root
|
spring.datasource.username=root
|
||||||
spring.datasource.password=petclinic
|
spring.datasource.password=petclinic
|
||||||
# Uncomment this the first time the app runs
|
# Uncomment this the first time the app runs
|
||||||
# spring.datasource.initialization-mode=always
|
spring.datasource.initialization-mode=always
|
||||||
|
|
Loading…
Reference in a new issue