diff --git a/backend/.gitignore b/backend/.gitignore index 4f088d4cf..d93a0f75b 100644 --- a/backend/.gitignore +++ b/backend/.gitignore @@ -1,5 +1,8 @@ *.env data/mysql-data +data/develop +data/mongo +logs HELP.md .gradle diff --git a/backend/docker-compose.yaml b/backend/docker-compose.yaml index bcdeb9d4e..6d1d32b7c 100644 --- a/backend/docker-compose.yaml +++ b/backend/docker-compose.yaml @@ -33,6 +33,21 @@ services: networks: - techpick-network + techpick-rabbitmq: + # ********************************** + # TECHPICK MESSAGE QUEUE + # ********************************** + image: rabbitmq:3-management + container_name: techpick.infra.message-queue + hostname: techpick + environment: + - RABBITMQ_ERLANG_COOKIE=${RABBITMQ_ERLANG_COOKIE} + - RABBITMQ_DEFAULT_USER=${RABBITMQ_USERNAME} + - RABBITMQ_DEFAULT_PASS=${RABBITMQ_PASSWORD} + ports: + - "15672:15672" # 관리 UI 포트 + - "5672:5672" # AMQP 포트 + techpick-ranking-mongo: # *********************************** # NoSQL DB for Ranking Module @@ -60,16 +75,14 @@ services: context: ./techpick-api dockerfile: Dockerfile container_name: techpick.server.api + volumes: + - ./logs/batch:/app/logs ports: - "8080:8080" env_file: - .env environment: - - LOCAL_MYSQL_URL=${DOCKER_MYSQL_URL} - - DOCKER_MYSQL_USERNAME=${DOCKER_MYSQL_USERNAME} - - DOCKER_MYSQL_PASSWORD=${DOCKER_MYSQL_PASSWORD} - - TZ=Asia/Seoul - - SPRING_PROFILES_ACTIVE=local + - SPRING_PROFILES_ACTIVE=dev networks: - techpick-network depends_on: @@ -83,30 +96,36 @@ services: context: ./techpick-batch dockerfile: Dockerfile container_name: techpick.server.batch + volumes: + - ./logs/batch:/app/logs + ports: + - "8081:8080" env_file: - .env environment: - - LOCAL_MYSQL_URL=${DOCKER_MYSQL_URL} - - DOCKER_MYSQL_USERNAME=${DOCKER_MYSQL_USERNAME} - - DOCKER_MYSQL_PASSWORD=${DOCKER_MYSQL_PASSWORD} - - TZ=Asia/Seoul - - SPRING_PROFILES_ACTIVE=local + - SPRING_PROFILES_ACTIVE=dev networks: - techpick-network depends_on: - techpick-mysql - techpick-rabbitmq: + techpick-ranking: # ********************************** - # TECHPICK MESSAGE QUEUE + # TECHPICK RANKING SERVER # ********************************** - image: rabbitmq:3-management - container_name: techpick.infra.message-queue - hostname: techpick - environment: - - RABBITMQ_ERLANG_COOKIE=${RABBITMQ_ERLANG_COOKIE} - - RABBITMQ_DEFAULT_USER=${RABBITMQ_USERNAME} - - RABBITMQ_DEFAULT_PASS=${RABBITMQ_PASSWORD} + build: + context: ./techpick-ranking + dockerfile: Dockerfile + container_name: techpick.server.ranking + volumes: + - ./logs/ranking:/app/logs ports: - - "15672:15672" # 관리 UI 포트 - - "5672:5672" # AMQP 포트 \ No newline at end of file + - "8082:8080" + env_file: + - .env + environment: + - SPRING_PROFILES_ACTIVE=dev + networks: + - techpick-network + depends_on: + - techpick-ranking-mongo diff --git a/backend/readme.md b/backend/readme.md new file mode 100644 index 000000000..c8fbbf149 --- /dev/null +++ b/backend/readme.md @@ -0,0 +1,16 @@ +# techpick backend + +0. create .env file + +``` +touch .env +``` + +1. Run with local docker compose + +```bash +# 1. build jar +./gradlew clean build --exclude-task test +# 2. build image && run containers +docker compose up -d +``` \ No newline at end of file diff --git a/backend/techpick-api/src/main/resources/application.yaml b/backend/techpick-api/src/main/resources/application.yaml index f77b629cb..5a95d9af1 100644 --- a/backend/techpick-api/src/main/resources/application.yaml +++ b/backend/techpick-api/src/main/resources/application.yaml @@ -3,20 +3,18 @@ spring: include: - core application: - name: techpick-api - + name: 'techpick.server.api' springdoc: swagger-ui: disable-swagger-default-url: true api-docs: path: /api-docs show-actuator: true - # swagger 가 패키지를 포함하여 관리하게 함 -> 같은 클래스내의 inner class 또한 구분 가능 - # ex) TagApiResponse.Create TagApiResponse.Move 를 구분할 수 있음 - use-fqn: true - + use-fqn: true # swagger가 패키지를 포함 관리, 같은 클래스내의 inner class 또한 구분 가능. Ex) TagApiResponse.Create TagApiResponse.Move 를 구분할 수 있음 +#logging: # /* Transaction Logging */ +# level: +# org.springframework.orm.jpa: DEBUG --- - spring: jwt: secret: @@ -58,7 +56,6 @@ spring: token-uri: https://nid.naver.com/oauth2.0/token user-info-uri: https://openapi.naver.com/v1/nid/me user-name-attribute: response - oauth2-attribute-config-provider: attributeConfig: google: @@ -70,9 +67,7 @@ oauth2-attribute-config-provider: naver: name: "id" email: "email" - --- - spring: config: activate: @@ -94,9 +89,9 @@ security: cookie-domain: localhost default-redirect-url: http://localhost:8080 base-url: http://localhost:8080 - +server: + port: 8080 --- - spring: config: activate: @@ -119,9 +114,9 @@ security: cookie-domain: minlife.me default-redirect-url: https://app.minlife.me base-url: https://v2.minlife.me - +server: + port: 8080 --- - spring: config: activate: @@ -143,10 +138,9 @@ security: cookie-domain: techpick.org default-redirect-url: https://app.techpick.org base-url: https://api.techpick.org - -# 운영 환경에서 스웨거 접근 못하도록 막는 설정 -springdoc: +springdoc: # 운영 환경에서 스웨거 접근 못하도록 막는 설정 swagger-ui: - enabled: false # false로 변경하면, swagger 접근 불가 - + enabled: false # false로 변경하면, swagger 접근 불가 +server: + port: 8080 --- \ No newline at end of file diff --git a/backend/techpick-api/src/main/resources/logback-spring.xml b/backend/techpick-api/src/main/resources/logback-spring.xml index d8ad79db7..9cbba8d5c 100644 --- a/backend/techpick-api/src/main/resources/logback-spring.xml +++ b/backend/techpick-api/src/main/resources/logback-spring.xml @@ -68,12 +68,6 @@ - - - - - @@ -83,10 +77,8 @@ - + - - \ No newline at end of file diff --git a/backend/techpick-batch/src/main/java/techpick/TechPickBatchApplication.java b/backend/techpick-batch/src/main/java/techpick/TechPickBatchApplication.java index ab770fbb2..5d3cd6a16 100644 --- a/backend/techpick-batch/src/main/java/techpick/TechPickBatchApplication.java +++ b/backend/techpick-batch/src/main/java/techpick/TechPickBatchApplication.java @@ -3,9 +3,7 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -@SpringBootApplication( - // scanBasePackages = {"techpick.batch", "techpick.core"} -) +@SpringBootApplication public class TechPickBatchApplication { public static void main(String[] args) { SpringApplication.run(TechPickBatchApplication.class, args); diff --git a/backend/techpick-batch/src/main/resources/application.yaml b/backend/techpick-batch/src/main/resources/application.yaml index 8df6ea3ea..d7f658669 100644 --- a/backend/techpick-batch/src/main/resources/application.yaml +++ b/backend/techpick-batch/src/main/resources/application.yaml @@ -1,4 +1,28 @@ +--- spring: profiles: include: - - core \ No newline at end of file + - core + application: + name: 'techpick.server.batch' +--- +spring: + config: + activate: + on-profile: local +server: + port: 8081 +--- +spring: + config: + activate: + on-profile: dev +server: + port: 8080 +--- +spring: + config: + activate: + on-profile: prod +server: + port: 8080 \ No newline at end of file diff --git a/backend/techpick-batch/src/main/resources/logback-spring.xml b/backend/techpick-batch/src/main/resources/logback-spring.xml index 9218e37bd..6075637f2 100644 --- a/backend/techpick-batch/src/main/resources/logback-spring.xml +++ b/backend/techpick-batch/src/main/resources/logback-spring.xml @@ -83,7 +83,7 @@ (ref: https://mkyong.com/logging/logback-duplicate-log-messages/) --> - + @@ -91,8 +91,8 @@ - + diff --git a/backend/techpick-core/src/main/resources/application-core.yaml b/backend/techpick-core/src/main/resources/application-core.yaml index 498236b7f..253b02abb 100644 --- a/backend/techpick-core/src/main/resources/application-core.yaml +++ b/backend/techpick-core/src/main/resources/application-core.yaml @@ -5,84 +5,61 @@ spring: sql: init: mode: never # schema.sql 실행시 always 키고 실행하시면 됩니다. option: never, always - jpa: + open-in-view: false properties: hibernate: + format_sql: false + show_sql: false dialect: org.hibernate.dialect.MySQL8Dialect - open-in-view: false - -#logging: # /* Transaction Logging */ -# level: -# org.springframework.orm.jpa: DEBUG - + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver --- - spring: config: activate: on-profile: local jpa: - properties: - hibernate: - format_sql: false - show_sql: true hibernate: ddl-auto: update - # ddl-auto: create datasource: url: ${LOCAL_MYSQL_URL} username: ${DOCKER_MYSQL_USERNAME} password: ${DOCKER_MYSQL_PASSWORD} - driver-class-name: com.mysql.cj.jdbc.Driver rabbitmq: host: ${LOCAL_RABBITMQ_HOST} port: ${RABBITMQ_PORT} username: ${RABBITMQ_USERNAME} password: ${RABBITMQ_PASSWORD} - --- - spring: config: activate: on-profile: dev jpa: - properties: - hibernate: - format_sql: false - show_sql: false hibernate: ddl-auto: update datasource: url: ${DOCKER_MYSQL_URL} username: ${DOCKER_MYSQL_USERNAME} password: ${DOCKER_MYSQL_PASSWORD} - driver-class-name: com.mysql.cj.jdbc.Driver rabbitmq: host: ${RABBITMQ_HOST} port: ${RABBITMQ_PORT} username: ${RABBITMQ_USERNAME} password: ${RABBITMQ_PASSWORD} - --- - spring: config: activate: on-profile: prod jpa: - properties: - hibernate: - format_sql: false - show_sql: false hibernate: ddl-auto: none datasource: url: ${DOCKER_MYSQL_URL} username: ${DOCKER_MYSQL_USERNAME} password: ${DOCKER_MYSQL_PASSWORD} - driver-class-name: com.mysql.cj.jdbc.Driver rabbitmq: host: ${RABBITMQ_HOST} port: ${RABBITMQ_PORT} diff --git a/backend/techpick-ranking/build.gradle b/backend/techpick-ranking/build.gradle index 1cb478590..e624bb360 100644 --- a/backend/techpick-ranking/build.gradle +++ b/backend/techpick-ranking/build.gradle @@ -13,11 +13,16 @@ dependencies { implementation project(":techpick-core") implementation 'org.springframework.boot:spring-boot-starter-data-mongodb' +} + +tasks.named('test') { + enabled = false +} - testImplementation platform('org.junit:junit-bom:5.10.0') - testImplementation 'org.junit.jupiter:junit-jupiter' +bootJar { + enabled = true } -test { - useJUnitPlatform() -} \ No newline at end of file +jar { + enabled = false +} diff --git a/backend/techpick-ranking/src/main/java/techpick/TechPickRankingApplication.java b/backend/techpick-ranking/src/main/java/techpick/TechPickRankingApplication.java index 4d4d0fe4e..72d81d7d9 100644 --- a/backend/techpick-ranking/src/main/java/techpick/TechPickRankingApplication.java +++ b/backend/techpick-ranking/src/main/java/techpick/TechPickRankingApplication.java @@ -2,13 +2,11 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; -import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; -@SpringBootApplication( - // scanBasePackages = {"techpick.core"} - // exclude = {DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class} -) +/** + * Exclude Hibernate Jpa module + */ +@SpringBootApplication public class TechPickRankingApplication { public static void main(String[] args) { diff --git a/backend/techpick-ranking/src/main/resources/application.yaml b/backend/techpick-ranking/src/main/resources/application.yaml index 9a90db60b..6bd20e3d7 100644 --- a/backend/techpick-ranking/src/main/resources/application.yaml +++ b/backend/techpick-ranking/src/main/resources/application.yaml @@ -1,13 +1,17 @@ -# 로컬에서 techpick-api와 동시에 켜야 할 경우 아래 주석을 해제하세요 -server: - port: 8082 - +logging: + level: + org: + springframework: + data: + mongodb: + core: + MongoTemplate: DEBUG # MongoDB Query Logging spring: profiles: include: - core application: - name: techpick-ranking + name: 'techpick.service.ranking' output: ansi: enabled: always @@ -25,16 +29,32 @@ spring: database: ${DOCKER_MONGO_DATABASE} username: ${DOCKER_MONGO_USERNAME} password: ${DOCKER_MONGO_PASSWORD} +server: + port: 8082 --- spring: config: activate: - on-profile: dev, prod + on-profile: dev data: mongodb: uri: mongodb://${DOCKER_MONGO_USERNAME}:${DOCKER_MONGO_PASSWORD}@${DOCKER_MONGO_URL}/${DOCKER_MONGO_DATABASE}?authSource=${DOCKER_MONGO_AUTH} database: ${DOCKER_MONGO_DATABASE} username: ${DOCKER_MONGO_USERNAME} password: ${DOCKER_MONGO_PASSWORD} +server: + port: 8080 --- - +spring: + config: + activate: + on-profile: prod + data: + mongodb: + uri: mongodb://${DOCKER_MONGO_USERNAME}:${DOCKER_MONGO_PASSWORD}@${DOCKER_MONGO_URL}/${DOCKER_MONGO_DATABASE}?authSource=${DOCKER_MONGO_AUTH} + database: ${DOCKER_MONGO_DATABASE} + username: ${DOCKER_MONGO_USERNAME} + password: ${DOCKER_MONGO_PASSWORD} +server: + port: 8080 +--- \ No newline at end of file diff --git a/backend/techpick-ranking/src/main/resources/logback-spring.xml b/backend/techpick-ranking/src/main/resources/logback-spring.xml index 86344bbe2..c962a0388 100644 --- a/backend/techpick-ranking/src/main/resources/logback-spring.xml +++ b/backend/techpick-ranking/src/main/resources/logback-spring.xml @@ -2,10 +2,6 @@ - - - - @@ -41,10 +37,11 @@ 100MB ${LOG_PATH}/${DATE_DIR}/application.%i.log - - 20GB - - 60 + ${LOG_PATH}/${DATE_DIR}/application.%i.log + + + + @@ -52,6 +49,16 @@ + + + logs/batch/badminton-batch.%d{yyyy-MM-dd}.log + 30 + + + [%thread] [%date] [%level] [%logger{10}] [%file:%line] - %msg%n + + + @@ -80,9 +87,10 @@ - - - + + + + \ No newline at end of file