Skip to content

Commit f5ce085

Browse files
first commit
0 parents  commit f5ce085

38 files changed

+2080
-0
lines changed

.dockerignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Git
2+
.git
3+
.gitignore
4+
5+
# IDE
6+
.idea
7+
.vscode
8+
*.iml
9+
10+
# Gradle
11+
.gradle
12+
build
13+
14+
# Environment
15+
.env
16+
.env.*
17+
*.pem
18+
19+
# Logs
20+
logs
21+
*.log
22+
23+
# Docker
24+
docker-compose*.yml
25+
Dockerfile

.env.example

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# ========================================
2+
# GoodGame API 환경 변수 템플릿
3+
# ========================================
4+
#
5+
# 사용법:
6+
# 로컬 개발: cp .env.example .env
7+
# 배포 서버: cp .env.example .env.prod (또는 GitHub Secrets 사용)
8+
#
9+
# ========================================
10+
11+
# ========================================
12+
# Spring Profile
13+
# ========================================
14+
# local: 로컬 개발 (Docker MySQL)
15+
# prod: 배포 서버 (AWS RDS)
16+
SPRING_PROFILES_ACTIVE=local
17+
18+
# ========================================
19+
# Database (MySQL / AWS RDS)
20+
# ========================================
21+
# [로컬] Docker MySQL (기본값 - 설정 안해도 됨)
22+
# [배포] AWS RDS - 아래 값 변경
23+
# ========================================
24+
SPRING_DATASOURCE_URL=jdbc:mysql://localhost:3306/goodgame?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul
25+
SPRING_DATASOURCE_USERNAME=goodgame
26+
SPRING_DATASOURCE_PASSWORD=goodgame123
27+
28+
# ========================================
29+
# JWT
30+
# ========================================
31+
# 배포 시 반드시 변경! 생성: openssl rand -base64 48
32+
JWT_SECRET=your-jwt-secret-key-must-be-at-least-256-bits-long-for-hs256
33+
34+
# ========================================
35+
# Kakao API (REST API 키 사용)
36+
# ========================================
37+
KAKAO_CLIENT_ID=
38+
KAKAO_CLIENT_SECRET=
39+
KAKAO_REDIRECT_URI=http://localhost:8080/api/auth/kakao/callback
40+
41+
# ========================================
42+
# AWS S3
43+
# ========================================
44+
AWS_ACCESS_KEY_ID=
45+
AWS_SECRET_ACCESS_KEY=
46+
AWS_REGION=ap-northeast-2
47+
AWS_S3_BUCKET=
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
name: Bug Report
3+
about: 버그를 발견했다면 이 템플릿을 사용해주세요
4+
title: "[BUG] "
5+
labels: bug
6+
assignees: ''
7+
---
8+
9+
## Bug Description
10+
<!-- 버그에 대해 명확하게 설명해주세요 -->
11+
12+
13+
## Steps to Reproduce
14+
<!-- 버그를 재현하는 단계를 작성해주세요 -->
15+
1.
16+
2.
17+
3.
18+
19+
20+
## Expected Behavior
21+
<!-- 예상했던 정상 동작을 설명해주세요 -->
22+
23+
24+
## Actual Behavior
25+
<!-- 실제로 발생한 동작을 설명해주세요 -->
26+
27+
28+
## Environment
29+
- Profile: <!-- local / dev / prod -->
30+
- Java Version:
31+
- OS:
32+
33+
34+
## Logs / Screenshots
35+
<!-- 관련 로그나 스크린샷이 있다면 첨부해주세요 -->
36+
37+
38+
## Related Domain
39+
<!-- 관련 도메인이 있다면 선택해주세요 -->
40+
- [ ] Member (회원)
41+
- [ ] Auth (인증)
42+
- [ ] Emotion (감정)
43+
- [ ] Global/Infrastructure
44+
- [ ] Documentation
45+
- [ ] CI/CD
46+
47+
48+
## Additional Context
49+
<!-- 추가 정보가 있다면 작성해주세요 -->
50+

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: Documentation
4+
url: https://github.com/umc-hackaton-4team/BE
5+
about: 프로젝트 README를 확인해주세요
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
name: Feature Request
3+
about: 새로운 기능을 제안하려면 이 템플릿을 사용해주세요
4+
title: "[FEAT] "
5+
labels: enhancement
6+
assignees: ''
7+
---
8+
9+
## Feature Summary
10+
<!-- 제안하는 기능을 간단히 설명해주세요 -->
11+
12+
13+
## Motivation
14+
<!-- 이 기능이 왜 필요한가요? 어떤 문제를 해결하나요? -->
15+
16+
17+
## Proposed Solution
18+
<!-- 제안하는 구현 방법이나 접근 방식을 설명해주세요 -->
19+
20+
21+
## Alternatives Considered
22+
<!-- 고려했던 다른 방법이 있다면 작성해주세요 -->
23+
24+
25+
## Related Domain
26+
<!-- 관련 도메인을 선택해주세요 -->
27+
- [ ] Member (회원)
28+
- [ ] Auth (인증)
29+
- [ ] Emotion (감정)
30+
- [ ] Global/Infrastructure
31+
- [ ] Documentation
32+
- [ ] CI/CD
33+
34+
35+
## Additional Context
36+
<!-- 추가 정보, 참고 자료, 스크린샷 등이 있다면 첨부해주세요 -->
37+

.github/ISSUE_TEMPLATE/task.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
name: Task
3+
about: 일반적인 작업이나 개선사항에 대한 이슈
4+
title: "[TASK] "
5+
labels: task
6+
assignees: ''
7+
---
8+
9+
## Task Description
10+
<!-- 작업 내용을 설명해주세요 -->
11+
12+
13+
## Checklist
14+
<!-- 완료해야 할 항목들을 작성해주세요 -->
15+
- [ ]
16+
17+
18+
## Related Domain
19+
<!-- 관련 도메인이 있다면 선택해주세요 -->
20+
- [ ] Member (회원)
21+
- [ ] Auth (인증)
22+
- [ ] Emotion (감정)
23+
- [ ] Global/Infrastructure
24+
- [ ] Documentation
25+
- [ ] CI/CD
26+
27+
28+
## Related Issues / PRs
29+
<!-- 관련 이슈나 PR이 있다면 링크해주세요 -->
30+
31+
32+
## Additional Notes
33+
<!-- 추가 정보가 있다면 작성해주세요 -->
34+

.github/pull_request_template.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<!--
2+
## PR 제목 컨벤션
3+
[TYPE] 설명 (#이슈번호)
4+
5+
예시:
6+
- [FEAT] 회원가입 API 구현 (#14)
7+
- [FIX] 이미지 업로드 시 NPE 수정 (#23)
8+
- [REFACTOR] 토큰 로직 분리 (#8)
9+
- [DOCS] ERD 스키마 업데이트 (#6)
10+
- [CHORE] CI/CD 파이프라인 추가 (#3)
11+
- [RELEASE] v1.0.0 배포 (#30)
12+
13+
TYPE: FEAT, FIX, DOCS, REFACTOR, TEST, CHORE, RENAME, REMOVE, RELEASE
14+
-->
15+
16+
## Summary
17+
<!-- 변경 사항을 간단히 설명해주세요 -->
18+
19+
20+
## Changes
21+
<!-- 변경된 내용을 목록으로 작성해주세요 -->
22+
-
23+
24+
25+
## Type of Change
26+
<!-- 해당하는 항목에 x 표시해주세요 -->
27+
- [ ] Bug fix (기존 기능에 영향을 주지 않는 버그 수정)
28+
- [ ] New feature (기존 기능에 영향을 주지 않는 새로운 기능 추가)
29+
- [ ] Breaking change (기존 기능에 영향을 주는 수정)
30+
- [ ] Refactoring (기능 변경 없는 코드 개선)
31+
- [ ] Documentation (문서 수정)
32+
- [ ] Chore (빌드, 설정 등 기타 변경)
33+
- [ ] Release (develop → main 배포)
34+
35+
36+
## Related Issues
37+
<!-- 관련 이슈 번호를 작성해주세요 (예: Closes #123, Fixes #456) -->
38+
39+
40+
## Checklist
41+
<!-- PR 제출 전 확인사항 -->
42+
- [ ] 코드 컨벤션을 준수했습니다
43+
- [ ] 로컬에서 빌드가 정상적으로 완료됩니다
44+
- [ ] 새로운 기능에 대한 테스트를 작성했습니다 (해당시)
45+
- [ ] API 변경이 있다면 Swagger 문서가 업데이트 되었습니다
46+
47+
48+
## Screenshots (Optional)
49+
<!-- UI 변경이 있다면 스크린샷을 첨부해주세요 -->
50+
51+
52+
## Additional Notes
53+
<!-- 리뷰어가 알아야 할 추가 정보가 있다면 작성해주세요 -->
54+

.github/workflows/ci.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CI (Build & Test)
2+
3+
on:
4+
pull_request:
5+
branches: [ "develop", "main" ]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
build-and-test:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout Code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up JDK 21
18+
uses: actions/setup-java@v4
19+
with:
20+
java-version: '21'
21+
distribution: 'temurin'
22+
23+
# Gradle 캐싱 (빌드 속도 향상)
24+
- name: Cache Gradle packages
25+
uses: actions/cache@v4
26+
with:
27+
path: |
28+
~/.gradle/caches
29+
~/.gradle/wrapper
30+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
31+
restore-keys: |
32+
${{ runner.os }}-gradle-
33+
34+
- name: Grant execute permission for gradlew
35+
run: chmod +x gradlew
36+
37+
- name: Test & Build
38+
run: ./gradlew clean build

.github/workflows/deploy.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: CD (Deploy to AWS EC2)
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
7+
env:
8+
DOCKER_IMAGE: ${{ secrets.DOCKER_USERNAME }}/goodgame-api
9+
CONTAINER_NAME: goodgame-api
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
deploy:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout Code
19+
uses: actions/checkout@v4
20+
21+
- name: Set up JDK 21
22+
uses: actions/setup-java@v4
23+
with:
24+
java-version: '21'
25+
distribution: 'temurin'
26+
27+
- name: Grant execute permission for gradlew
28+
run: chmod +x gradlew
29+
30+
- name: Build without Test
31+
run: ./gradlew build -x test
32+
33+
# Docker Hub 로그인
34+
- name: Login to Docker Hub
35+
uses: docker/login-action@v3
36+
with:
37+
username: ${{ secrets.DOCKER_USERNAME }}
38+
password: ${{ secrets.DOCKER_PASSWORD }}
39+
40+
# Docker 이미지 빌드 및 푸시
41+
- name: Build and Push
42+
uses: docker/build-push-action@v5
43+
with:
44+
context: .
45+
push: true
46+
tags: ${{ env.DOCKER_IMAGE }}:latest
47+
48+
# docker-compose.prod.yml 파일을 서버로 전송 (SCP)
49+
- name: Copy Docker Compose file to Server
50+
uses: appleboy/scp-action@master
51+
with:
52+
host: ${{ secrets.EC2_HOST }}
53+
username: ${{ secrets.EC2_USER }}
54+
key: ${{ secrets.EC2_SSH_KEY }}
55+
port: 22
56+
source: "docker-compose.prod.yml"
57+
target: "/home/${{ secrets.EC2_USER }}/app"
58+
strip_components: 0
59+
60+
# EC2 서버에 배포 및 검증
61+
- name: Deploy to EC2
62+
uses: appleboy/ssh-action@master
63+
with:
64+
host: ${{ secrets.EC2_HOST }}
65+
username: ${{ secrets.EC2_USER }}
66+
key: ${{ secrets.EC2_SSH_KEY }}
67+
port: 22
68+
script: |
69+
# 앱 디렉토리 이동 및 환경변수 설정
70+
cd ~/app
71+
echo "${{ secrets.ENV_PROD }}" > .env.prod
72+
73+
# 최신 이미지 Pull
74+
sudo docker compose -f docker-compose.prod.yml pull
75+
76+
# 기존 컨테이너 내리고 새로 시작
77+
sudo docker compose -f docker-compose.prod.yml down
78+
sudo docker compose -f docker-compose.prod.yml up -d
79+
80+
# 배포 검증 (Health Check)
81+
echo "배포 후 Health Check 시작..."
82+
83+
for i in {1..12}; do
84+
RESPONSE=$(curl -s http://localhost:8080/api/actuator/health || true)
85+
86+
if [[ "$RESPONSE" == *"UP"* ]]; then
87+
echo "✅ 서비스 정상 실행 확인! (Attempt $i)"
88+
sudo docker image prune -f
89+
exit 0
90+
fi
91+
92+
echo "서비스 시작 대기 중... ($i/12)"
93+
sleep 5
94+
done
95+
96+
# 실패 시 처리
97+
echo "❌ 배포 실패: 서비스가 제한 시간 내에 뜨지 않았습니다."
98+
sudo docker compose -f docker-compose.prod.yml logs --tail=100
99+
exit 1

0 commit comments

Comments
 (0)