Skip to content

Commit 956523b

Browse files
authored
Merge pull request #15 from Ring-Us/develop
fix: github actions main-cd 수정
2 parents 8d8651c + 67ded91 commit 956523b

File tree

21 files changed

+459
-65
lines changed

21 files changed

+459
-65
lines changed

.github/workflows/main-cd.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
push:
55
branches:
66
- main # main 브랜치에 푸시될 때 실행
7+
pull_request:
8+
branches:
9+
- main
710

811
jobs:
912
deploy:

build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ dependencies {
3939
annotationProcessor 'org.projectlombok:lombok'
4040
testImplementation 'org.springframework.boot:spring-boot-starter-test'
4141
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
42+
43+
//aws
44+
implementation platform('software.amazon.awssdk:bom:2.20.0') // AWS SDK 버전 관리
45+
implementation 'software.amazon.awssdk:s3'
46+
implementation 'software.amazon.awssdk:sts'
47+
implementation 'software.amazon.awssdk:core:2.30.20'
48+
implementation 'software.amazon.awssdk:ec2'
4249
}
4350

4451
tasks.named('test') {

dev.sh

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

3-
ENV_FILE=".env"
3+
ENV_FILE=".env.dev"
44

55
echo "[dev.sh] environment variable file: $ENV_FILE"
66

@@ -25,7 +25,7 @@ fi
2525

2626
echo "[dev.sh] environment variable load complete"
2727

28-
./gradlew clean build
28+
./gradlew build -x test
2929

3030
if [ $? -eq 0 ]; then
3131
echo "[dev.sh] build complete"
@@ -34,6 +34,6 @@ else
3434
exit 1
3535
fi
3636

37-
sudo docker compose --env-file .env up -d --build
37+
sudo docker compose --env-file .env.dev up -d --build
3838

39-
echo "[dev.sh] deploy complete"
39+
echo "[dev.sh] deploy complete"

docker-compose.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ services:
1414
restart: always
1515

1616
database:
17-
image: mysql:9.0.0
17+
image: mysql:8.4.4
1818
container_name: ring-us-database
1919
environment:
2020
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
@@ -34,16 +34,14 @@ services:
3434
redis:
3535
image: redis:7.0
3636
container_name: ring-us-redis
37-
environment:
38-
REDIS_PASSWORD : ${REDIS_PASSWORD}
39-
command: redis-server --requirepass ${REDIS_PASSWORD}
37+
command: --port ${REDIS_PORT} --requirepass ${REDIS_PASSWORD}
4038
expose:
4139
- ${REDIS_PORT}
4240
ports:
4341
- ${REDIS_PORT}:${REDIS_PORT}
4442
restart: always
4543
volumes:
46-
- ring-us-redis:/var/lib/redis
44+
- ring-us-redis:/data
4745
volumes:
4846
ring-us-database:
49-
ring-us-redis:
47+
ring-us-redis:

src/main/java/es/princip/ringus/domain/mentee/Mentee.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package es.princip.ringus.domain.mentee;
22

33
import es.princip.ringus.domain.common.Education;
4+
import es.princip.ringus.infra.storage.domain.Certificate;
5+
import es.princip.ringus.infra.storage.domain.ProfileImage;
46
import jakarta.persistence.*;
57
import lombok.AccessLevel;
68
import lombok.Builder;
@@ -30,6 +32,9 @@ public class Mentee {
3032
@Column(name = "introduction", length = 500)
3133
private String introduction;
3234

35+
@Embedded
36+
private ProfileImage profileImage;
37+
3338
@Column(name = "member_id")
3439
private Long memberId;
3540

@@ -45,4 +50,11 @@ public Mentee(
4550
this.introduction = introduction;
4651
this.memberId = memberId;
4752
}
53+
54+
/**
55+
* 프로필 이미지 업데이트
56+
*/
57+
public void updateProfileImage(ProfileImage profileImage) {
58+
this.profileImage = profileImage;
59+
}
4860
}

src/main/java/es/princip/ringus/domain/mentor/Mentor.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import es.princip.ringus.domain.mentor.vo.Organization;
77
import es.princip.ringus.domain.mentor.vo.Portfolio;
88
import es.princip.ringus.domain.mentor.vo.Timezone;
9+
import es.princip.ringus.infra.storage.domain.Certificate;
10+
import es.princip.ringus.infra.storage.domain.ProfileImage;
911
import jakarta.persistence.*;
1012
import lombok.AccessLevel;
1113
import lombok.Builder;
@@ -66,6 +68,9 @@ public class Mentor {
6668
@Embedded
6769
private Portfolio portfolio;
6870

71+
@Embedded
72+
private ProfileImage profileImage;
73+
6974
@Column(name = "member_id")
7075
private Long memberId;
7176

@@ -93,4 +98,11 @@ public Mentor(
9398
this.portfolio = portfolio;
9499
this.memberId = memberId;
95100
}
101+
102+
/**
103+
* 프로필 이미지 업데이트
104+
*/
105+
public void updateProfileImage(ProfileImage profileImage) {
106+
this.profileImage = profileImage;
107+
}
96108
}

src/main/java/es/princip/ringus/global/exception/CustomRuntimeException.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package es.princip.ringus.global.exception;
22

33
import lombok.Getter;
4+
import lombok.extern.slf4j.Slf4j;
45
import org.springframework.http.HttpStatus;
56

67
@Getter
8+
@Slf4j
79
public class CustomRuntimeException extends RuntimeException{
810

911
private HttpStatus status;
@@ -15,6 +17,8 @@ public CustomRuntimeException(ErrorCode errorCode){
1517
this.status = errorCode.status();
1618
this.message = errorCode.message();
1719
this.code = errorCode.code();
20+
21+
log.error("CustomRuntimeException 발생: status={}, code={}, message={}", status, code, message, this);
1822
}
1923

2024
}
Lines changed: 14 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,27 @@
11
package es.princip.ringus.global.util;
22

3-
import jakarta.annotation.PostConstruct;
4-
import org.springframework.beans.factory.annotation.Value;
5-
import org.springframework.stereotype.Component;
3+
import lombok.Getter;
64

7-
import java.io.BufferedReader;
8-
import java.io.FileReader;
9-
import java.io.IOException;
10-
import java.util.HashSet;
11-
import java.util.Set;
5+
@Getter
6+
public enum UniversityDomainUtil {
7+
KNU("knu.ac.kr");
128

13-
@Component
14-
public class UniversityDomainUtil {
9+
private final String domain;
1510

16-
private static String filePath;
17-
private static final Set<String> universityDomains = new HashSet<>();
18-
19-
public UniversityDomainUtil(@Value("${university.file.path}") String filePath) {
20-
UniversityDomainUtil.filePath = filePath;
21-
}
22-
23-
@PostConstruct
24-
private void init() {
25-
loadUniversityDomains();
11+
UniversityDomainUtil(String domain) {
12+
this.domain = domain;
2613
}
2714

2815
/**
29-
* 대학 도메인 목록을 파일에서 로드하여 universityDomains에 저장
30-
*/
31-
private static void loadUniversityDomains() {
32-
try (BufferedReader br = new BufferedReader(new FileReader(filePath))) {
33-
StringBuilder content = new StringBuilder();
34-
String line;
35-
36-
while ((line = br.readLine()) != null) {
37-
content.append(line).append(" ");
38-
}
39-
40-
String[] parts = content.toString().trim().split(" ");
41-
for (int i = 1; i < parts.length; i += 2) {
42-
universityDomains.add(parts[i]);
43-
}
44-
45-
} catch (IOException e) {
46-
throw new RuntimeException("대학 도메인을 읽어오는데 실패함", e);
47-
}
48-
}
49-
50-
/**
51-
* 이메일이 대학 도메인인지 확인
52-
* @param email 검사할 이메일 주소
53-
* @return 대학 도메인에 해당하면 true, 아니면 false
16+
* 주어진 이메일이 대학 도메인에 속하는지 확인
5417
*/
5518
public static boolean isUniversityVerified(String email) {
5619
String domain = email.substring(email.indexOf("@") + 1);
57-
return universityDomains.contains(domain);
20+
for (UniversityDomainUtil university : values()) {
21+
if (university.getDomain().equals(domain)) {
22+
return true;
23+
}
24+
}
25+
return false;
5826
}
5927
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package es.princip.ringus.infra.config;
2+
3+
import org.springframework.beans.factory.annotation.Value;
4+
import org.springframework.context.annotation.Bean;
5+
import org.springframework.stereotype.Component;
6+
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
7+
import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider;
8+
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
9+
import software.amazon.awssdk.regions.Region;
10+
import software.amazon.awssdk.services.s3.S3Client;
11+
12+
@Component
13+
public class S3Config {
14+
@Value("${aws.s3.region}")
15+
private String region;
16+
17+
@Value("${aws.s3.access-key:}")
18+
private String accessKey; // 액세스 키 (없으면 빈 값)
19+
20+
@Value("${aws.s3.secret-key:}")
21+
private String secretKey; // 시크릿 키 (없으면 빈 값)
22+
23+
@Bean
24+
public S3Client s3Client() {
25+
// 로컬 환경에서 액세스 키와 시크릿 키가 설정되어 있으면 StaticCredentialsProvider 사용
26+
if (!accessKey.isEmpty() && !secretKey.isEmpty()) {
27+
AwsBasicCredentials awsCredentials = AwsBasicCredentials.create(accessKey, secretKey);
28+
return S3Client.builder()
29+
.region(Region.of(region))
30+
.credentialsProvider(StaticCredentialsProvider.create(awsCredentials))
31+
.build();
32+
}
33+
34+
// EC2 환경에서는 DefaultCredentialsProvider 사용 (IAM 역할)
35+
return S3Client.builder()
36+
.region(Region.of(region))
37+
.credentialsProvider(DefaultCredentialsProvider.create())
38+
.build();
39+
}
40+
}

src/main/java/es/princip/ringus/infra/config/WebConfig.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ public WebConfig(SessionInterceptor sessionInterceptor) {
1919
@Override
2020
public void addInterceptors(InterceptorRegistry registry) {
2121
registry.addInterceptor(sessionInterceptor)
22-
.addPathPatterns("/**")
23-
.excludePathPatterns("/auth/**");
22+
.excludePathPatterns("/**")
23+
.excludePathPatterns("/auth/**")
24+
.excludePathPatterns("/service-terms")
25+
.excludePathPatterns("/swagger-ui/**")
26+
.excludePathPatterns("/v3/api-docs/**")
27+
.excludePathPatterns("/swagger-resources/**")
28+
.excludePathPatterns("/webjars/**");
2429
}
2530
}

0 commit comments

Comments
 (0)