-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile
67 lines (51 loc) ยท 1.93 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Build stage
FROM --platform=linux/amd64 gradle:8.5-jdk21 AS builder
WORKDIR /build
# ์์กด์ฑ ์บ์ฑ์ ์ํ ๊ทธ๋๋ค ํ์ผ ๋ณต์ฌ
COPY build.gradle settings.gradle /build/
COPY gradle /build/gradle
COPY gradlew /build/
RUN chmod +x ./gradlew
# ์์กด์ฑ ๋ค์ด๋ก๋ (์บ์ ํ์ฉ)
RUN ./gradlew dependencies
# ์์ค ์ฝ๋ ๋ณต์ฌ (resources ํด๋ ์ ์ธ)
COPY src/main/java /build/src/main/java
COPY src/test /build/src/test
# Parameter Store์์ ๊ฐ์ ธ์จ ์ค์ ํ์ผ ๋ณต์ฌ
COPY src/main/resources/application.yml /build/src/main/resources/
COPY src/main/resources/application-dev.yml /build/src/main/resources/
# ์ค์ ํ์ผ ํ์ธ
RUN echo "=== Listing resources directory ==="
RUN ls -la /build/src/main/resources/
# ๋น๋
RUN ./gradlew clean build -x test --no-daemon
# Production stage
FROM --platform=linux/amd64 eclipse-temurin:21-jdk-alpine
WORKDIR /app
# ์ค์ ํ์ผ ๋๋ ํ ๋ฆฌ ์์ฑ
RUN mkdir -p /app/config
# ๊ธฐ๋ณธ ์๊ฐ๋ ์ค์
RUN apk add --no-cache tzdata curl && \
cp /usr/share/zoneinfo/Asia/Seoul /etc/localtime && \
echo "Asia/Seoul" > /etc/timezone && \
apk del tzdata
# ์ค์ ํ์ผ ๋ณต์ฌ
COPY --from=builder /build/src/main/resources/application.yml /app/config/
COPY --from=builder /build/src/main/resources/application-dev.yml /app/config/
# ์ ํ๋ฆฌ์ผ์ด์
jar ํ์ผ ๋ณต์ฌ
COPY --from=builder /build/build/libs/*.jar app.jar
# ์๋ฒ ํ๊ฒฝ ์ค์
ENV SERVER_PORT=30010
ENV JAVA_OPTS="-Dfile.encoding=UTF-8 \
-Dspring.profiles.active=dev \
-Dspring.config.location=file:/app/config/"
# ํฌ์ค์ฒดํฌ
HEALTHCHECK --interval=30s --timeout=3s --retries=3 \
CMD curl -f http://localhost:${SERVER_PORT}/actuator/health || exit 1
# ๋นroot ์ฌ์ฉ์ ์ถ๊ฐ
RUN addgroup -S spring && adduser -S spring -G spring
RUN chown -R spring:spring /app
USER spring:spring
# ์ปจํ
์ด๋ ์คํ
ENTRYPOINT ["sh", "-c", "java ${JAVA_OPTS} -jar app.jar"]
EXPOSE ${SERVER_PORT}