-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
43 lines (31 loc) · 1.28 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
36
37
38
39
40
41
42
43
ARG JAVA_VERSION=17
ARG BUILD_STAGE_WORKDIR=/home/sports-club-api
#--- Build Stage ---#
FROM openjdk:${JAVA_VERSION} AS build-stage
ARG BUILD_STAGE_WORKDIR
WORKDIR ${BUILD_STAGE_WORKDIR}
ARG JAVA_VERSION
# Fetch all application dependencies
COPY ./pom.xml ./pom.xml
# Copy Maven Wrapper
COPY ./.mvn ./.mvn
COPY ./mvnw .
RUN chmod 744 ./mvnw
RUN ./mvnw '-Djava.version=${JAVA_VERSION}' dependency:go-offline -DexcludeGroupIds=org.openapitools
# Compile and package the application
COPY ./src ./src
RUN --mount=type=cache,target=/root/.m2 ./mvnw '-Djava.version=${JAVA_VERSION}' -Dmaven.test.skip package \
&& mkdir -p target/dependency \
&& cd target/dependency \
&& jar -xf ../*.jar
#--- Final Stage ---#
FROM openjdk:${JAVA_VERSION}-jdk-slim
ARG BUILD_STAGE_WORKDIR
ARG DEPENDENCY=target/dependency
COPY --from=build-stage ${BUILD_STAGE_WORKDIR}/${DEPENDENCY}/META-INF /app/META-INF
COPY --from=build-stage ${BUILD_STAGE_WORKDIR}/${DEPENDENCY}/BOOT-INF/classes /app
COPY --from=build-stage ${BUILD_STAGE_WORKDIR}/${DEPENDENCY}/BOOT-INF/lib /app/lib
RUN apt-get update && apt-get install -y curl
ENTRYPOINT ["java","-cp","/app:/app/lib/*","systems.fervento.sportsclub.SportsClubApp"]
EXPOSE 8083
HEALTHCHECK CMD curl -f http://localhost:8083/api/actuator/health || exit 1