Skip to content

Commit ed45127

Browse files
committed
Merge branch 'develop' into feature/login
2 parents c803b8e + d260bc7 commit ed45127

File tree

54 files changed

+1714
-38
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1714
-38
lines changed

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

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Deploy workflow on production environment
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
types:
8+
- closed
9+
workflow_dispatch: # 수동 실행 가능
10+
11+
12+
# 병합됐을 때
13+
jobs:
14+
deploy:
15+
runs-on: ubuntu-latest
16+
steps:
17+
# 체크아웃
18+
- uses: actions/checkout@v4
19+
20+
# AWS 인증 (IAM 사용자 Access Key, Secret Key 활용)
21+
- name: Configure AWS credentials
22+
uses: aws-actions/configure-aws-credentials@v1
23+
with:
24+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
25+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
26+
aws-region: ${{ secrets.AWS_REGION }}
27+
28+
# Gradle 권한 설정
29+
- name: Grant execute permission for gradlew
30+
run: chmod +x ./gradlew
31+
32+
# JDK 21 세팅
33+
- name: Set up JDK 21
34+
uses: actions/setup-java@v4
35+
with:
36+
java-version: 21
37+
distribution: 'temurin'
38+
39+
# application.yml 생성
40+
- name: Make application.yml
41+
run: |
42+
mkdir -p ./src/main/resources
43+
cd ./src/main/resources
44+
touch ./application.yml
45+
touch ./application-secret.yml
46+
47+
echo "${{ secrets.APPLICATION }}" | base64 --decode > ./application.yml
48+
echo "${{ secrets.SECRET }}" | base64 --decode > ./application-secret.yml
49+
50+
# Gradle cache 설정
51+
- name: Cache Gradle packages
52+
uses: actions/cache@v4
53+
with:
54+
path: ~/.gradle/caches
55+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
56+
restore-keys: ${{ runner.os }}-gradle
57+
58+
# Gradle build (우선 Test 제외)
59+
- name: Build with Gradle
60+
uses: gradle/gradle-build-action@0d13054264b0bb894ded474f08ebb30921341cee
61+
with:
62+
arguments: clean build -x test
63+
64+
65+
# 빌드 결과물을 S3 버킷에 업로드
66+
- name: Upload to AWS S3
67+
run: |
68+
echo "S3 Location: s3://${{ secrets.S3_BUCKET_NAME }}/$GITHUB_SHA.zip"
69+
aws deploy push \
70+
--application-name ${{ secrets.CODE_DEPLOY_APP_NAME }} \
71+
--ignore-hidden-files \
72+
--s3-location s3://${{ secrets.S3_BUCKET_NAME }}/prod/${{ github.sha }}.zip \
73+
--source .
74+
75+
# S3 버킷에 있는 파일을 대상으로 CodeDeploy 실행
76+
- name: Deploy to AWS EC2 from S3g
77+
run: |
78+
aws deploy create-deployment \
79+
--application-name ${{ secrets.CODE_DEPLOY_APP_NAME }} \
80+
--deployment-config-name CodeDeployDefault.AllAtOnce \
81+
--deployment-group-name ${{ secrets.CODE_DEPLOY_DEPLOYMENT_GROUP_NAME }} \
82+
--s3-location bucket=${{ secrets.S3_BUCKET_NAME }},key=prod/${{ github.sha }}.zip,bundleType=zip
83+
84+

.github/workflows/code-review-gpt.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

appspec.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
version: 0.0
2+
os: linux
3+
4+
files:
5+
- source: /
6+
destination: /home/ubuntu/app
7+
overwrite: yes
8+
9+
permissions:
10+
- object: /
11+
pattern: "**"
12+
owner: ubuntu
13+
group: ubuntu
14+
15+
hooks:
16+
AfterInstall:
17+
- location: scripts/stop.sh
18+
timeout: 2000
19+
runas: ubuntu
20+
21+
ApplicationStart:
22+
- location: scripts/deploy.sh
23+
timeout: 2000
24+
runas: ubuntu

build.gradle.kts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,20 @@ dependencies {
4444
testImplementation("org.springframework.security:spring-security-test")
4545
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
4646

47-
// JWT 관련
47+
// JWT 관련
4848
implementation("io.jsonwebtoken:jjwt-api:0.12.6")
4949
runtimeOnly("io.jsonwebtoken:jjwt-impl:0.12.6")
5050
runtimeOnly("io.jsonwebtoken:jjwt-jackson:0.12.6")
5151

52-
// Swagger
52+
// Swagger
5353
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.1")
5454

55+
// QueryDSL
56+
implementation("com.querydsl:querydsl-jpa:5.0.0:jakarta")
57+
annotationProcessor("com.querydsl:querydsl-apt:5.0.0:jakarta")
58+
annotationProcessor("jakarta.annotation:jakarta.annotation-api")
59+
annotationProcessor("jakarta.persistence:jakarta.persistence-api")
60+
5561
// mysql
5662
runtimeOnly("com.mysql:mysql-connector-j")
5763
}

scripts/deploy.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
PROJECT_ROOT="/home/ubuntu/app"
4+
JAR_FILE="$PROJECT_ROOT/spring-log4u.jar"
5+
6+
APP_LOG="$PROJECT_ROOT/application.log"
7+
ERROR_LOG="$PROJECT_ROOT/error.log"
8+
DEPLOY_LOG="$PROJECT_ROOT/deploy.log"
9+
10+
TIME_NOW=$(date +%c)
11+
12+
# build 파일 복사
13+
echo "$TIME_NOW > $JAR_FILE 파일 복사" >> $DEPLOY_LOG
14+
cp $PROJECT_ROOT/build/libs/Log4U-0.0.1-SNAPSHOT.jar $JAR_FILE
15+
16+
# jar 파일 실행
17+
echo "$TIME_NOW > $JAR_FILE 파일 실행" >> $DEPLOY_LOG
18+
nohup java -jar $JAR_FILE > $APP_LOG 2> $ERROR_LOG &
19+
20+
CURRENT_PID=$(pgrep -f $JAR_FILE)
21+
echo "$TIME_NOW > 실행된 프로세스 아이디 $CURRENT_PID 입니다." >> $DEPLOY_LOG

scripts/stop.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
PROJECT_ROOT="/home/ubuntu/app"
4+
JAR_FILE="$PROJECT_ROOT/spring-log4u.jar"
5+
6+
DEPLOY_LOG="$PROJECT_ROOT/deploy.log"
7+
8+
TIME_NOW=$(date +%c)
9+
10+
# 현재 구동 중인 애플리케이션 pid 확인
11+
CURRENT_PID=$(pgrep -f $JAR_FILE)
12+
13+
# 프로세스가 켜져 있으면 종료
14+
if [ -z $CURRENT_PID ]; then
15+
echo "$TIME_NOW > 현재 실행중인 애플리케이션이 없습니다" >> $DEPLOY_LOG
16+
else
17+
echo "$TIME_NOW > 실행중인 $CURRENT_PID 애플리케이션 종료 " >> $DEPLOY_LOG
18+
kill -15 $CURRENT_PID
19+
fi

src/main/java/com/example/log4u/Log4UApplication.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
@SpringBootApplication
99
public class Log4UApplication {
1010

11-
public static void main(String[] args) {
12-
SpringApplication.run(Log4UApplication.class, args);
13-
}
11+
public static void main(String[] args) {
12+
SpringApplication.run(Log4UApplication.class, args);
13+
}
1414

1515
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.example.log4u.common.config;
2+
3+
import org.springframework.context.annotation.Bean;
4+
import org.springframework.context.annotation.Configuration;
5+
6+
import com.querydsl.jpa.impl.JPAQueryFactory;
7+
8+
import jakarta.persistence.EntityManager;
9+
10+
@Configuration
11+
public class QueryDslConfig {
12+
13+
private final EntityManager entityManager;
14+
15+
public QueryDslConfig(EntityManager entityManager) {
16+
this.entityManager = entityManager;
17+
}
18+
19+
@Bean
20+
public JPAQueryFactory jpaQueryFactory() {
21+
return new JPAQueryFactory(entityManager);
22+
}
23+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package com.example.log4u.common.dto;
2+
3+
import java.util.List;
4+
5+
import org.springframework.data.domain.Page;
6+
import org.springframework.data.domain.Slice;
7+
8+
public record PageResponse<T>(
9+
List<T> content,
10+
PageInfo pageInfo
11+
) {
12+
// 오프셋 기반 (검색용)
13+
public static <T> PageResponse<T> of(Page<T> page) {
14+
return new PageResponse<>(
15+
page.getContent(),
16+
PageInfo.of(page)
17+
);
18+
}
19+
20+
// 커서 기반 (무한 스크롤용)
21+
public static <T> PageResponse<T> of(Slice<T> slice, Long nextCursor) {
22+
return new PageResponse<>(
23+
slice.getContent(),
24+
PageInfo.of(slice, nextCursor)
25+
);
26+
}
27+
28+
public record PageInfo(
29+
Integer page,
30+
int size,
31+
Long totalElements,
32+
Integer totalPages,
33+
boolean hasNext,
34+
Long nextCursor
35+
) {
36+
// Page용 팩토리 메서드
37+
public static PageInfo of(Page<?> page) {
38+
return new PageInfo(
39+
page.getNumber(),
40+
page.getSize(),
41+
page.getTotalElements(),
42+
page.getTotalPages(),
43+
page.hasNext(),
44+
null
45+
);
46+
}
47+
48+
// Slice용 팩토리 메서드
49+
public static PageInfo of(Slice<?> slice, Long nextCursor) {
50+
return new PageInfo(
51+
null,
52+
slice.getSize(),
53+
null,
54+
null,
55+
slice.hasNext(),
56+
nextCursor
57+
);
58+
}
59+
}
60+
}

src/main/java/com/example/log4u/common/entity/BaseEntity.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,4 @@ abstract public class BaseEntity {
2323
@LastModifiedDate
2424
@Column(nullable = false)
2525
private LocalDateTime updatedAt;
26-
27-
private String deleteYn = "N";
28-
}
26+
}

0 commit comments

Comments
 (0)