-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDockerfileLocal
More file actions
37 lines (27 loc) · 1.48 KB
/
DockerfileLocal
File metadata and controls
37 lines (27 loc) · 1.48 KB
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
# Use a lightweight JDK image
FROM eclipse-temurin:25-jdk-alpine
# Set environment variables
ENV TZ=Asia/Bangkok \
JAVA_OPTS="-Xms1G -Xmx1G -Xss256k -XX:MaxMetaspaceSize=256m -XX:+UseG1GC -XX:+UseContainerSupport -XX:MaxRAMPercentage=75.0 -XX:InitialRAMPercentage=75.0 -XX:MaxGCPauseMillis=100 -XX:+ParallelRefProcEnabled -XX:+UseCompressedOops -XX:+UseCompressedClassPointers -XX:+AlwaysPreTouch -XX:+TieredCompilation -XX:+UseStringDeduplication -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/usr/spring-data/logs/heapdump.hprof"
# Install required packages and set timezone
RUN apk --no-cache add curl tzdata && \
cp /usr/share/zoneinfo/Asia/Bangkok /etc/localtime && \
echo "Asia/Bangkok" > /etc/timezone
# Create non-root appUser and group
#RUN addgroup -g 1001 springgroup && \
# adduser -D -u 1001 -G springgroup springuser
# Set working directory
WORKDIR /app
# Copy the built JAR file
COPY /build/libs/api-service-1.0.0.jar app.jar
# Copy the built JAR file and give ownership to the non-root appUser
#COPY --chown=springuser:springgroup /build/libs/api-service-1.0.0.jar app.jar
# Switch to non-root appUser
#USER springuser
# Expose the application port
EXPOSE 8080
# Health check using curl
HEALTHCHECK --interval=30s --timeout=3s --retries=3 \
CMD curl -f http://localhost:8080/actuator/health || exit 1
# Define entrypoint
ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -Dspring.config.additional-location=/usr/spring-data/env/ -Dspring.profiles.active=localdocker -jar app.jar"]