Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6bf20a8
init: 프로젝트 세팅
hyoon1129 Feb 14, 2025
1d0516a
feat: 회사 및 주식 히스토리 엔티티 추가
hyoon1129 Feb 15, 2025
7299c92
feat: 리포지토리 계층 추가
hyoon1129 Feb 15, 2025
1989dc3
feat: 주식 데이터 응답 DTO 추가
hyoon1129 Feb 15, 2025
8d14635
feat: 주식 데이터 조회 서비스 추가
hyoon1129 Feb 15, 2025
83a7930
feat: 주식 데이터 조회 API 컨트롤러 추가
hyoon1129 Feb 15, 2025
21db340
feat: 전역 예외 처리 핸들러 추가
hyoon1129 Feb 15, 2025
31e8a7b
feat: 공통 API 응답 DTO 추가 및 적용
hyoon1129 Feb 15, 2025
df023a5
feat: 회사 코드 조회 실패 예외 클래스 추가
hyoon1129 Feb 15, 2025
e9bbceb
feat: GlobalExceptionHandler에 예외 처리 로직 추가
hyoon1129 Feb 15, 2025
7150362
refactor: API 응답 포맷에 HTTP 상태 코드 추가
hyoon1129 Feb 15, 2025
541472c
feat: startDate, endDate 유효성 검사 로직 추가
hyoon1129 Feb 15, 2025
858d1e7
refactor: API 키 검증 로직 개선 및 예외 처리 추가
hyoon1129 Feb 15, 2025
4a5c3f1
chore: 테스트용 H2 데이터베이스 종속성 추가
hyoon1129 Feb 16, 2025
0fcce09
fix: API 키 검증 메서드 개선
hyoon1129 Feb 16, 2025
3bd7731
chore: 테스트 환경 설정을 위한 application-test.yml 추가
hyoon1129 Feb 16, 2025
3bba6eb
feat: StockService 테스트 코드 작성
hyoon1129 Feb 16, 2025
fd12147
feat: 예외 상황 검증을 위한 StockExceptionTest 추가
hyoon1129 Feb 16, 2025
a6b645c
docs: API 문서 추가
hyoon1129 Feb 16, 2025
2d0d327
fix: 오타 수정
hyoon1129 Feb 16, 2025
d04689a
refactor: api key 상수로 관리하게 수정
hyoon1129 Feb 16, 2025
f6bd3ff
refactor: API 키 검증 예외 클래스 추가
hyoon1129 Feb 16, 2025
cf1d593
refactor: API 키 설정 ConfigurationProperties로 변경
hyoon1129 Feb 16, 2025
38c3bb9
feat: 로그 설정 및 GlobalExceptionHandler 로깅 추가
hyoon1129 Feb 16, 2025
309a800
feat: docker와 ghcr을 이용한 배포 설정
hyoon1129 Feb 16, 2025
236cef1
docs: API_DOCS 수정
hyoon1129 Feb 16, 2025
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
63 changes: 63 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Deploy to EC2 with GHCR

on:
push:
branches:
- feature

env:
IMAGE_NAME: ghcr.io/${{ github.repository }}/ktb-yuni-api

jobs:
build-and-deploy:
runs-on: ubuntu-latest

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

- name: Build with Gradle
run: ./gradlew build -x test

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to GHCR
run: echo "${{ secrets.GHCR_PAT }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin

- name: Build and push Docker image
run: |
IMAGE_NAME_LOWER=$(echo "${IMAGE_NAME}" | tr '[:upper:]' '[:lower:]')
docker build -t $IMAGE_NAME_LOWER:latest .
docker push $IMAGE_NAME_LOWER:latest

- name: Set up SSH key
run: |
echo "${{ secrets.EC2_KEY }}" | base64 -d > yuni-key.pem
chmod 600 yuni-key.pem

- name: Deploy to EC2
env:
EC2_HOST: ${{ secrets.EC2_HOST }}
EC2_USER: ${{ secrets.EC2_USER }}
GHCR_USERNAME: ${{ github.actor }}
GHCR_TOKEN: ${{ secrets.GHCR_PAT }}
run: |
ssh -o StrictHostKeyChecking=no -i yuni-key.pem $EC2_USER@$EC2_HOST <<EOF
# GHCR 로그인
echo "$GHCR_TOKEN" | docker login ghcr.io -u "$GHCR_USERNAME" --password-stdin

# 기존 컨테이너 중지 및 삭제
docker stop ktb-yuni-api || true
docker rm ktb-yuni-api || true

# 사용하지 않는 이미지 제거
docker image prune -af

# 최신 이미지 Pull 및 실행
docker pull $IMAGE_NAME:latest
docker run -d --name ktb-yuni-api \
-p 8080:8080 \
-v /home/ubuntu/application.properties:/app/application.properties \
ghcr.io/hyoon1129/ktb-be-dev-assignment/ktb-yuni-api:latest
EOF
272 changes: 272 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,272 @@
# Created by https://www.toptal.com/developers/gitignore/api/git,macos,intellij,java,gradle,maven,netbeans,visualstudiocode
# Edit at https://www.toptal.com/developers/gitignore?templates=git,macos,intellij,java,gradle,maven,netbeans,visualstudiocode

### Git ###
# Created by git for backups. To disable backups in Git:
# $ git config --global mergetool.keepBackup false
*.orig

# Created by git when using merge tools for conflicts
*.BACKUP.*
*.BASE.*
*.LOCAL.*
*.REMOTE.*
*_BACKUP_*.txt
*_BASE_*.txt
*_LOCAL_*.txt
*_REMOTE_*.txt

### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# SonarLint plugin
.idea/sonarlint/

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721

# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr

# Sonarlint plugin
# https://plugins.jetbrains.com/plugin/7973-sonarlint
.idea/**/sonarlint/

# SonarQube Plugin
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
.idea/**/sonarIssues.xml

# Markdown Navigator plugin
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
.idea/**/markdown-navigator.xml
.idea/**/markdown-navigator-enh.xml
.idea/**/markdown-navigator/

# Cache file creation bug
# See https://youtrack.jetbrains.com/issue/JBR-2257
.idea/$CACHE_FILE$

# CodeStream plugin
# https://plugins.jetbrains.com/plugin/12206-codestream
.idea/codestream.xml

# Azure Toolkit for IntelliJ plugin
# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij
.idea/**/azureSettings.xml

### 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

### Maven ###
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
.mvn/wrapper/maven-wrapper.jar

# Eclipse m2e generated files
# Eclipse Core
.project
# JDT-specific (Eclipse Java Development Tools)
.classpath

### NetBeans ###
**/nbproject/private/
**/nbproject/Makefile-*.mk
**/nbproject/Package-*.bash
build/
nbbuild/
dist/
nbdist/
.nb-gradle/

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix

### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide

### Gradle ###
.gradle
**/build/
!src/**/build/

# Ignore Gradle GUI config
gradle-app.setting

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

# Avoid ignore Gradle wrappper properties
!gradle-wrapper.properties

# Cache of project
.gradletasknamecache

# Eclipse Gradle plugin generated files
# Eclipse Core
# JDT-specific (Eclipse Java Development Tools)

### Gradle Patch ###
# Java heap dump
application.properties
*.hprof
HELP.md
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
.idea
.gradle/
# End of https://www.toptal.com/developers/gitignore/api/git,macos,intellij,java,gradle,maven,netbeans,visualstudiocode
Loading