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 all 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", "feat/multi-module" ]

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' -d '+9 hours')" >> $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 (KST) 🕚",
"value": "${{ env.CURRENT_TIME }}",
"short": true
}
]
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: always()

- 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-app/src/main/resources
cd ./daepiro-app/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-app: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 }}

- 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.

144 changes: 53 additions & 91 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,116 +5,78 @@ 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 {
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)
}
33 changes: 33 additions & 0 deletions daepiro-api/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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'
}

tasks.named('test') {
useJUnitPlatform()
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package com.numberone.backend.domain.admin.controller;

import com.numberone.backend.domain.admin.dto.request.CreateDisasterEventDto;
import com.numberone.backend.domain.admin.dto.SaveAdminDisasterRequest;
import com.numberone.backend.domain.admin.dto.response.GetAddressResponse;
import com.numberone.backend.domain.admin.service.AdminService;
import com.numberone.backend.domain.disaster.dto.request.SaveDisasterRequest;
import com.numberone.backend.domain.disaster.event.DisasterEvent;
import com.numberone.backend.domain.disaster.service.DisasterService;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

Expand All @@ -25,16 +22,16 @@ public class AdminController {

@Operation(summary = "서버에 지역별 대피소 정보 Json 파일로 업로드하기", description =
"""

🔥 (주의) Shelter Database 정보를 json 형태로 서버 스토리지에 저장하는 기능으로, 10 분 이상 소요됩니다.

요청 시, 현재 저장된 대피소 db 를 기반으로

지역 별 대피소 정보를 Json 형태로 정리하여 서버 스토리지에 저장합니다.

대피소 db 를 업데이트 한 경우에, 실행하는 api 입니다.

""")
🔥 (주의) Shelter Database 정보를 json 형태로 서버 스토리지에 저장하는 기능으로, 10 분 이상 소요됩니다.
요청 시, 현재 저장된 대피소 db 를 기반으로
지역 별 대피소 정보를 Json 형태로 정리하여 서버 스토리지에 저장합니다.
대피소 db 를 업데이트 한 경우에, 실행하는 api 입니다.
""")
@PostMapping("/shelter-init")
public ResponseEntity<String> uploadAllShelterInfo() {
return ResponseEntity.created(URI.create("/api/admin/shelter-init"))
Expand All @@ -43,12 +40,12 @@ public ResponseEntity<String> uploadAllShelterInfo() {

@Operation(summary = "서버에 대피소 주소 정보 Json 파일로 업로드하기", description =
"""

🔥 (주의) Shelter Database 정보를 기반으로 주소 정보를 json 형태로 서버 스토리지에 저장하는 기능입니다.

대피소 db 를 업데이트 한 경우에, 실행하는 api 입니다.

""")
🔥 (주의) Shelter Database 정보를 기반으로 주소 정보를 json 형태로 서버 스토리지에 저장하는 기능입니다.
대피소 db 를 업데이트 한 경우에, 실행하는 api 입니다.
""")
@PostMapping("/address-info")
public ResponseEntity<String> uploadAllAddressInfo() {
return ResponseEntity.created(URI.create("/api/admin/address-info"))
Expand All @@ -63,8 +60,8 @@ public ResponseEntity<List<GetAddressResponse>> getAllAddressInfo() {

@Operation(summary = "(테스트용) 재난 발생시키기", description = """
지원되는 재난 유형:


DROUGHT("가뭄"),
STRONG_WIND("강풍"),
DRYNESS("건조"),
Expand Down Expand Up @@ -105,7 +102,7 @@ public ResponseEntity<List<GetAddressResponse>> getAllAddressInfo() {
OTHERS("기타"),
""")
@PostMapping("/disaster")
public ResponseEntity<SaveDisasterRequest> createDisaster(@RequestBody SaveDisasterRequest request){
public ResponseEntity<SaveAdminDisasterRequest> createDisaster(@RequestBody SaveAdminDisasterRequest request) {
disasterService.save(request);
return ResponseEntity.ok(request);
}
Expand Down
Loading
Loading