Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
64 changes: 61 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,64 @@
# VCS
.git
.gradle
.gitignore
.gitattributes
.github/

# Gradle 로컬 캐시 / 빌드 산출물 (컨테이너 안에서 다시 생성되므로 불필요)
.gradle/
build/
*.md
out/
bin/
HELP.md

# IDE / OS 자동 생성 파일
.idea/
.vscode/
.settings/
.classpath
.project
.springBeans
.sts4-cache
.apt_generated
.factorypath
*.iml
*.iws
*.ipr
**/.DS_Store
Thumbs.db

# 환경변수 / 시크릿
.env
.idea
.env.*
!.env.example
*.pem
*.key
id_rsa*

# Docker / Compose 정의 (이미지 안에서 안 씀)
Dockerfile
.dockerignore
docker/
docker-compose.yaml
compose*.yaml
compose*.yml

# 배포 인프라 정의 (fluent-bit 설정 등)
deploy/

# 문서
*.md
LICENSE
docs/
CLAUDE.md

# 테스트 코드 (Dockerfile이 `gradlew build -x test`로 스킵하므로 제외)
src/test/

# 로컬 실행 흔적 (데이터/로그)
postgres-data/
logs/
*.log

# Windows 전용 스크립트 (리눅스 컨테이너 무관)
gradlew.bat
13 changes: 8 additions & 5 deletions .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
deploy:
name: Deploy to Wisoft Server
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' }}
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' && github.event.workflow_run.head_branch == 'main' }}

steps:
- name: SSH 키 설정
Expand Down Expand Up @@ -49,10 +49,10 @@ jobs:
echo "$GHCR_PAT" | docker login ghcr.io -u "$GITHUB_ACTOR" --password-stdin

echo "=== 최신 이미지 Pull ==="
docker compose -f docker/docker-compose.prod.yml --env-file .env pull app
docker compose -f docker-compose.prod.yml pull app

echo "=== 앱 컨테이너 재시작 ==="
docker compose -f docker/docker-compose.prod.yml --env-file .env up -d app
docker compose -f docker-compose.prod.yml up -d app

echo "=== Health Check (최대 60초) ==="
for i in \$(seq 1 12); do
Expand All @@ -65,7 +65,7 @@ jobs:
done

echo "Health check 실패"
docker compose -f docker/docker-compose.prod.yml logs --tail=50 app
docker compose -f docker-compose.prod.yml logs --tail=50 app
exit 1
ENDSSH

Expand All @@ -79,5 +79,8 @@ jobs:
TARGET_USER: ${{ secrets.RASPI_TARGET_USER }}
run: |
ssh -o StrictHostKeyChecking=no -o ProxyJump=$JUMP_USER@$JUMP_HOST:$JUMP_PORT $TARGET_USER@$TARGET_HOST /bin/bash << ENDSSH
docker image prune -af --filter "until=72h" --filter "reference=ghcr.io/wisoft-prepair/backend-java*" || true
docker images 'ghcr.io/wisoft-prepair/backend-java*' --format '{{.ID}}' \
| awk '!seen[\$0]++' \
| tail -n +2 \
| xargs -r docker rmi -f || true
ENDSSH
3 changes: 3 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ jobs:
- name: 코드 체크아웃
uses: actions/checkout@v4

- name: QEMU 설정
uses: docker/setup-qemu-action@v3

- name: Docker Buildx 설정
uses: docker/setup-buildx-action@v3

Expand Down
12 changes: 3 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ FROM eclipse-temurin:21 AS builder

WORKDIR /app

# Gradle 캐싱을 위해 설정 파일 먼저 복사
COPY gradlew .
COPY gradle gradle
COPY build.gradle .
COPY settings.gradle .
COPY build.gradle .

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

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

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

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

# 포트 문서화
EXPOSE 7300

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

# 실행
ENTRYPOINT ["java", "-jar", "app.jar"]
58 changes: 0 additions & 58 deletions docker-compose-dev.yml

This file was deleted.

39 changes: 39 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
services:
postgres:
image: postgres:17
container_name: prepair-backend-java-postgres
ports:
- "${POSTGRES_PORT}:5432"
environment:
- POSTGRES_DB=${POSTGRES_DB}
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
volumes:
- postgres-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER}"]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

PostgreSQL 상태 확인 시, 서버가 연결을 수락하는지 확인하는 것뿐만 아니라, 애플리케이션이 사용할 특정 데이터베이스가 준비되었는지 확인하는 것이 더 안정적입니다. pg_isready-d 플래그를 추가하여 데이터베이스 이름을 명시하는 것을 권장합니다.

      test: ["CMD-SHELL", "pg_isready -d ${POSTGRES_DB} -U ${POSTGRES_USER}"]

interval: 10s
timeout: 5s
retries: 5

app:
build:
context: .
dockerfile: Dockerfile
container_name: prepair-backend-java-api
ports:
- "7300:7300"
env_file:
- .env
environment:
- SPRING_PROFILES_ACTIVE=prod
- TZ=Asia/Seoul
depends_on:
postgres:
condition: service_healthy

volumes:
postgres-data:



68 changes: 0 additions & 68 deletions docker/docker-compose.prod.yml

This file was deleted.

34 changes: 0 additions & 34 deletions docker/fluent-bit/fluent-bit.conf

This file was deleted.

5 changes: 0 additions & 5 deletions docker/fluent-bit/parsers.conf

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ logging:

spring:
application:
name: interview-service
name: prepair-backend-java-api

profiles:
active: local
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<springProperty name="SERVICE_NAME" source="spring.application.name" defaultValue="prepair-api"/>
<springProperty name="SERVICE_NAME" source="spring.application.name" defaultValue="prepair-backend-java-api"/>

<springProfile name="local">
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
Expand Down
Loading