diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 06a4cee3..78749faf 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -1,5 +1,4 @@ -# github repository Actions 페이지에 나타낼 이름 -name: NumberOne-Backend-CICD +name: NumberOne-Backend-CICD (fade-out) # event trigger on: diff --git a/.github/workflows/jib-build-depoly.yml b/.github/workflows/jib-build-depoly.yml index 52c7ec50..73c05cc1 100644 --- a/.github/workflows/jib-build-depoly.yml +++ b/.github/workflows/jib-build-depoly.yml @@ -83,6 +83,7 @@ jobs: - name: 🐧 create service-account.json run: | + mkdir -p ./daepiro-api/src/main/resources cd ./daepiro-api/src/main/resources touch ./service-account.json echo "${{ secrets.FCM }}" | base64 --decode > ./service-account.json diff --git a/.gitignore b/.gitignore index 921e0692..0a8f8649 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,7 @@ out/ **/src/main/resources/service-account.json +*.yml application.yml application.properties diff --git a/build.gradle b/build.gradle index 3b562a99..ad52465e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,82 +1,65 @@ plugins { - id 'java' - id 'org.springframework.boot' version '3.1.4' - id 'io.spring.dependency-management' version '1.1.3' - id 'com.google.cloud.tools.jib' version '3.4.0' + id 'java' + id 'org.springframework.boot' version '3.1.4' + id 'io.spring.dependency-management' version '1.1.3' + id 'com.google.cloud.tools.jib' version '3.4.0' } group = 'com.numberone.backend' -version = '0.0.1-SNAPSHOT' +version = '0.0.2-SNAPSHOT' allprojects { - apply plugin: 'java' - sourceCompatibility = JavaVersion.VERSION_17 + apply plugin: 'java' + sourceCompatibility = JavaVersion.VERSION_17 - repositories { - mavenCentral() - maven{url 'https://jitpack.io'} - } + repositories { + mavenCentral() + maven { url 'https://jitpack.io' } + } } ext { - set('springCloudVersion', "2021.0.1") - queryDslVersion = "4.3.0" + set('springCloudVersion', "2021.0.1") } - subprojects { - apply plugin: 'java' - apply plugin: 'io.spring.dependency-management' - apply plugin: 'java-library' - apply plugin: 'org.springframework.boot' - apply plugin: 'jacoco' - - configurations { - developmentOnly - runtimeClasspath { - extendsFrom developmentOnly - } - - compileOnly { - extendsFrom annotationProcessor - } - - all { - exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat' - } - } - - repositories { - mavenCentral() - } - - dependencyManagement { - imports { - mavenBom("org.springframework.boot:spring-boot-dependencies:3.1.4") - mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" - } - } - - dependencies { - compileOnly 'org.projectlombok:lombok' - annotationProcessor 'org.projectlombok:lombok' - annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' - - implementation 'org.springframework.boot:spring-boot-starter-undertow' - - implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.10.3' - implementation 'com.google.code.gson:gson:2.10.1' - - testImplementation('org.springframework.boot:spring-boot-starter-test') { - exclude module: 'junit' - } - testImplementation(platform('org.junit:junit-bom:5.9.3')) - testImplementation('org.junit.jupiter:junit-jupiter') - } - - - tasks.named('test') { - useJUnitPlatform() - } + apply plugin: 'io.spring.dependency-management' + apply plugin: 'java-library' + apply plugin: 'org.springframework.boot' + apply plugin: 'jacoco' + + configurations { + compileOnly { + extendsFrom annotationProcessor + } + } + + repositories { + mavenCentral() + } + + dependencyManagement { + imports { + mavenBom("org.springframework.boot:spring-boot-dependencies:3.1.4") + mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" + } + } + + dependencies { + // lombok + compileOnly 'org.projectlombok:lombok' + annotationProcessor 'org.projectlombok:lombok' + annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor' + + // spring + implementation 'org.springframework.boot:spring-boot-starter-web' + implementation 'org.springframework.boot:spring-boot-starter-validation' + implementation 'org.springframework.boot:spring-boot-starter-security' + implementation 'org.springframework.boot:spring-boot-starter-aop' + + // swagger + implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2' + + } } \ No newline at end of file diff --git a/daepiro-api/build.gradle b/daepiro-api/build.gradle index c6dd7b51..a65fb63b 100644 --- a/daepiro-api/build.gradle +++ b/daepiro-api/build.gradle @@ -2,32 +2,12 @@ dependencies { implementation project(':daepiro-core') implementation project(':daepiro-common') implementation project(':daepiro-redis') +} - // spring - implementation 'org.springframework.boot:spring-boot-starter-security' - implementation 'org.springframework.boot:spring-boot-starter-web' - implementation 'org.springframework.boot:spring-boot-starter-validation' - - // swagger - implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2' - - // jpa - api 'org.springframework.boot:spring-boot-starter-data-jpa' - - // lombok - annotationProcessor 'org.projectlombok:lombok' - compileOnly 'org.projectlombok:lombok' - - // test - testImplementation 'org.springframework.boot:spring-boot-starter-test' - - // aop - implementation 'org.springframework.boot:spring-boot-starter-aop' - - // fcm - implementation 'com.google.firebase:firebase-admin:9.1.1' +bootJar { + enabled = false } -tasks.named('test') { - useJUnitPlatform() +jar { + enabled = true } \ No newline at end of file diff --git a/daepiro-api/src/main/java/com/numberone/backend/domain/member/service/MemberService.java b/daepiro-api/src/main/java/com/numberone/backend/domain/member/service/MemberService.java index 658fd7f1..1fa37dba 100644 --- a/daepiro-api/src/main/java/com/numberone/backend/domain/member/service/MemberService.java +++ b/daepiro-api/src/main/java/com/numberone/backend/domain/member/service/MemberService.java @@ -38,11 +38,6 @@ public Member findByEmail(String email) { .orElseThrow(NotFoundMemberException::new); } - @Transactional - public void create(String email) { - memberRepository.save(Member.of(email)); - } - @Transactional public void initMemberData(String email, OnboardingRequest onboardingRequest) { Member member = memberRepository.findByEmail(email) diff --git a/daepiro-api/src/main/resources/logback-spring.xml b/daepiro-api/src/main/resources/logback-spring.xml deleted file mode 100644 index c29764b0..00000000 --- a/daepiro-api/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - ${LOG_PATTERN} - - - - - - - - - \ No newline at end of file diff --git a/daepiro-app/build.gradle b/daepiro-app/build.gradle index 4288ad08..d2cb9145 100644 --- a/daepiro-app/build.gradle +++ b/daepiro-app/build.gradle @@ -9,43 +9,45 @@ dependencies { implementation project(':daepiro-api') implementation project(':daepiro-crawler') implementation project(':daepiro-auth') - - // spring - implementation 'org.springframework.boot:spring-boot-starter-web' - implementation 'org.springframework.boot:spring-boot-starter-security' - - // swagger - implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2' - - // lombok - annotationProcessor 'org.projectlombok:lombok' - compileOnly 'org.projectlombok:lombok' - -} - -tasks.named('test') { - useJUnitPlatform() } +// system environment variables def serverIP = System.getenv("EC2_PUBLIC_IP") def jmxPort = System.getenv("JMX_PORT") +def dockerUserName = System.getenv("DOCKER_USERNAME") +def dockerImageName = System.getenv("DOCKER_IMAGE") +// jib jib { from { image = "openjdk:17" } to { - image = "versatile0010/numberone" + image = String.format("%s/%s", dockerUserName, dockerImageName) tags = ["latest"] } container { mainClass = 'com.numberone.backend.BackendApplication' creationTime = "USE_CURRENT_TIMESTAMP" - jvmFlags = ["-Duser.timezone=Asia/Seoul", "-Xms128m", "-Xmx128m", "-Dcom.sun.management.jmxremote=true", "-Dcom.sun.management.jmxremote.local.only=false", "-Dcom.sun.management.jmxremote.port="+jmxPort.toString(), "-Dcom.sun.management.jmxremote.ssl=false", "-Dcom.sun.management.jmxremote.authenticate=false", "-Djava.rmi.server.hostname=" + serverIP.toString(), "-Dcom.sun.management.jmxremote.rmi.port="+jmxPort.toString(), "-XX:+HeapDumpOnOutOfMemoryError", "-XX:HeapDumpPath=/heap-dumps/heapdump.hprof"] + jvmFlags = [ + "-Duser.timezone=Asia/Seoul", + "-Xms128m", "-Xmx128m", + "-Dcom.sun.management.jmxremote=true", + "-Dcom.sun.management.jmxremote.local.only=false", + "-Dcom.sun.management.jmxremote.port=" + jmxPort.toString(), + "-Dcom.sun.management.jmxremote.ssl=false", + "-Dcom.sun.management.jmxremote.authenticate=false", + "-Djava.rmi.server.hostname=" + serverIP.toString(), + "-Dcom.sun.management.jmxremote.rmi.port=" + jmxPort.toString(), + "-XX:+HeapDumpOnOutOfMemoryError", + "-XX:HeapDumpPath=/heap-dumps/heapdump.hprof"] ports = ['8080'] } } -tasks.bootJar { +bootJar { + enabled = true // entry module +} +jar { enabled = true } \ No newline at end of file diff --git a/daepiro-app/src/main/java/com/numberone/backend/LoginTestController.java b/daepiro-app/src/main/java/com/numberone/backend/LoginTestController.java deleted file mode 100644 index 0be586f9..00000000 --- a/daepiro-app/src/main/java/com/numberone/backend/LoginTestController.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.numberone.backend; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.security.core.Authentication; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@Tag(name = "login_test", description = "토큰 인증 테스트 관련 API") -@RestController -public class LoginTestController { - @Operation(summary = "토큰 인증 테스트하기", description = - """ - 서버에서 발급받은 액세스 토큰을 "Bearer [발급받은 액세스토큰]" 형태로 http 헤더의 Authorization에 넣어서 요청해주세요. - - 유효한 토큰이라면 사용자의 이메일을 반환합니다. - - 앞으로 서버에 api 요청을 날릴때 이렇게 Authorization 헤더에 발급받은 액세스 토큰을 담아 전달해주세요. - """) - @GetMapping("/api/logintest") - public LoginTestResponse test(Authentication authentication) { - return LoginTestResponse.of(authentication.getName()); - } -} diff --git a/daepiro-app/src/main/java/com/numberone/backend/LoginTestResponse.java b/daepiro-app/src/main/java/com/numberone/backend/LoginTestResponse.java deleted file mode 100644 index 37e8f98f..00000000 --- a/daepiro-app/src/main/java/com/numberone/backend/LoginTestResponse.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.numberone.backend; - -import lombok.AccessLevel; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Getter -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class LoginTestResponse { - private String email; - - @Builder - private LoginTestResponse(String email) { - this.email = email; - } - - public static LoginTestResponse of(String email) { - return LoginTestResponse.builder() - .email(email) - .build(); - } -} diff --git a/daepiro-auth/build.gradle b/daepiro-auth/build.gradle index ac024334..569d8f09 100644 --- a/daepiro-auth/build.gradle +++ b/daepiro-auth/build.gradle @@ -2,31 +2,21 @@ dependencies { implementation project(':daepiro-core') implementation project(':daepiro-redis') implementation project(':daepiro-common') - implementation project(':daepiro-api') // todo: remove it - - // spring - implementation 'org.springframework.boot:spring-boot-starter-web' - implementation 'org.springframework.boot:spring-boot-starter-validation' - - // lombok - compileOnly 'org.projectlombok:lombok' - - // swagger - implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2' // oauth implementation 'org.springframework.boot:spring-boot-starter-oauth2-client' implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server' - // security - implementation 'org.springframework.boot:spring-boot-starter-security' - + // jwt implementation 'io.jsonwebtoken:jjwt-api:0.11.5' runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5' runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5' } -tasks.bootJar { +bootJar { enabled = false } +jar { + enabled = true +} \ No newline at end of file diff --git a/daepiro-auth/src/main/java/com/numberone/backend/domain/service/TokenService.java b/daepiro-auth/src/main/java/com/numberone/backend/domain/service/TokenService.java index 9a8c89ad..097086d1 100644 --- a/daepiro-auth/src/main/java/com/numberone/backend/domain/service/TokenService.java +++ b/daepiro-auth/src/main/java/com/numberone/backend/domain/service/TokenService.java @@ -1,7 +1,7 @@ package com.numberone.backend.domain.service; +import com.numberone.backend.domain.member.entity.Member; import com.numberone.backend.domain.member.repository.MemberRepository; -import com.numberone.backend.domain.member.service.MemberService; import com.numberone.backend.domain.properties.KakaoProperties; import com.numberone.backend.domain.properties.NaverProperties; import com.numberone.backend.domain.properties.TokenPeriodProperties; @@ -28,14 +28,18 @@ @Transactional(readOnly = true) @Slf4j public class TokenService { + private final JwtProvider jwtProvider; + private final RestTemplate restTemplate; + private final KakaoProperties kakaoProperties; private final NaverProperties naverProperties; - private final MemberService memberService; + private final TokenPeriodProperties tokenPeriodProperties; + + private final MemberRepository repository; private final TokenRepository tokenRepository; private final MemberRepository memberRepository; - private final TokenPeriodProperties tokenPeriodProperties; @Transactional public GetTokenResponse loginKakao(GetTokenRequest tokenRequest) { @@ -90,7 +94,7 @@ public RefreshTokenResponse refresh(RefreshTokenRequest tokenRequest) { private GetTokenResponse getTokenResponse(String email) { Boolean isNewMember = false; if (!memberRepository.existsByEmail(email)) { - memberService.create(email); + memberRepository.save(Member.of(email)); isNewMember = true; } if (tokenRepository.existsById(email)) { diff --git a/daepiro-common/build.gradle b/daepiro-common/build.gradle index 85f609fd..e4376396 100644 --- a/daepiro-common/build.gradle +++ b/daepiro-common/build.gradle @@ -1,23 +1,7 @@ -plugins { - id 'java' - id "java-library" - id "java-test-fixtures" -} - dependencies { - // spring - implementation 'org.springframework.boot:spring-boot-starter-security' - implementation 'org.springframework.boot:spring-boot-starter-web' - implementation 'org.springframework.boot:spring-boot-starter-validation' - - // swagger - implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2' implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE' - // aop - implementation 'org.springframework.boot:spring-boot-starter-aop' - // fcm implementation 'com.google.firebase:firebase-admin:9.1.1' @@ -25,7 +9,9 @@ dependencies { implementation 'com.google.code.geocoder-java:geocoder-java:0.16' } -tasks.bootJar { +bootJar { enabled = false } - +jar { + enabled = true +} diff --git a/daepiro-core/build.gradle b/daepiro-core/build.gradle index 7fb37abf..7225e31f 100644 --- a/daepiro-core/build.gradle +++ b/daepiro-core/build.gradle @@ -1,52 +1,15 @@ -buildscript { - ext { - queryDslVersion = "5.0.0" - } -} - -plugins { - id 'java' - id "java-library" - id "java-test-fixtures" - id "maven-publish" -} - -configurations { - compileOnly { - extendsFrom annotationProcessor - } -} - repositories { mavenCentral() } -bootJar { - enabled = false -} - -jar { - enabled = true -} - dependencies { implementation project(':daepiro-common') - // swagger - implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2' - // p6spy implementation 'com.github.gavlyukovskiy:p6spy-spring-boot-starter:1.5.8' - // validation - implementation 'org.springframework.boot:spring-boot-starter-validation' - // jpa - implementation 'org.springframework.boot:spring-boot-starter-data-jpa' - - // lombok - compileOnly 'org.projectlombok:lombok' - annotationProcessor 'org.projectlombok:lombok' + api 'org.springframework.boot:spring-boot-starter-data-jpa' // mysql connector runtimeOnly 'com.mysql:mysql-connector-j' @@ -59,10 +22,6 @@ dependencies { // === QueryDsl === } -tasks.named('test') { - useJUnitPlatform() -} - // === Querydsl 빌드 옵션 === def querydslDir = "$buildDir/generated/querydsl" @@ -76,4 +35,12 @@ tasks.withType(JavaCompile) { clean.doLast { file(querydslDir).deleteDir() +} +// === Querydsl 빌드 옵션 === + +bootJar { + enabled = false +} +jar { + enabled = true } \ No newline at end of file diff --git a/daepiro-crawler/build.gradle b/daepiro-crawler/build.gradle index 72bcdb0d..e7acfb2b 100644 --- a/daepiro-crawler/build.gradle +++ b/daepiro-crawler/build.gradle @@ -1,27 +1,16 @@ -plugins { - id 'java' - id "java-library" - id "java-test-fixtures" -} - dependencies { implementation project(':daepiro-common') implementation project(':daepiro-core') - implementation 'org.springframework.boot:spring-boot-starter-security' - implementation 'org.springframework.boot:spring-boot-starter-web' - implementation 'org.springframework.boot:spring-boot-starter-validation' - - // jpa - api 'org.springframework.boot:spring-boot-starter-data-jpa' - //crawling implementation 'com.squareup.okhttp3:okhttp:4.9.1' implementation 'org.jsoup:jsoup:1.14.2' implementation 'net.sourceforge.htmlunit:htmlunit:2.70.0' } -tasks.bootJar { +bootJar { enabled = false } - +jar { + enabled = true +} diff --git a/daepiro-redis/build.gradle b/daepiro-redis/build.gradle index 7d95f7a4..e9922f7d 100644 --- a/daepiro-redis/build.gradle +++ b/daepiro-redis/build.gradle @@ -1,19 +1,13 @@ -plugins { - id 'java' - id "java-library" - id "java-test-fixtures" -} - dependencies { implementation project(':daepiro-common') // redis - implementation 'org.springframework.boot:spring-boot-starter-data-redis' - - // test - testFixturesRuntimeOnly group: 'it.ozimov', name: 'embedded-redis', version: '0.7.1' + api 'org.springframework.boot:spring-boot-starter-data-redis' } -tasks.bootJar { +bootJar { enabled = false } +jar { + enabled = true +} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 687276ac..00000000 --- a/docker-compose.yml +++ /dev/null @@ -1,26 +0,0 @@ -version: '3' -services: - trothcam: - image: versatile0010/numberone:latest - container_name: numberone - restart: always - ports: - - 8080:8080 - logging: - driver: awslogs - options: - awslogs-group: "numberone-dev" - awslogs-region: "ap-northeast-2" - awslogs-stream: "dev-spring" - - redis: - hostname: redis - image: redis:latest - ports: - - 6379:6379 - logging: - driver: awslogs - options: - awslogs-group: "numberone-dev" - awslogs-region: "ap-northeast-2" - awslogs-stream: "dev-redis" \ No newline at end of file