Skip to content

Commit

Permalink
🚨 fix: 배포 스크립트 오류 수정 (#657)
Browse files Browse the repository at this point in the history
  • Loading branch information
kimminkyeu authored Dec 2, 2024
1 parent 2981321 commit a5fd041
Show file tree
Hide file tree
Showing 13 changed files with 166 additions and 112 deletions.
3 changes: 3 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
*.env
data/mysql-data
data/develop
data/mongo
logs

HELP.md
.gradle
Expand Down
61 changes: 40 additions & 21 deletions backend/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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 포트
- "8082:8080"
env_file:
- .env
environment:
- SPRING_PROFILES_ACTIVE=dev
networks:
- techpick-network
depends_on:
- techpick-ranking-mongo
16 changes: 16 additions & 0 deletions backend/readme.md
Original file line number Diff line number Diff line change
@@ -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
```
32 changes: 13 additions & 19 deletions backend/techpick-api/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -70,9 +67,7 @@ oauth2-attribute-config-provider:
naver:
name: "id"
email: "email"

---

spring:
config:
activate:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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
---
10 changes: 1 addition & 9 deletions backend/techpick-api/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,6 @@
</appender>

<!-- ``````````````````````` LOGGER SETTING ```````````````````````````` -->
<!-- "additivity=false"를 하면 해당 <logger>에서만 로깅 되고, 다른 곳으로 전달 되지 않는다.
(ref: https://mkyong.com/logging/logback-duplicate-log-messages/) -->
<!-- <logger name="root" level="debug" additivity="false">-->
<!-- <appender-ref ref="CONSOLE"/>-->
<!-- </logger>-->

<!-- (1) 프로젝트 전체 로그 설정 -->
<logger name="techpick.api" level="info" additivity="false">
<appender-ref ref="CONSOLE"/>
Expand All @@ -83,10 +77,8 @@
<appender-ref ref="CONSOLE"/>
<appender-ref ref="APP-LOG-FILE"/>
</logger>

<logger name="p6spy" level="info" additivity="false">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="SQL-LOG-FILE"/>
</logger>


</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
26 changes: 25 additions & 1 deletion backend/techpick-batch/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
---
spring:
profiles:
include:
- core
- 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
4 changes: 2 additions & 2 deletions backend/techpick-batch/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,16 @@
(ref: https://mkyong.com/logging/logback-duplicate-log-messages/) -->

<!-- (1) 프로젝트 전체 로그 설정 -->
<logger name="techpick.api" level="info" additivity="false">
<logger name="techpick.batch" level="info" additivity="false">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="APP-LOG-FILE"/>
</logger>
<logger name="techpick.core" level="info" additivity="false">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="APP-LOG-FILE"/>
</logger>

<logger name="p6spy" level="info" additivity="false">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="SQL-LOG-FILE"/>
</logger>

Expand Down
33 changes: 5 additions & 28 deletions backend/techpick-core/src/main/resources/application-core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Loading

0 comments on commit a5fd041

Please sign in to comment.