-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
53 lines (39 loc) · 1.29 KB
/
Dockerfile
File metadata and controls
53 lines (39 loc) · 1.29 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Stage 1: Build
FROM eclipse-temurin:25-jdk-alpine AS build
WORKDIR /app
# Copy Gradle files
COPY gradle gradle
COPY gradlew .
COPY gradle.properties .
COPY settings.gradle .
COPY build.gradle .
# Download dependencies
RUN ./gradlew dependencies --no-daemon
# Copy source code
COPY src src
# Build application (skip tests for faster build)
RUN ./gradlew clean bootJar --no-daemon -x test
# Stage 2: Runtime
FROM eclipse-temurin:25-jre-alpine
WORKDIR /app
# Install timezone data, configure timezone, and create non-root user
RUN apk add --no-cache tzdata && \
cp /usr/share/zoneinfo/America/Santiago /etc/localtime && \
echo "America/Santiago" > /etc/timezone && \
apk del tzdata && \
addgroup -S spring && \
adduser -S spring -G spring
USER spring:spring
# Copy JAR from build stage
COPY --from=build /app/build/libs/*.jar app.jar
# Expose application port
EXPOSE 8080
# Default environment variables
ENV JAVA_OPTS="-Xms128m -Xmx256m -Duser.timezone=America/Santiago" \
SPRING_PROFILES_ACTIVE="prod" \
TZ="America/Santiago"
# Healthcheck
HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/actuator/health || exit 1
# Startup command
ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -jar app.jar"]