add Dockerfile(multi-staing) and docker-compose configuration(connect application and DB)

This commit is contained in:
RolandBakunts 2023-01-11 01:13:46 -08:00
parent 764f5787f2
commit 1838a3606e
2 changed files with 50 additions and 19 deletions

16
Dockerfile Normal file
View 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"]

View file

@ -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