mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-29 18:55:49 +00:00
add Dockerfile(multi-staing) and docker-compose configuration(connect application and DB)
This commit is contained in:
parent
764f5787f2
commit
1838a3606e
2 changed files with 50 additions and 19 deletions
16
Dockerfile
Normal file
16
Dockerfile
Normal file
|
@ -0,0 +1,16 @@
|
|||
FROM openjdk:17-jdk as builder
|
||||
|
||||
RUN mkdir -p /app/source
|
||||
|
||||
COPY . /app/source
|
||||
|
||||
WORKDIR /app/source
|
||||
|
||||
RUN ./mvnw clean package
|
||||
|
||||
|
||||
FROM openjdk:17-jdk-alpine
|
||||
|
||||
COPY --from=builder /app/source/target/*.jar /app/app.jar
|
||||
|
||||
CMD ["java", "-jar", "/app/app.jar"]
|
|
@ -1,23 +1,38 @@
|
|||
version: "2.2"
|
||||
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:5.7
|
||||
ports:
|
||||
- "3306:3306"
|
||||
db:
|
||||
image: postgres:9.4
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=
|
||||
- MYSQL_ALLOW_EMPTY_PASSWORD=true
|
||||
- MYSQL_USER=petclinic
|
||||
- MYSQL_PASSWORD=petclinic
|
||||
- MYSQL_DATABASE=petclinic
|
||||
volumes:
|
||||
- "./conf.d:/etc/mysql/conf.d:ro"
|
||||
postgres:
|
||||
image: postgres:14.1
|
||||
- POSTGRES_USER=postgres
|
||||
- POSTGRES_PASSWORD=postgres
|
||||
spring:
|
||||
image: rolandgryddynamics/myapp
|
||||
ports:
|
||||
- "5432:5432"
|
||||
environment:
|
||||
- POSTGRES_PASSWORD=petclinic
|
||||
- POSTGRES_USER=petclinic
|
||||
- POSTGRES_DB=petclinic
|
||||
- 8080:8080
|
||||
depends_on:
|
||||
- db
|
||||
|
||||
|
||||
# version: "2.2"
|
||||
|
||||
# services:
|
||||
# mysql:
|
||||
# image: mysql:5.7
|
||||
# ports:
|
||||
# - "3306:3306"
|
||||
# environment:
|
||||
# - MYSQL_ROOT_PASSWORD=
|
||||
# - MYSQL_ALLOW_EMPTY_PASSWORD=true
|
||||
# - MYSQL_USER=petclinic
|
||||
# - MYSQL_PASSWORD=petclinic
|
||||
# - MYSQL_DATABASE=petclinic
|
||||
# volumes:
|
||||
# - "./conf.d:/etc/mysql/conf.d:ro"
|
||||
# postgres:
|
||||
# image: postgres:14.1
|
||||
# ports:
|
||||
# - "5432:5432"
|
||||
# environment:
|
||||
# - POSTGRES_PASSWORD=petclinic
|
||||
# - POSTGRES_USER=petclinic
|
||||
# - POSTGRES_DB=petclinic
|
||||
|
|
Loading…
Reference in a new issue