Skip to content

Commit

Permalink
Merge branch 'refactor/#128' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jemin committed Dec 7, 2023
2 parents a9df550 + 90d56c6 commit 151cb83
Show file tree
Hide file tree
Showing 159 changed files with 1,384 additions and 1,220 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/backend-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Deploy to Production

on:
push:
branches:
- develop

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout source code
uses: actions/checkout@master

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'

- name: Gradle Caching
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build with Gradle
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew build

# 배포에 필요한 여러 설정 파일과 프로젝트 빌드 파일을 zip 파일로 모아준다.
- name: Make zip file
run: |
mkdir deploy
cp ./docker/docker-compose.blue.yml ./deploy/
cp ./docker/docker-compose.green.yml ./deploy/
cp ./appspec.yml ./deploy/
cp ./docker/Dockerfile ./deploy/
cp ./core/core-api/build/libs/core-api-0.0.1-SNAPSHOT.jar ./deploy/
zip -r -qq -j ./spring-build.zip ./deploy
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2

- name: Upload to S3
run: |
aws s3 cp \
--region ap-northeast-2 \
./spring-build.zip s3://melly-s3
# 추가
- name: Code Deploy
run: aws deploy create-deployment --application-name melly-codedeploy
--deployment-config-name CodeDeployDefault.HalfAtATime
--deployment-group-name spring-deploy-group
--s3-location bucket=melly-s3,bundleType=zip,key=spring-build.zip
5 changes: 0 additions & 5 deletions Dockerfile

This file was deleted.

35 changes: 35 additions & 0 deletions appspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: 0.0

# Deploy 대상 서버의 운영체제를 표시
os: linux

# 코드 파일 전송과 관련된 설정
files:
# 코드 파일의 소스 경로
- source: /
# 코드 파일의 대상 경로 -> /home/ec2-user/app 디렉토리로 파일을 복사한다.
destination: /home/ec2-user/app
# 대상 경로에 이미 파일이 존재하는 경우, 덮어쓰기를 허용할지 여부
overwrite: yes

# 파일 및 디렉토리 권한에 관련된 설정
permissions:
# 권한을 설정할 대상 경로
- object: /
# 모든 파일 및 디렉토리를 의미
pattern: "**"
# 파일 및 디렉토리의 소유자를 ec2-user로 설정
owner: ec2-user
# 파일 및 디렉토리의 그룹을 ec2-user로 설정
group: ec2-user

# Deploy 전후에 실행할 스크립트 또는 명령에 관련된 설정
hooks:
# 애플리케이션 시작시 실행할 스크립트 또는 명령에 관련된 설정
ApplicationStart:
# 실행할 스크립트 또는 명령의 위치
- location: deploy.sh
# 스크립트 또는 명령 실행의 제한 시간을 설정
timeout: 60
# CodeDeploy 중 실행되는 스크립트 또는 명령을 실행할 사용자를 지정
runas: ec2-user
9 changes: 5 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ allprojects {
repositories {
mavenCentral()
}


}


Expand All @@ -21,17 +23,16 @@ subprojects {
apply plugin: 'io.spring.dependency-management'
apply plugin: 'jacoco'
apply plugin: 'jacoco-report-aggregation'


bootJar.enabled = false // core-api 모듈 이외에는 모두 boot 되지 않는 모듈
jar.enabled = true // jar는 필요함
jar.enabled = true

dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudDependenciesVersion}"
mavenBom "org.springframework.cloud:spring-cloud-dependencies:2022.0.3"
}
}

jacoco {
toolVersion = '0.8.8'
}
Expand Down
3 changes: 2 additions & 1 deletion clients/client-auth/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies {
implementation 'io.github.openfeign:feign-hc5' // Open Feign의 클라이언트로 Apache HttpClient5를 사용합니다

// Fault Tolerance
implementation 'org.springframework.cloud:spring-cloud-starter-circuitbreaker-resilience4j'


// JWT
implementation 'io.jsonwebtoken:jjwt-api:0.11.2'
Expand All @@ -24,3 +24,4 @@ dependencies {

testImplementation "org.springframework.cloud:spring-cloud-starter-contract-stub-runner"
}

4 changes: 2 additions & 2 deletions clients/client-auth/src/main/resources/client-auth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ spring.cloud.openfeign:
loggerLevel: full # openFeign 관련 모든 로그 출력

httpclient:
max-connections: 2000 # 전체 커넥션 수
max-connections-per-route: 500 # Route당 할당되는 최대 커넥션 수
max-connections: 400 # 전체 커넥션 수
max-connections-per-route: 100 # Route당 할당되는 최대 커넥션 수

circuitbreaker:
enabled: true
Expand Down
9 changes: 3 additions & 6 deletions core/core-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,14 @@ dependencies {
annotationProcessor "jakarta.annotation:jakarta.annotation-api"
annotationProcessor "jakarta.persistence:jakarta.persistence-api"


/*
현재 Melly 프로젝트의 clients:client-auth 모듈에서 OpenFeign을 위한 Circuit Breaker를 위해 Resilience4j 라이브러리를 implementation으로 사용하고 있습니다.
core-api 모듈에서 client-auth 모듈을 의존하고 있기에 core-api의 compile classpath에 resilence4j가 들어오지는 않지만 runtime에는 사용이 가능합니다.
따라서 core-api 모듈에서는 중복으로 implementation을 하지 않고 compileOnly로 compile classpath에만 의존성을 추가했습니다.
*/
implementation "org.springframework.cloud:spring-cloud-starter-circuitbreaker-resilience4j:3.0.2"
implementation "io.github.resilience4j:resilience4j-all"

// Test
testImplementation 'org.springframework.security:spring-security-test'

implementation 'org.ehcache:ehcache:3.10.8'
implementation 'javax.cache:cache-api:1.1.1'

// Rest Docs
asciidoctorExt 'org.springframework.restdocs:spring-restdocs-asciidoctor'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package cmc.mellyserver.auth.certificate;

public abstract class CertificateConstants {

public static final String TITLE_CERTIFICATION = "Melly 인증번호 안내";

public static final String PREFIX_CERTIFICATION = "email certification:";

public static final int LIMIT_TIME_CERTIFICATION_NUMBER = 60 * 3;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmc.mellyserver.common.event;
package cmc.mellyserver.auth.certificate;

public record CertificationCompletedEvent(String email, String content) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package cmc.mellyserver.auth.certificate;

import static cmc.mellyserver.mail.EmailConstants.*;
import static cmc.mellyserver.auth.certificate.CertificateConstants.*;

import java.time.Duration;

Expand All @@ -15,9 +15,7 @@ class CertificationNumberRepository {

private final StringRedisTemplate redisTemplate;

/*
인증번호 유효기간 : 3분
*/
// 인증번호 유효기간 : 3분
public void save(String email, String certificationNumber) {

redisTemplate.opsForValue()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package cmc.mellyserver.auth.certificate;

import cmc.mellyserver.auth.dto.request.EmailCertificationRequest;
import cmc.mellyserver.auth.service.dto.request.EmailCertificationRequest;

public interface CertificationService {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Repository;

import cmc.mellyserver.auth.dto.request.EmailCertificationRequest;
import cmc.mellyserver.common.event.CertificationCompletedEvent;
import cmc.mellyserver.auth.service.dto.request.EmailCertificationRequest;
import lombok.RequiredArgsConstructor;

@Profile({"local", "prod"})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package cmc.mellyserver.auth.common.constant;

public abstract class AuthConstants {

public static final String SIGNUP_CELEBRATION_MAIL = "회원가입 축하드립니다!";
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import org.springframework.util.StringUtils;
import org.springframework.web.filter.OncePerRequestFilter;

import cmc.mellyserver.auth.common.util.HeaderUtil;
import cmc.mellyserver.auth.token.TokenProvider;
import cmc.mellyserver.common.util.HeaderUtil;
import cmc.mellyserver.support.exception.LogoutOrWithdrawException;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.method.support.ModelAndViewContainer;

import cmc.mellyserver.auth.common.util.HeaderUtil;
import cmc.mellyserver.auth.token.TokenProvider;
import cmc.mellyserver.common.util.HeaderUtil;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmc.mellyserver.common.util;
package cmc.mellyserver.auth.common.util;

import java.util.Objects;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@
import cmc.mellyserver.auth.certificate.CertificationService;
import cmc.mellyserver.auth.common.resolver.CurrentUser;
import cmc.mellyserver.auth.common.resolver.LoginUser;
import cmc.mellyserver.auth.common.util.HeaderUtil;
import cmc.mellyserver.auth.controller.dto.request.AuthLoginRequest;
import cmc.mellyserver.auth.controller.dto.request.ChangePasswordRequest;
import cmc.mellyserver.auth.controller.dto.request.OAuthLoginRequest;
import cmc.mellyserver.auth.controller.dto.request.OAuthSignupRequest;
import cmc.mellyserver.auth.controller.dto.request.ReIssueAccessTokenRequest;
import cmc.mellyserver.auth.controller.dto.request.SignupRequest;
import cmc.mellyserver.auth.dto.request.EmailCertificationRequest;
import cmc.mellyserver.auth.dto.response.OAuthResponseDto;
import cmc.mellyserver.auth.dto.response.TokenResponseDto;
import cmc.mellyserver.auth.service.AuthService;
import cmc.mellyserver.auth.service.OAuthService;
import cmc.mellyserver.common.util.HeaderUtil;
import cmc.mellyserver.auth.service.dto.request.EmailCertificationRequest;
import cmc.mellyserver.auth.service.dto.response.OAuthResponseDto;
import cmc.mellyserver.auth.service.dto.response.TokenResponseDto;
import cmc.mellyserver.support.response.ApiResponse;
import cmc.mellyserver.support.response.SuccessCode;
import jakarta.servlet.http.HttpServletRequest;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package cmc.mellyserver.auth.controller.dto.request;

import cmc.mellyserver.auth.dto.request.AuthLoginRequestDto;
import cmc.mellyserver.auth.service.dto.request.AuthLoginRequestDto;
import jakarta.validation.constraints.Email;

public record AuthLoginRequest(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package cmc.mellyserver.auth.controller.dto.request;

import cmc.mellyserver.auth.dto.request.OAuthLoginRequestDto;
import cmc.mellyserver.auth.service.dto.request.OAuthLoginRequestDto;
import cmc.mellyserver.dbcore.user.enums.Provider;
import lombok.Builder;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.hibernate.validator.constraints.Length;

import cmc.mellyserver.auth.dto.request.OAuthSignupRequestDto;
import cmc.mellyserver.auth.service.dto.request.OAuthSignupRequestDto;
import cmc.mellyserver.dbcore.user.enums.AgeGroup;
import cmc.mellyserver.dbcore.user.enums.Gender;
import cmc.mellyserver.dbcore.user.enums.Provider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.hibernate.validator.constraints.Length;

import cmc.mellyserver.auth.dto.request.AuthSignupRequestDto;
import cmc.mellyserver.auth.service.dto.request.AuthSignupRequestDto;
import cmc.mellyserver.dbcore.user.enums.AgeGroup;
import cmc.mellyserver.dbcore.user.enums.Gender;
import jakarta.validation.constraints.Email;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import org.springframework.transaction.annotation.Transactional;

import cmc.mellyserver.auth.controller.dto.request.ChangePasswordRequest;
import cmc.mellyserver.auth.dto.request.AuthLoginRequestDto;
import cmc.mellyserver.auth.dto.request.AuthSignupRequestDto;
import cmc.mellyserver.auth.dto.response.TokenResponseDto;
import cmc.mellyserver.auth.service.dto.request.AuthLoginRequestDto;
import cmc.mellyserver.auth.service.dto.request.AuthSignupRequestDto;
import cmc.mellyserver.auth.service.dto.response.TokenResponseDto;
import cmc.mellyserver.auth.token.RefreshToken;
import cmc.mellyserver.auth.token.TokenDto;
import cmc.mellyserver.auth.token.TokenService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cmc.mellyserver.auth.dto.request.OAuthLoginRequestDto;
import cmc.mellyserver.auth.dto.request.OAuthSignupRequestDto;
import cmc.mellyserver.auth.dto.response.OAuthResponseDto;
import cmc.mellyserver.auth.dto.response.TokenResponseDto;
import cmc.mellyserver.auth.service.dto.request.OAuthLoginRequestDto;
import cmc.mellyserver.auth.service.dto.request.OAuthSignupRequestDto;
import cmc.mellyserver.auth.service.dto.response.OAuthResponseDto;
import cmc.mellyserver.auth.service.dto.response.TokenResponseDto;
import cmc.mellyserver.auth.token.TokenDto;
import cmc.mellyserver.auth.token.TokenService;
import cmc.mellyserver.clientauth.LoginClient;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmc.mellyserver.auth.dto.request;
package cmc.mellyserver.auth.service.dto.request;

import lombok.Builder;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmc.mellyserver.auth.dto.request;
package cmc.mellyserver.auth.service.dto.request;

import org.hibernate.validator.constraints.Length;

Expand Down Expand Up @@ -35,7 +35,7 @@ public record AuthSignupRequestDto(
public User toEntity() {
return User.builder()
.email(email)
.password("passowrd")
.password(password)
.nickname(nickname)
.ageGroup(ageGroup)
.gender(gender)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmc.mellyserver.auth.dto.request;
package cmc.mellyserver.auth.service.dto.request;

public record EmailCertificationRequest(String email, String certificationNumber) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmc.mellyserver.auth.dto.request;
package cmc.mellyserver.auth.service.dto.request;

import cmc.mellyserver.dbcore.user.enums.Provider;
import lombok.Builder;
Expand Down
Loading

0 comments on commit 151cb83

Please sign in to comment.