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
74 changes: 74 additions & 0 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Spring Boot CD to EC2

on:
push:
branches:
- develop

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

steps:
# 1. 코드 체크아웃
- name: Checkout code
uses: actions/checkout@v3

# 2. JDK 설정
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'
cache: 'gradle'

# 3. Gradle 실행 권한 부여
- name: Grant execute permission for gradlew
run: chmod +x gradlew

# 4. 빌드 (테스트 포함)
- name: Build with Gradle
run: ./gradlew clean build

# 5. JAR 파일명 확인 및 환경변수 설정
- name: Get JAR file name
id: jar_name
run: |
JAR_FILE=$(ls build/libs/*.jar | grep -v plain | head -n 1)
echo "jar_path=$JAR_FILE" >> $GITHUB_OUTPUT
echo "jar_name=$(basename $JAR_FILE)" >> $GITHUB_OUTPUT

# 6. EC2로 JAR 파일 전송
- name: Copy JAR to EC2
uses: appleboy/scp-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_SSH_KEY }}
port: ${{ secrets.EC2_SSH_PORT }}
source: ${{ steps.jar_name.outputs.jar_path }}
target: "/home/${{ secrets.EC2_USERNAME }}/app"
strip_components: 2

# 7. 배포 스크립트 실행
- name: Execute deployment script on EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_SSH_KEY }}
port: ${{ secrets.EC2_SSH_PORT }}
script: |
cd /home/${{ secrets.EC2_USERNAME }}/app
chmod +x deploy.sh
./deploy.sh ${{ steps.jar_name.outputs.jar_name }}

# 8. 배포 결과 알림
- name: Notify deployment status
if: always()
run: |
if [ ${{ job.status }} == 'success' ]; then
echo "✅ 배포 성공!"
else
echo "❌ 배포 실패!"
fi
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ out/
### VS Code ###
.vscode/

**/application.yml
**/application-local.yml
**/application.properties

/lib/
11 changes: 10 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,22 @@ dependencies {
implementation 'org.locationtech.jts:jts-core:1.19.0'

// Swagger-ui
implementation "org.springdoc:springdoc-openapi-starter-webmvc-ui:2.5.0"
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.5.0'

// EXIF metadata extraction
implementation 'com.drewnoakes:metadata-extractor:2.19.0'

// File type validation
implementation 'org.apache.tika:tika-core:2.9.1'

// BOM
implementation platform('io.awspring.cloud:spring-cloud-aws-dependencies:3.2.1')

// 사용하려는 프레임워크 모듈
implementation 'io.awspring.cloud:spring-cloud-aws-starter-parameter-store'

// AWS 자격 증명
implementation 'io.awspring.cloud:spring-cloud-aws-starter'
}

tasks.named('test') {
Expand Down
19 changes: 19 additions & 0 deletions src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
spring:
config:
import:
- "aws-parameterstore:/PHOTO_LINER_API/rds/dev/"
- "aws-parameterstore:/PHOTO_LINER_API/ec2/dev/"

cloud:
aws:
region:
static: ap-northeast-2

datasource:
url: ${MYSQL_URL}
username: ${MYSQL_USER_NAME}
password: ${MYSQL_PASSWORD}

photo:
upload:
base-dir: ${PHOTOS_UPLOAD_URL}
10 changes: 10 additions & 0 deletions src/main/resources/application-local-example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
spring:

datasource:
url: url
username: username
password: password

photo:
upload:
base-dir: url
27 changes: 27 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
spring:
profiles:
active: local

application:
name: PhotoLiner

servlet:
multipart:
enabled: true
max-file-size: 10MB
max-request-size: 100MB

datasource:
driver-class-name: com.mysql.cj.jdbc.Driver

jpa:
hibernate:
ddl-auto: validate
show-sql: true
properties:
hibernate:
format_sql: true

flyway:
enabled: true
baseline-on-migrate: true