-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
41 lines (30 loc) · 1017 Bytes
/
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
# Using Eclipse Temurin as the base image for OpenJDK, as it is a well-supported, secure, and production-ready JDK distribution
FROM eclipse-temurin:19-jdk-jammy as build
WORKDIR /workspace/app
# copy maven stuff first to cache dependancies
COPY mvnw .
COPY .mvn .mvn
COPY pom.xml .
COPY src src
# build that app
RUN ./mvnw install -DskipTests
# setup runtime img
FROM eclipse-temurin:19-jre-jammy
WORKDIR /app
# add non-root user for securty
RUN addgroup --system --gid 1001 appuser && \
adduser --system --uid 1001 --group appuser
# grab the jar from build stage
COPY --from=build /workspace/app/target/*.jar app.jar
# fix ownership adn switch to non-root user
RUN chown -R appuser:appuser /app
USER appuser
# setup helth check
HEALTHCHECK --interval=30s --timeout=3s \
CMD curl -f http://localhost:8080/actuator/health || exit 1
# env vars for java
ENV JAVA_OPTS="-Xmx512m -Xms256m"
# open up the applicationport
EXPOSE 8080
# run the app
ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -jar app.jar"]