Skip to content

Commit a5ee16f

Browse files
committed
Merge branch 'develop' into feature/diary
2 parents 76c989d + b6ff618 commit a5ee16f

File tree

13 files changed

+176
-88
lines changed

13 files changed

+176
-88
lines changed

.github/workflows/ci.cd.prod.yml

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ on:
77
types:
88
- closed
99
workflow_dispatch: # 수동 실행 가능
10-
11-
1210
# 병합됐을 때
1311
jobs:
14-
deploy:
12+
build:
1513
runs-on: ubuntu-latest
1614
steps:
1715
# 체크아웃
@@ -36,6 +34,17 @@ jobs:
3634
java-version: 21
3735
distribution: 'temurin'
3836

37+
# application.yml 생성
38+
- name: Make application.yml
39+
run: |
40+
mkdir -p ./src/main/resources
41+
cd ./src/main/resources
42+
touch ./application.yml
43+
touch ./application-secret.yml
44+
45+
echo "${{ secrets.APPLICATION }}" | base64 --decode > ./application.yml
46+
echo "${{ secrets.SECRET }}" | base64 --decode > ./application-secret.yml
47+
3948
# Gradle cache 설정
4049
- name: Cache Gradle packages
4150
uses: actions/cache@v4
@@ -50,24 +59,27 @@ jobs:
5059
with:
5160
arguments: clean build -x test
5261

62+
deploy:
63+
runs-on: ubuntu-latest
64+
if: github.event.pull_request.merged == true
65+
needs: build
66+
steps:
67+
- uses: actions/checkout@v4
5368

5469
# 빌드 결과물을 S3 버킷에 업로드
5570
- name: Upload to AWS S3
5671
run: |
5772
echo "S3 Location: s3://${{ secrets.S3_BUCKET_NAME }}/$GITHUB_SHA.zip"
5873
aws deploy push \
59-
--application-name ${{ secrets.CODE_DEPLOY_APP_NAME }} \
60-
--ignore-hidden-files \
61-
--s3-location s3://${{ secrets.S3_BUCKET_NAME }}/$GITHUB_SHA.zip \
62-
--source .
63-
74+
--application-name ${{ secrets.CODE_DEPLOY_APP_NAME }} \
75+
--ignore-hidden-files \
76+
--s3-location s3://${{ secrets.S3_BUCKET_NAME }}/prod/${{ github.sha }}.zip \
77+
--source .
6478
# S3 버킷에 있는 파일을 대상으로 CodeDeploy 실행
65-
- name: Deploy to AWS EC2 from S3
79+
- name: Deploy to AWS EC2 from S3g
6680
run: |
6781
aws deploy create-deployment \
6882
--application-name ${{ secrets.CODE_DEPLOY_APP_NAME }} \
6983
--deployment-config-name CodeDeployDefault.AllAtOnce \
7084
--deployment-group-name ${{ secrets.CODE_DEPLOY_DEPLOYMENT_GROUP_NAME }} \
71-
--s3-location bucket=${{ secrets.S3_BUCKET_NAME }},key=$GITHUB_SHA.zip,bundleType=zip
72-
73-
85+
--s3-location bucket=${{ secrets.S3_BUCKET_NAME }},key=prod/${{ github.sha }}.zip,bundleType=zip

.github/workflows/cr.yml

Lines changed: 0 additions & 53 deletions
This file was deleted.
Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
name: log4u-build
1+
name: log4u-dev-build
22
on:
3-
# push:
4-
# branches:
5-
# - develop # dev 브랜치 push
63
pull_request:
74
branches:
8-
- main # main pr
95
- develop # develop pr
106
types: [ opened, synchronize, reopened ]
7+
workflow_dispatch:
118
jobs:
129
build:
1310
name: Build and analyze
@@ -16,30 +13,59 @@ jobs:
1613
- uses: actions/checkout@v4
1714
with:
1815
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
16+
1917
- name: Set up JDK 21
2018
uses: actions/setup-java@v4
2119
with:
2220
java-version: 21
2321
distribution: 'zulu' # Alternative distribution options are available
22+
2423
- name: Cache Gradle packages
2524
uses: actions/cache@v4
2625
with:
2726
path: ~/.gradle/caches
2827
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
2928
restore-keys: ${{ runner.os }}-gradle
29+
3030
- name: Cache SonarCloud packages
3131
uses: actions/cache@v4
3232
with:
3333
path: ~/.sonar/cache
3434
key: ${{ runner.os }}-sonar
3535
restore-keys: ${{ runner.os }}-sonar
36+
37+
38+
- name: MySQL 컨테이너 실행
39+
run: |
40+
docker run --name test-mysql \
41+
-e MYSQL_ROOT_PASSWORD=root \
42+
-e MYSQL_DATABASE=log4u \
43+
-e MYSQL_USER=dev \
44+
-e MYSQL_PASSWORD=devcos4-team08 \
45+
-d \
46+
-p 3307:3306 \
47+
mysql:8.0.33
48+
3649
- name: Build and analyze
3750
env:
38-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3952
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
40-
DB_URL: ${{ secrets.DB_URL }} # Database URL
41-
DB_USERNAME: ${{ secrets.DB_USERNAME }} # Database username
42-
DB_PASSWORD: ${{ secrets.DB_PASSWORD }} # Database password
53+
DB_URL: jdbc:mysql://localhost:3307/log4u
54+
DB_USERNAME: dev
55+
DB_PASSWORD: devcos4-team08
56+
57+
# dev 프로필 사용
4358
run: |
4459
chmod +x ./gradlew
45-
./gradlew build jacocoTestReport sonar --info -Dsonar.branch.name=${{ github.ref_name }}
60+
./gradlew build jacocoTestReport sonar --info -Pprofile=dev -Dsonar.branch.name=${{ github.ref_name }}
61+
62+
- name: Docker MySQL 종료 및 제거
63+
run: |
64+
docker stop log4u-mysql
65+
docker rm log4u-mysql
66+
67+
- name: Upload Test Report
68+
uses: actions/upload-artifact@v4
69+
with:
70+
name: problems-report
71+
path: build/reports/problems/problems-report.html

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ out/
3535

3636
### VS Code ###
3737
.vscode/
38+
/src/main/resources/application-secret.yml

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## 개발 환경 설정
2+
3+
* 루트 디렉토리(WEB3_4_Log4U_BE)에서 다음 명령 실행
4+
5+
6+
* 개발용 MYSQL 빌드
7+
8+
```
9+
# 이미지 빌드
10+
cd docker
11+
docker build -t log4u-mysql .
12+
13+
# 최초 실행 1(볼륨 존재)
14+
docker run -d --name log4u-mysql -p 3307:3306 -v {file}:/var/lib/mysql log4u-mysql
15+
16+
# 최초 실행 2(볼륨 없이)
17+
docker run -d --name log4u-mysql -p 3307:3306 log4u-mysql
18+
19+
# 이미 존재할 경우
20+
docker start log4u-mysql
21+
22+
```

appspec.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ os: linux
33

44
files:
55
- source: /
6-
destination: /home/ubuntu/build
6+
destination: /home/ubuntu/app
77
overwrite: yes
88

99
permissions:
@@ -18,11 +18,6 @@ hooks:
1818
timeout: 2000
1919
runas: ubuntu
2020

21-
AfterInstall:
22-
- location: scripts/docker-start.sh
23-
timeout: 2000
24-
runas: ubuntu
25-
2621
ApplicationStart:
2722
- location: scripts/deploy.sh
2823
timeout: 2000

docker/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# MYSQL
2+
FROM mysql:8.0.33
3+
4+
# 변수 설정
5+
ENV TZ=Asia/Seoul \
6+
MYSQL_ROOT_PASSWORD=root \
7+
MYSQL_USER=dev \
8+
MYSQL_PASSWORD=devcos4-team08 \
9+
MYSQL_DATABASE=log4u
10+
11+
# 데이터 파일을 컨테이너에 연결
12+
VOLUME ["/var/lib/mysql"]
13+
14+
# MySQL 3306 포트
15+
EXPOSE 3306
16+
17+
# MYSQL 실행
18+
CMD ["mysqld"]

.github/scripts/deploy.sh renamed to scripts/deploy.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
PROJECT_ROOT="/home/ubuntu/build"
3+
PROJECT_ROOT="/home/ubuntu/app"
44
JAR_FILE="$PROJECT_ROOT/spring-log4u.jar"
55

66
APP_LOG="$PROJECT_ROOT/application.log"
@@ -11,7 +11,7 @@ TIME_NOW=$(date +%c)
1111

1212
# build 파일 복사
1313
echo "$TIME_NOW > $JAR_FILE 파일 복사" >> $DEPLOY_LOG
14-
cp $PROJECT_ROOT/build/libs/*.jar $JAR_FILE
14+
cp $PROJECT_ROOT/build/libs/Log4U-0.0.1-SNAPSHOT.jar $JAR_FILE
1515

1616
# jar 파일 실행
1717
echo "$TIME_NOW > $JAR_FILE 파일 실행" >> $DEPLOY_LOG

.github/scripts/stop.sh renamed to scripts/stop.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
PROJECT_ROOT="/home/ubuntu/build"
3+
PROJECT_ROOT="/home/ubuntu/app"
44
JAR_FILE="$PROJECT_ROOT/spring-log4u.jar"
55

66
DEPLOY_LOG="$PROJECT_ROOT/deploy.log"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
logging:
2+
level:
3+
org:
4+
springframework: debug
5+
6+
spring:
7+
jpa:
8+
database-platform: org.hibernate.dialect.MySQLDialect
9+
hibernate:
10+
ddl-auto: create
11+
12+
datasource:
13+
url: jdbc:mysql://localhost:3307/log4u
14+
username: dev
15+
password: devcos4-team08
16+
driver-class-name: com.mysql.cj.jdbc.Driver

0 commit comments

Comments
 (0)