better layer caching & multi-stage build

This commit is contained in:
hllvc 2021-07-05 12:09:43 +02:00
parent 131e96b7a2
commit a666c41a62
2 changed files with 15 additions and 10 deletions

View file

@ -1,11 +1,16 @@
FROM openjdk:latest
WORKDIR /tmp/
COPY . .
FROM openjdk:8-jdk-alpine AS build
WORKDIR /build
COPY .mvn .mvn
COPY mvnw .
COPY mvnw.cmd .
COPY pom.xml .
RUN ./mvnw -B -e dependency:go-offline
COPY src src
RUN ./mvnw package
FROM openjdk:8-jre-alpine
EXPOSE 8080
CMD ./mvnw spring-boot:run -Dspring-boot.run.profiles=mysql
ENTRYPOINT [ "java" ]
CMD [ "-jar", "-Dspring.profiles.active=mysql" ,"app.jar" ]
COPY --from=build /build/target/*.jar /app/app.jar
WORKDIR /app

View file

@ -1,10 +1,10 @@
services:
app:
image: hllvc/spring-petclinic:latest
ports:
- "3000:8080"
links:
- mysql:mysql
ports:
- "3000:8080"
mysql:
image: mysql:5.7
ports: