Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Sprint#1] 프로젝트 기반 및 CI/CD 파이프라인 작성 #9

Merged
merged 25 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b9d020f
[#1] feat: Initialize base project with Spring Security, global excep…
Starlight258 Jan 21, 2024
44ed478
Merge pull request #2 from Starlight258/feat/setup-foundation
Starlight258 Jan 22, 2024
77786e5
feat: add ci workflow using sonarqube
FacerAin Jan 24, 2024
3499655
feat: add test profile and in-memory h2 db
FacerAin Jan 24, 2024
3068c57
chore: add workflow-dispatch for triggering manually
FacerAin Jan 24, 2024
fa0d3b0
chore: fix user table name for h2 db reserved word
FacerAin Jan 24, 2024
7f6e288
chore: update build workflow for gradle clean
FacerAin Jan 24, 2024
9b7c934
chore: fix profile for ci/cd testing
FacerAin Jan 24, 2024
77fc238
chore: fix profile for ci/cd testing
FacerAin Jan 24, 2024
21751f3
feat: update build workflow for base64 encode
FacerAin Jan 24, 2024
90d8347
chore: update build workflow for debug
FacerAin Jan 24, 2024
65a5049
chore: update build workflow for debug
FacerAin Jan 24, 2024
aa9e5af
chore: update build workflow for debug
FacerAin Jan 24, 2024
b7b697c
chore: update build workflow for debug
FacerAin Jan 24, 2024
ad1d859
Merge remote-tracking branch 'origin/main'
FacerAin Jan 24, 2024
a62ae89
chore: fix profile for ci/cd testing
FacerAin Jan 24, 2024
72df53f
chore: remove unused build workflow task
FacerAin Jan 24, 2024
ae847b4
chore: update table name user to member for reserved word
FacerAin Jan 27, 2024
e31fd35
Merge pull request #4 from FacerAin/feat/setup-cicd
FacerAin Jan 27, 2024
1c6a729
[#1] feat: Add H2 database dependency and enable iframe for H2 console
Starlight258 Jan 27, 2024
5066758
[#5] feat: Implement Docker support and switch H2 DB to file-based st…
Starlight258 Jan 29, 2024
5aae3fe
[#6] chore: Add git commit message template
Starlight258 Jan 29, 2024
618dfe8
[#8] chore: Exclude .DS_Store from Git tracking
Starlight258 Jan 30, 2024
a5f1c3f
[#8] refactor: Use wildcard for JAR file in Dockerfile
Starlight258 Jan 30, 2024
37acd37
Merge pull request #8 from Starlight258/feat/dockerizing
FacerAin Jan 30, 2024
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
41 changes: 41 additions & 0 deletions .github/.gitmessage.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[#issue] type: description

# Commit Message Convention
#
# - 커밋 메시지는 반드시 영어로 작성합니다.
# - GitHub 이슈 번호를 참조합니다.
# - Description의 첫 글자는 대문자로 시작합니다.
#
# 기본 형식
# - `[#{issue-number}] <type>: <description>`
#
# 예시
# - `[#123] feat: Add login functionality`
#
# Commit Types
#
# 🌟 새로운 기능 및 주요 변경
# - `feat`: 새로운 기능 추가
# - `!BREAKING CHANGE`: 큰 API 변경
#
# 🛠️ 버그 수정 및 긴급 조치
# - `fix`: 버그 수정
# - `!HOTFIX`: 긴급한 버그 수정
#
# 🔧 코드 개선
# - `refactor`: 코드 리팩토링
# - `style`: 코드 포맷 변경, 세미콜론 누락 등 코드 수정 없는 경우
#
# 📚 문서 및 주석
# - `docs`: 문서 수정
# - `comment`: 주석 추가 및 변경
#
# 🧪 테스트
# - `test`: 테스트 코드 추가, 프로덕션 코드 변경 없음
#
# 🏗️ 구조적 변경
# - `rename`: 파일/폴더명 수정, 이동
# - `remove`: 파일 삭제
#
# 🎨 기타
# - `chore`: 빌드 업무 수정, 패키지 매니저 변경 등 프로덕션 코드 변경 없는 경우
43 changes: 43 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Build

on: [pull_request, workflow_dispatch]


jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
- name: Make application-prod.yml
run: |
touch src/main/resources/application-prod.yml
echo "${{ secrets.APPLICATION_PROD }}" | base64 --decode > src/main/resources/application-prod.yml
- name: Make application-test.yml
run: |
touch src/main/resources/application-test.yml
echo "${{ secrets.APPLICATION_TEST }}" | base64 --decode > src/main/resources/application-test.yml
- name: Cache SonarQube packages
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Gradle packages
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
run: ./gradlew clean build sonar --info
115 changes: 115 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
HELP.md
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
# yml
**/application-local.yml
**/application-prod.yml
**/application-test.yml
# db data
data/
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### Database ###
*.accdb
*.db
*.dbf
*.mdb
*.pdb
*.sqlite3
*.db-shm
*.db-wal

### Java ###
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### macOS Patch ###
# iCloud generated files
*.icloud

### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# JDK 17을 기반으로 하는 이미지 사용
FROM openjdk:17-alpine

# 작업 디렉토리
WORKDIR /usr/src/app

# 변수 정의 (빌드 시 사용)
ARG JAR_PATH=./build/libs

# 빌드한 파일 옮기기
COPY ${JAR_PATH}/*.jar ${JAR_PATH}/app.jar

# 환경변수 설정 (실행중인 컨테이너에 액세스 가능)
ENV JAR_PATH ${JAR_PATH}

# ENV 이용해서 실행
CMD java -jar ${JAR_PATH}/app.jar
Empty file added README.md
Empty file.
59 changes: 59 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.2.1'
id 'io.spring.dependency-management' version '1.1.4'
id "org.sonarqube" version "4.0.0.2929"
}

group = 'org.dnd'
version = '0.0.1-SNAPSHOT'

java {
sourceCompatibility = '17'
}

configurations {
compileOnly {
extendsFrom annotationProcessor
}
}

repositories {
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-aop'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0'
implementation("org.springframework.boot:spring-boot-devtools")


compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.mysql:mysql-connector-j'
runtimeOnly("com.h2database:h2")

annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
testRuntimeOnly 'com.h2database:h2'

// third-party
implementation group: 'com.auth0', name: 'java-jwt', version: '4.3.0'

}

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

sonar {
properties {
property "sonar.projectKey", "dnd-10th-2-backend"
}
}
18 changes: 18 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: '3.7'
services:
app:
build:
context: .
dockerfile: Dockerfile
environment: # 환경 변수 설정
- SPRING_DATASOURCE_URL=jdbc:h2:file:/usr/src/app/data/mydb;DB_CLOSE_ON_EXIT=FALSE
platform: linux/amd64
ports:
- "8080:8080"
# h2data 볼륨을 컨테이너 내부의 /usr/src/app/data에 매핑
volumes:
- h2data:/usr/src/app/data

# 볼륨 정의 (기본 설정 사용)
volumes:
h2data:
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading
Loading