Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: 모놀리틱 구조에서 멀티 모듈 구조로 전환 #116

Merged
merged 31 commits into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
3bcee48
Feat: multi-module
versatile0010 Jan 8, 2024
4d393ea
Feat: deploy test
versatile0010 Jan 8, 2024
4b19f0d
Feat: fix shell
versatile0010 Jan 8, 2024
9008e6d
Feat: set main class for jib
versatile0010 Jan 8, 2024
9515dad
Feat: management dependency and plugins
versatile0010 Jan 9, 2024
c1ae34a
Feat: fix shell
versatile0010 Jan 9, 2024
e7f10ec
Feat: crawler, redis, auth module
versatile0010 Jan 9, 2024
cab6774
Feat: auth module
versatile0010 Jan 9, 2024
befe8cd
Feat: auth module
versatile0010 Jan 9, 2024
074a37c
Feat: removed locationProvider to daepiro-common
versatile0010 Jan 9, 2024
eae4d1c
Feat: jmx setup
versatile0010 Jan 14, 2024
a6e3341
Feat: change jdk base image to openjdk
versatile0010 Jan 14, 2024
9572aba
Feat: heap dump set up
versatile0010 Jan 14, 2024
a59c8a8
Feat: heap dump set up
versatile0010 Jan 14, 2024
43b808a
Feat: heap dump dir fix
versatile0010 Jan 14, 2024
4d2ab31
Feat: custom slack noti
versatile0010 Feb 3, 2024
d7726c0
Revert "Feat: custom slack noti"
versatile0010 Feb 3, 2024
e6ad641
Feat: custom slack noti
versatile0010 Feb 3, 2024
3826d7e
Feat: custom slack noti
versatile0010 Feb 3, 2024
5f4507d
Revert "Feat: custom slack noti"
versatile0010 Feb 3, 2024
695ee79
Revert "Feat: custom slack noti"
versatile0010 Feb 3, 2024
95e968b
Feat: custom slack noti
versatile0010 Feb 3, 2024
c0f7daf
Feat: custom slack noti
versatile0010 Feb 3, 2024
d48ef04
Feat: custom slack noti
versatile0010 Feb 3, 2024
ed53979
Feat: custom slack noti
versatile0010 Feb 3, 2024
a91371c
Feat: custom slack noti
versatile0010 Feb 3, 2024
86dc067
Feat: set up bootJar disabled, jar enabled at core module
versatile0010 Feb 3, 2024
a60edad
Feat: exclude deploy target branch
versatile0010 Feb 3, 2024
f51c13a
Feat: module architecture renewed
versatile0010 Feb 18, 2024
772829a
Feat: fixed time zone
versatile0010 Feb 18, 2024
48c07c6
Feat: gradle dependency clean up
versatile0010 Feb 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 42 additions & 6 deletions .github/workflows/jib-build-depoly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: NumberOne-Backend-JIB-BUILD-DEPLOY
# event trigger
on:
push:
branches: [ "main", "dev", "dev-check" ]
branches: [ "dev", "dev-check" ]

permissions: write-all

Expand Down Expand Up @@ -33,6 +33,39 @@ jobs:
- name: 🐧 Grant execute permission for gradlew
run: chmod +x gradlew


- name: get Current Time
run: echo "CURRENT_TIME=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV

- name: 🔔 Send Slack Message when deploy started
uses: 8398a7/action-slack@v3
with:
status: custom
custom_payload: |
{
"attachments": [
{
"title": "대피로 백엔드 배포를 시작합니다. 👻",
"pretext": "Daepiro backend is deploying...",
"fields": [
{
"title": "Author 💻",
"value": "${{ github.actor }}",
"short": true
},
{
"title": "Deploy time 🕚",
"value": "${{ env.CURRENT_TIME }}",
"short": true
}
]
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: always()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

- name: 🔑 Login to Docker Hub
uses: docker/[email protected]
with:
Expand All @@ -41,27 +74,30 @@ jobs:

- name: 🐧 create application.yml
run: |
mkdir -p ./src/main/resources
cd ./src/main/resources
mkdir -p ./daepiro-api/src/main/resources
cd ./daepiro-api/src/main/resources
touch ./application.yml
echo "${{ secrets.PROPERTIES_PROD }}" | base64 --decode > ./application.yml
ls -la
shell: bash

- name: 🐧 create service-account.json
run: |
cd ./src/main/resources
cd ./daepiro-api/src/main/resources
touch ./service-account.json
echo "${{ secrets.FCM }}" | base64 --decode > ./service-account.json
ls -la
shell: bash

- name: Build with jib
run: |
./gradlew jib -x test \
./gradlew :daepiro-api:jib -x test \
-Djib.to.auth.username=${{ secrets.DOCKER_USERNAME }} \
-Djib.to.auth.password=${{ secrets.DOCKER_PASSWORD }} \
-Djib.to.image="${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_IMAGE }}:latest"
env:
EC2_PUBLIC_IP: ${{ secrets.EC2_PUBLIC_IP }}
JMX_PORT: ${{ secrets.JMX_PORT }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

main 메서드가 api모듈에 있기 때문에 api모듈 경로에서 빌드를 해주는거군요!


- name: Get current time
uses: 1466587594/get-current-time@v2
Expand Down Expand Up @@ -94,7 +130,7 @@ jobs:
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo, message, commit, author, action, eventName, ref, workflow, pullRequest
fields: repo, message, commit, author, workflow
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: always()
5 changes: 0 additions & 5 deletions Dockerfile

This file was deleted.

145 changes: 54 additions & 91 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,116 +5,79 @@ plugins {
id 'com.google.cloud.tools.jib' version '3.4.0'
}

group = 'com.numberone'
group = 'com.numberone.backend'
version = '0.0.1-SNAPSHOT'

jib {
from {
image = "openjdk:17-alpine"
}
to {
image = "versatile0010/numberone"
credHelper = 'ecr-login'
tags = ["latest"]
}
container {
jvmFlags = ["-Duser.timezone=Asia/Seoul", "-Xms128m", "-Xmx128m"]
}
}


allprojects {
apply plugin: 'java'
sourceCompatibility = JavaVersion.VERSION_17

java {
sourceCompatibility = '17'
}

configurations {
compileOnly {
extendsFrom annotationProcessor
repositories {
mavenCentral()
maven{url 'https://jitpack.io'}
}
}

repositories {
mavenCentral()
ext {
set('springCloudVersion', "2021.0.1")
queryDslVersion = "4.3.0"
}

dependencies {
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
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'

// queryDSL
implementation "com.querydsl:querydsl-jpa:5.0.0:jakarta"
implementation 'com.github.gavlyukovskiy:p6spy-spring-boot-starter:1.5.8'

annotationProcessor "com.querydsl:querydsl-apt:5.0.0:jakarta"
annotationProcessor "jakarta.annotation:jakarta.annotation-api"
annotationProcessor "jakarta.persistence:jakarta.persistence-api"

annotationProcessor "com.querydsl:querydsl-apt:${dependencyManagement.importedProperties['querydsl.version']}:jpa"
annotationProcessor "jakarta.annotation:jakarta.annotation-api"
annotationProcessor "jakarta.persistence:jakarta.persistence-api"
annotationProcessor 'org.projectlombok:lombok'
subprojects {
apply plugin: 'java'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'java-library'
apply plugin: 'org.springframework.boot'
apply plugin: 'jacoco'

compileOnly 'org.projectlombok:lombok'
configurations {
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}

runtimeOnly 'com.h2database:h2'
runtimeOnly 'com.mysql:mysql-connector-j'
compileOnly {
extendsFrom annotationProcessor
}

all {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
}
}

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'

implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'

implementation 'io.jsonwebtoken:jjwt:0.9.1'
implementation 'com.sun.xml.bind:jaxb-impl:4.0.1'
implementation 'com.sun.xml.bind:jaxb-core:4.0.1'
implementation 'javax.xml.bind:jaxb-api:2.4.0-b180830.0359'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server'

// cloud
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'
repositories {
mavenCentral()
}

// aop
implementation 'org.springframework.boot:spring-boot-starter-aop'
dependencyManagement {
imports {
mavenBom("org.springframework.boot:spring-boot-dependencies:3.1.4")
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}

//crawling
implementation 'com.squareup.okhttp3:okhttp:4.9.1'
implementation 'org.jsoup:jsoup:1.14.2'
implementation 'net.sourceforge.htmlunit:htmlunit:2.70.0'
dependencies {
//implementation 'org.projectlombok:lombok'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'

//geocoding
implementation 'com.google.code.geocoder-java:geocoder-java:0.16'
// fcm
implementation 'com.google.firebase:firebase-admin:9.1.1'
}
implementation 'org.springframework.boot:spring-boot-starter-undertow'

tasks.named('test') {
useJUnitPlatform()
}
implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.10.3'
implementation 'com.google.code.gson:gson:2.10.1'

// Querydsl 설정부
def generated = 'src/main/generated'
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')
}

// querydsl QClass 파일 생성 위치를 지정
tasks.withType(JavaCompile) {
options.getGeneratedSourceOutputDirectory().set(file(generated))
}

// java source set 에 querydsl QClass 위치 추가
sourceSets {
main.java.srcDirs += [ generated ]
}
tasks.named('test') {
useJUnitPlatform()
}

// gradle clean 시에 QClass 디렉토리 삭제
clean {
delete file(generated)
}
78 changes: 78 additions & 0 deletions daepiro-api/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
plugins {
id 'com.google.cloud.tools.jib' version '3.4.0'
}

dependencies {
implementation project(':daepiro-core')
implementation project(':daepiro-common')
implementation project(':daepiro-redis')

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
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'

annotationProcessor 'org.projectlombok:lombok'

compileOnly 'org.projectlombok:lombok'

runtimeOnly 'com.h2database:h2'
runtimeOnly 'com.mysql:mysql-connector-j'

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'

implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'

implementation 'io.jsonwebtoken:jjwt:0.9.1'
implementation 'com.sun.xml.bind:jaxb-impl:4.0.1'
implementation 'com.sun.xml.bind:jaxb-core:4.0.1'
implementation 'javax.xml.bind:jaxb-api:2.4.0-b180830.0359'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server'

// cloud
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'

implementation 'com.squareup.okhttp3:okhttp:4.9.1'
implementation 'org.jsoup:jsoup:1.14.2'
implementation 'net.sourceforge.htmlunit:htmlunit:2.70.0'
}

tasks.named('test') {
useJUnitPlatform()
}

def serverIP = System.getenv("EC2_PUBLIC_IP")
def jmxPort = System.getenv("JMX_PORT")

jib {
from {
image = "openjdk:17"
}
to {
image = "versatile0010/numberone"
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"]
ports = ['8080']
}
}

tasks.bootJar {
enabled = true
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;

@SpringBootApplication
@ServletComponentScan
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ServletComponentScan 어노테이션이 어디에 쓰이는건가용? 구글링해봤는데 저희 프로젝트에서는 쓰이는 곳을 잘 못찾겠네요!

public class BackendApplication {
public static void main(String[] args) {
SpringApplication.run(BackendApplication.class, args);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.numberone.backend.config;
package com.numberone.backend.auth.config;

import com.numberone.backend.config.auth.JwtFilter;
import com.numberone.backend.auth.global.JwtFilter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
Expand Down
Loading