Skip to content

Commit 34635fc

Browse files
committed
Chore: 멀티 스테이지 적용 (빌드 / 실행)
1 parent ae0cf7d commit 34635fc

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ jobs:
3737
echo "No Gradle project found"; exit 1
3838
fi
3939
40-
- name: Build & Test
40+
- name: Test
4141
env:
4242
MAIL_PASSWORD: ${{ secrets.CI_MAIL_PASSWORD }}
4343
MAIL_USERNAME: ${{ secrets.CI_MAIL_USERNAME }}
4444
MONGO_URI: ${{ secrets.CI_MONGO_URI }}
4545
run: |
4646
cd "${{ steps.detect.outputs.dir }}"
4747
chmod +x ./gradlew || true
48-
./gradlew clean test bootJar
48+
./gradlew clean test --no-daemon
4949
5050
- name: Find Dockerfile
5151
id: df

infra/backend/Dockerfile

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
1+
# ---- Build Stage ----
2+
FROM eclipse-temurin:21-jdk-alpine AS builder
3+
4+
WORKDIR /workspace
5+
6+
COPY gradlew ./gradlew
7+
COPY gradle ./gradle
8+
COPY build.gradle* settings.gradle* ./
9+
RUN chmod +x ./gradlew
10+
11+
RUN ./gradlew --no-daemon dependencies || true
12+
13+
COPY . .
14+
15+
RUN ./gradlew clean bootJar -x test --no-daemon
16+
17+
# ---- Runtime Stage ----
118
FROM eclipse-temurin:21-jre-alpine
219

320
RUN addgroup -S app && adduser -S app -G app
421
RUN apk add --no-cache wget
522

623
WORKDIR /app
724

8-
COPY --chown=app:app app.jar /app/app.jar
25+
COPY --from=builder --chown=app:app /workspace/build/libs/*.jar /app/app.jar
926

10-
#ENV JAVA_OPTS="-Xms256m -Xmx512m" \
11-
# SERVER_PORT=8080 \
12-
# TZ=Asia/Seoul
13-
1427
ENV JAVA_OPTS="-XX:MaxRAMPercentage=75 -XX:+UseG1GC -Duser.timezone=Asia/Seoul"
1528

1629
EXPOSE 8080

0 commit comments

Comments
 (0)