-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
64 lines (46 loc) ยท 1.5 KB
/
Dockerfile
File metadata and controls
64 lines (46 loc) ยท 1.5 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
54
55
56
57
58
59
60
61
62
63
64
# Build-Up Backend Dockerfile
# Multi-stage build for optimized image size
# Stage 1: Build
FROM gradle:8.5-jdk21 AS builder
WORKDIR /app
# Gradle ์บ์ ์ต์ ํ๋ฅผ ์ํด ์์กด์ฑ ํ์ผ๋ง ๋จผ์ ๋ณต์ฌ
COPY build.gradle settings.gradle ./
COPY gradle ./gradle
# ์์กด์ฑ ๋ค์ด๋ก๋ (์บ์ ํ์ฉ)
RUN gradle dependencies --no-daemon || true
# ์ ์ฒด ์์ค ๋ณต์ฌ
COPY . .
# ์ ํ๋ฆฌ์ผ์ด์
๋น๋ (ํ
์คํธ ์คํต)
RUN gradle clean build -x test --no-daemon
# Stage 2: Runtime
FROM eclipse-temurin:21-jre-alpine
WORKDIR /app
# ํ์์กด ์ค์
RUN apk add --no-cache tzdata && \
cp /usr/share/zoneinfo/Asia/Seoul /etc/localtime && \
echo "Asia/Seoul" > /etc/timezone && \
apk del tzdata
# curl ์ค์น (ํฌ์ค์ฒดํฌ์ฉ)
RUN apk add --no-cache curl
# ๋น๋ฃจํธ ์ฌ์ฉ์ ์์ฑ
RUN addgroup -g 1001 -S appgroup && \
adduser -u 1001 -S appuser -G appgroup
# ๋น๋๋ JAR ํ์ผ ๋ณต์ฌ
COPY --from=builder /app/build/libs/*.jar app.jar
# ์์ ๊ถ ๋ณ๊ฒฝ
RUN chown -R appuser:appgroup /app
# ๋น๋ฃจํธ ์ฌ์ฉ์๋ก ์ ํ
USER appuser
# ํฌํธ ๋
ธ์ถ
EXPOSE 8080
# JVM ์ต์
์ค์
ENV JAVA_OPTS="-Xms512m -Xmx1024m \
-XX:+UseG1GC \
-XX:MaxGCPauseMillis=200 \
-XX:+UseStringDeduplication \
-Djava.security.egd=file:/dev/./urandom"
# ํฌ์ค์ฒดํฌ
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl -f http://localhost:8080/api/actuator/health || exit 1
# ์ ํ๋ฆฌ์ผ์ด์
์คํ
ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -jar app.jar"]