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
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/gradlew text eol=lf
*.bat text eol=crlf
*.jar binary
15 changes: 15 additions & 0 deletions .github/ISSUE_TEMPLATE/기능-구현.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
name: 기능 구현
about: '기능 설명 및 구현 '
title: "[FEAT]"
labels: "\U0001F6E0️ FEAT"
assignees: ''

---

## ✨ 구현 할 기능
- [ ]
- [ ]
- [ ]

<br>
12 changes: 12 additions & 0 deletions .github/ISSUE_TEMPLATE/기능-수정.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
name: 기능 수정
about: 리팩토링 목적이 아닌 기능 수정
title: "[FIX} "
labels: "\U0001F527 FIX"
assignees: ''

---

## 🛠️ 수정할 부분

<br>
12 changes: 12 additions & 0 deletions .github/ISSUE_TEMPLATE/기타-수정.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
name: 기타 수정
about: '작은 부분 수정 '
title: "[CHORE]"
labels: "\U0001F3B5 CHORE"
assignees: ''

---

## 수정 부분과 이유

<br>
12 changes: 12 additions & 0 deletions .github/ISSUE_TEMPLATE/리팩토링.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
name: 리팩토링
about: 클린코드, 디렉토리 구조 변경
title: "[REFACT] "
labels: "\U0001F31F REFACT"
assignees: ''

---

## ✨ 리팩토링 할 부분

<br>
12 changes: 12 additions & 0 deletions .github/ISSUE_TEMPLATE/문서-작업-.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
name: '문서 작업 '
about: 문서작업 내용
title: ''
labels: "\U0001F4DC DOC"
assignees: ''

---

## 📜 작업내용

<br>
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/오류수정.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: 오류수정
about: '오류 설명 및 수정 '
title: "[DEBUG]"
labels: "\U0001F577️ BUG"
assignees: ''

---

## 오류 내용

<br>


## ⚠ 에러로그 캡쳐

<br>
25 changes: 25 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## ❤️ 기능 설명

swagger 테스트 성공 결과 스크린샷 첨부
<br>

## 연결된 issue

연결된 issue를 자동으로 닫기 위해 아래 {이슈넘버}를 입력해주세요. <br>
close #{}
<br>
<br>

## 🩷 Approve 하기 전 확인해주세요!

- [ ] 리뷰어가 확인해줬으면 하는 사항 적어주세요.
- [ ]

<br>

## ✅ 체크리스트

- [ ] PR 제목 규칙 잘 지켰는가?
- [ ] 추가/수정사항을 설명하였는가?
- [ ] 테스트 결과 사진을 넣었는가?
- [ ] 이슈넘버를 적었는가?
93 changes: 93 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: CD - Deploy to Server

on:
workflow_run:
workflows: ["CI - Build and Test"]
types: [completed]
branches: [ develop, main ]

env:
DOCKER_IMAGE: ${{ secrets.DOCKERHUB_USERNAME }}/tech-blog

jobs:
docker-build:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Download JAR from CI
uses: actions/download-artifact@v4
with:
name: tech-blog-jar
path: build/libs/
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
push: true
tags: |
${{ env.DOCKER_IMAGE }}:${{ github.event.workflow_run.head_branch }}
${{ env.DOCKER_IMAGE }}:${{ github.event.workflow_run.head_branch }}-${{ github.event.workflow_run.head_sha }}

deploy:
needs: [docker-build]
runs-on: ubuntu-latest
env:
BRANCH: ${{ github.event.workflow_run.head_branch }}
SPRING_PROFILES_ACTIVE: dev
DB_URL: ${{ secrets.DB_URL }}
DB_USERNAME: ${{ secrets.DB_USERNAME }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
REDIS_HOST: redis
REDIS_PORT: 6379
REDIS_PASSWORD: ${{ secrets.REDIS_PASSWORD }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Copy deployment files to server
uses: appleboy/[email protected]
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_SSH_KEY }}
source: "docker-compose.yml, deploy.sh"
target: "~/deploy/"

- name: Deploy with docker-compose
uses: appleboy/[email protected]
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_SSH_KEY }}
envs: DOCKER_IMAGE,BRANCH,SPRING_PROFILES_ACTIVE,DB_URL,DB_USERNAME,DB_PASSWORD,REDIS_HOST,REDIS_PORT,REDIS_PASSWORD
script: |
cd ~/deploy
chmod +x deploy.sh
./deploy.sh

- name: Health check
run: |
sleep 25
response=$(curl -s -o /dev/null -w "%{http_code}" https://techfork.shop/actuator/health || echo "000")

if [ "$response" = "200" ]; then
echo "✅ 배포 성공!"
else
echo "❌ 헬스 체크 실패: $response"
exit 1
fi
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI - Build and Test

on:
pull_request:
branches: [ develop, main ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'

- name: Grant execute permission for gradlew
run: chmod +x ./gradlew

- name: Build with Gradle
run: ./gradlew clean build

- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: tech-blog-jar
path: build/libs/*.jar
retention-days: 3
45 changes: 45 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
HELP.md
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/
application-local.yml

### Terraform ###
.terraform/
*.tfstate
*.tfstate.*
*.tfvars
!*.tfvars.example
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Java 17 기반 슬림 이미지 사용
FROM openjdk:17-slim

ARG JAR_FILE=build/libs/*.jar

# jar 파일 복사
COPY ${JAR_FILE} app.jar

# 애플리케이션 실행
ENTRYPOINT ["java", "-jar", "app.jar"]
74 changes: 74 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.5.6'
id 'io.spring.dependency-management' version '1.1.7'
}

group = 'com.techfork'
version = '0.0.1-SNAPSHOT'
description = '주요 테크 블로그를 수집하고 제공하는 통합 플랫폼'

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

configurations {
compileOnly {
extendsFrom annotationProcessor
}
}

repositories {
mavenCentral()
}

ext {
set('springAiVersion', "1.0.3")
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'

runtimeOnly 'com.mysql:mysql-connector-j'

developmentOnly 'org.springframework.boot:spring-boot-devtools'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'

// implementation 'org.springframework.boot:spring-boot-starter-batch'
// testImplementation 'org.springframework.batch:spring-batch-test'

// implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
// implementation 'org.springframework.boot:spring-boot-starter-security'
// testImplementation 'org.springframework.security:spring-security-test'

// developmentOnly 'org.springframework.boot:spring-boot-docker-compose'
// developmentOnly 'org.springframework.ai:spring-ai-spring-boot-docker-compose'

// implementation 'org.springframework.boot:spring-boot-starter-data-elasticsearch'
// implementation 'org.springframework.ai:spring-ai-advisors-vector-store'
// implementation 'org.springframework.ai:spring-ai-starter-vector-store-elasticsearch'

// implementation 'org.springframework.ai:spring-ai-starter-model-anthropic'

implementation 'org.springframework.boot:spring-boot-starter-actuator'
}

dependencyManagement {
imports {
mavenBom "org.springframework.ai:spring-ai-bom:${springAiVersion}"
}
}

tasks.named('test') {
useJUnitPlatform()
}
Loading