-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathDockerfile
35 lines (29 loc) · 1.57 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
FROM eclipse-temurin:17-jdk-alpine as development
# The fact that we are using a parent pom.xml file makes the build process a bit more complex.
# A better option could be to have a local Nexus Repository with all the dependencies.
WORKDIR /app
RUN apk add git curl
RUN git clone -b v1.1 --single-branch https://github.com/danielsobrado/spring-cloud-kafka-microservices.git
RUN chmod -R 777 spring-cloud-kafka-microservices
WORKDIR /app/spring-cloud-kafka-microservices
# Enabling BuildKit cache for faster builds
RUN --mount=type=cache,target=.m2 ./mvnw install -pl .,jvmcc-product-service -DskipTests
# Trick to invalidate the cache when the github repo gets updated
ARG USER=danielsobrado
ARG REPO=spring-cloud-kafka-microservices
ARG BRANCH=main
ADD https://api.github.com/repos/$USER/$REPO/git/refs/heads/$BRANCH version.json
RUN ./mvnw install -pl .,jvmcc-product-service -DskipTests
FROM eclipse-temurin:17-jdk-alpine as build
COPY --from=development /app/spring-cloud-kafka-microservices/jvmcc-product-service/target/jvmcc-product-service-*.jar /jvmcc-product-service.jar
RUN ls -la
RUN java -Djarmode=layertools -jar jvmcc-product-service.jar extract
FROM eclipse-temurin:17-jdk-alpine as production
COPY --from=build dependencies/ ./
COPY --from=build snapshot-dependencies/ ./
COPY --from=build spring-boot-loader/ ./
COPY --from=build application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
# docker build -t dalamar/jvmcc-product-service .
# docker push dalamar/jvmcc-product-service
# docker run -d -p 8092:8092 --name="jvmcc-product-service" jvmcc-product-service