Skip to content

Commit 47c194f

Browse files
authored
chore: Docker 설정 간소화 및 CI/CD 안정화 (#67)
1 parent f99b72c commit 47c194f

14 files changed

Lines changed: 116 additions & 184 deletions

.DS_Store

0 Bytes
Binary file not shown.

.dockerignore

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,64 @@
1+
# VCS
12
.git
2-
.gradle
3+
.gitignore
4+
.gitattributes
5+
.github/
6+
7+
# Gradle 로컬 캐시 / 빌드 산출물 (컨테이너 안에서 다시 생성되므로 불필요)
8+
.gradle/
39
build/
4-
*.md
10+
out/
11+
bin/
12+
HELP.md
13+
14+
# IDE / OS 자동 생성 파일
15+
.idea/
16+
.vscode/
17+
.settings/
18+
.classpath
19+
.project
20+
.springBeans
21+
.sts4-cache
22+
.apt_generated
23+
.factorypath
24+
*.iml
25+
*.iws
26+
*.ipr
27+
**/.DS_Store
28+
Thumbs.db
29+
30+
# 환경변수 / 시크릿
531
.env
6-
.idea
32+
.env.*
33+
!.env.example
34+
*.pem
35+
*.key
36+
id_rsa*
37+
38+
# Docker / Compose 정의 (이미지 안에서 안 씀)
39+
Dockerfile
40+
.dockerignore
41+
docker/
42+
docker-compose.yaml
43+
compose*.yaml
44+
compose*.yml
45+
46+
# 배포 인프라 정의 (fluent-bit 설정 등)
47+
deploy/
48+
49+
# 문서
50+
*.md
51+
LICENSE
52+
docs/
53+
CLAUDE.md
54+
55+
# 테스트 코드 (Dockerfile이 `gradlew build -x test`로 스킵하므로 제외)
56+
src/test/
57+
58+
# 로컬 실행 흔적 (데이터/로그)
59+
postgres-data/
60+
logs/
61+
*.log
62+
63+
# Windows 전용 스크립트 (리눅스 컨테이너 무관)
64+
gradlew.bat

.github/workflows/cd.yaml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
deploy:
1313
name: Deploy to Wisoft Server
1414
runs-on: ubuntu-latest
15-
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' }}
15+
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' && github.event.workflow_run.head_branch == 'main' }}
1616

1717
steps:
1818
- name: SSH 키 설정
@@ -49,10 +49,10 @@ jobs:
4949
echo "$GHCR_PAT" | docker login ghcr.io -u "$GITHUB_ACTOR" --password-stdin
5050
5151
echo "=== 최신 이미지 Pull ==="
52-
docker compose -f docker/docker-compose.prod.yml --env-file .env pull app
52+
docker compose -f docker-compose.prod.yml pull app
5353
5454
echo "=== 앱 컨테이너 재시작 ==="
55-
docker compose -f docker/docker-compose.prod.yml --env-file .env up -d app
55+
docker compose -f docker-compose.prod.yml up -d app
5656
5757
echo "=== Health Check (최대 60초) ==="
5858
for i in \$(seq 1 12); do
@@ -65,7 +65,7 @@ jobs:
6565
done
6666
6767
echo "Health check 실패"
68-
docker compose -f docker/docker-compose.prod.yml logs --tail=50 app
68+
docker compose -f docker-compose.prod.yml logs --tail=50 app
6969
exit 1
7070
ENDSSH
7171
@@ -79,5 +79,8 @@ jobs:
7979
TARGET_USER: ${{ secrets.RASPI_TARGET_USER }}
8080
run: |
8181
ssh -o StrictHostKeyChecking=no -o ProxyJump=$JUMP_USER@$JUMP_HOST:$JUMP_PORT $TARGET_USER@$TARGET_HOST /bin/bash << ENDSSH
82-
docker image prune -af --filter "until=72h" --filter "reference=ghcr.io/wisoft-prepair/backend-java*" || true
82+
docker images 'ghcr.io/wisoft-prepair/backend-java*' --format '{{.ID}}' \
83+
| awk '!seen[\$0]++' \
84+
| tail -n +2 \
85+
| xargs -r docker rmi -f || true
8386
ENDSSH

.github/workflows/ci.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ jobs:
7575
- name: 코드 체크아웃
7676
uses: actions/checkout@v4
7777

78+
- name: QEMU 설정
79+
uses: docker/setup-qemu-action@v3
80+
7881
- name: Docker Buildx 설정
7982
uses: docker/setup-buildx-action@v3
8083

Dockerfile

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,13 @@ FROM eclipse-temurin:21 AS builder
55

66
WORKDIR /app
77

8-
# Gradle 캐싱을 위해 설정 파일 먼저 복사
98
COPY gradlew .
109
COPY gradle gradle
11-
COPY build.gradle .
1210
COPY settings.gradle .
11+
COPY build.gradle .
1312

14-
# 의존성 다운로드 (캐싱 레이어)
1513
RUN ./gradlew dependencies --no-daemon
1614

17-
# 소스코드 복사 후 빌드
1815
COPY src src
1916
RUN ./gradlew build -x test --no-daemon
2017

@@ -29,12 +26,9 @@ RUN apt-get update && apt-get install -y ffmpeg curl && rm -rf /var/lib/apt/list
2926

3027
COPY --from=builder /app/build/libs/*.jar app.jar
3128

32-
# 포트 문서화
3329
EXPOSE 7300
3430

35-
# 컨테이너 레벨 헬스체크 (Docker daemon의 status 표시용)
36-
HEALTHCHECK --interval=24h --timeout=10s --start-period=40s --retries=3 \
37-
CMD curl -sf http://localhost:7300/actuator/health || exit 1
31+
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
32+
CMD curl -sf http://localhost:7300/actuator/health
3833

39-
# 실행
4034
ENTRYPOINT ["java", "-jar", "app.jar"]

docker-compose-dev.yml

Lines changed: 0 additions & 58 deletions
This file was deleted.

docker-compose.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
services:
2+
postgres:
3+
image: postgres:17
4+
container_name: prepair-backend-java-postgres
5+
ports:
6+
- "${POSTGRES_PORT}:5432"
7+
environment:
8+
- POSTGRES_DB=${POSTGRES_DB}
9+
- POSTGRES_USER=${POSTGRES_USER}
10+
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
11+
volumes:
12+
- postgres-data:/var/lib/postgresql/data
13+
healthcheck:
14+
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER}"]
15+
interval: 10s
16+
timeout: 5s
17+
retries: 5
18+
19+
app:
20+
build:
21+
context: .
22+
dockerfile: Dockerfile
23+
container_name: prepair-backend-java-api
24+
ports:
25+
- "7300:7300"
26+
env_file:
27+
- .env
28+
environment:
29+
- SPRING_PROFILES_ACTIVE=prod
30+
- TZ=Asia/Seoul
31+
depends_on:
32+
postgres:
33+
condition: service_healthy
34+
35+
volumes:
36+
postgres-data:
37+
38+
39+

docker/docker-compose.prod.yml

Lines changed: 0 additions & 68 deletions
This file was deleted.

docker/fluent-bit/fluent-bit.conf

Lines changed: 0 additions & 34 deletions
This file was deleted.

docker/fluent-bit/parsers.conf

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)