From 5dce245521a5440ac0cdbdeebe1c04037540a55d Mon Sep 17 00:00:00 2001 From: kimjaeyeol Date: Wed, 27 Oct 2021 15:17:34 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20Docker=20compose=20edu=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/apigateway/Dockerfile | 1 + .../src/main/resources/bootstrap.yml | 3 +- .../src/main/resources/logback-spring.xml | 2 +- backend/board-service/Dockerfile | 2 + .../src/main/resources/logback-spring.xml | 2 +- backend/config/Dockerfile | 5 +- .../config/src/main/resources/application.yml | 3 +- .../config/src/main/resources/bootstrap.yml | 2 +- .../src/main/resources/logback-spring.xml | 4 +- backend/portal-service/Dockerfile | 2 + .../src/main/resources/logback-spring.xml | 2 +- backend/user-service/Dockerfile | 3 +- .../src/main/resources/logback-spring.xml | 2 +- config/application.yml | 8 +-- config/board-service.yml | 2 +- config/portal-service.yml | 2 +- config/reserve-check-service.yml | 2 +- config/reserve-item-service.yml | 2 +- config/reserve-request-service.yml | 2 +- config/user-service.yml | 2 +- docker-compose/app/docker-compose.yml | 56 +++++++++++-------- docker-compose/app/mesh/docker-compose.yml | 6 ++ docker-compose/elk/docker-compose.yml | 13 ++--- docker-compose/mysql/docker-compose.yml | 5 ++ 24 files changed, 79 insertions(+), 54 deletions(-) diff --git a/backend/apigateway/Dockerfile b/backend/apigateway/Dockerfile index 677dcad..ce1d5d0 100644 --- a/backend/apigateway/Dockerfile +++ b/backend/apigateway/Dockerfile @@ -1,6 +1,7 @@ # openjdk8 base image FROM openjdk:8-jre-alpine +# directory 생성 RUN mkdir -p /usr/app/msa-attach-volume/messages # jar 파일이 복사되는 위치 ENV APP_HOME=/usr/app/ diff --git a/backend/apigateway/src/main/resources/bootstrap.yml b/backend/apigateway/src/main/resources/bootstrap.yml index cb13949..c23f12f 100644 --- a/backend/apigateway/src/main/resources/bootstrap.yml +++ b/backend/apigateway/src/main/resources/bootstrap.yml @@ -2,5 +2,4 @@ spring: cloud: config: uri: http://localhost:8888 - name: application - enabled: true + name: application \ No newline at end of file diff --git a/backend/apigateway/src/main/resources/logback-spring.xml b/backend/apigateway/src/main/resources/logback-spring.xml index 40f300c..74b3422 100644 --- a/backend/apigateway/src/main/resources/logback-spring.xml +++ b/backend/apigateway/src/main/resources/logback-spring.xml @@ -15,7 +15,7 @@ - + diff --git a/backend/board-service/Dockerfile b/backend/board-service/Dockerfile index 1f91f39..eefcf0a 100644 --- a/backend/board-service/Dockerfile +++ b/backend/board-service/Dockerfile @@ -1,6 +1,8 @@ # openjdk8 base image FROM openjdk:8-jre-alpine +# directory 생성 +RUN mkdir -p /usr/app/msa-attach-volume/messages # jar 파일이 복사되는 위치 ENV APP_HOME=/usr/app/ # 작업 시작 위치 diff --git a/backend/board-service/src/main/resources/logback-spring.xml b/backend/board-service/src/main/resources/logback-spring.xml index 8d9097c..5d2aec4 100644 --- a/backend/board-service/src/main/resources/logback-spring.xml +++ b/backend/board-service/src/main/resources/logback-spring.xml @@ -15,7 +15,7 @@ - + diff --git a/backend/config/Dockerfile b/backend/config/Dockerfile index c6a9267..c52c8a0 100644 --- a/backend/config/Dockerfile +++ b/backend/config/Dockerfile @@ -1,6 +1,9 @@ # docker run --name egov-config -d -p 8888:8888 -e profile=prod -e ENCRYPT_KEY=??? egovframework/egov-config # base image - openjdk8 FROM openjdk:8-jre-alpine + +# directory 생성 +RUN mkdir -p /usr/app/config # jar 파일이 복사되는 위치 ENV APP_HOME=/usr/app/ # 작업 시작 위치 @@ -10,4 +13,4 @@ COPY build/libs/*.jar config.jar # application port EXPOSE 8888 # 실행 -CMD ["java", "-Dspring.profiles.active=${profile:native}", "-jar", "config.jar"] +CMD ["java", "-Dsearch.location=/usr/app/config", "-jar", "config.jar"] diff --git a/backend/config/src/main/resources/application.yml b/backend/config/src/main/resources/application.yml index 5acb437..5d739f8 100644 --- a/backend/config/src/main/resources/application.yml +++ b/backend/config/src/main/resources/application.yml @@ -10,7 +10,8 @@ spring: config: server: native: - search-locations: file:///usr/app/config # docker + search-locations: ${search.location:file:///${user.home}/workspace.edu/egovframe-msa-edu/config} # Windows + # search-locations: file://${user.home}/workspace.edu/egovframe-msa-edu/config # MacOS rabbitmq: host: localhost port: 5672 diff --git a/backend/config/src/main/resources/bootstrap.yml b/backend/config/src/main/resources/bootstrap.yml index 2e25268..250aee9 100644 --- a/backend/config/src/main/resources/bootstrap.yml +++ b/backend/config/src/main/resources/bootstrap.yml @@ -1,2 +1,2 @@ encrypt: - key: egovframe # 대칭키 임의의 값 + key: egovframe # 대칭키 임의의 값 \ No newline at end of file diff --git a/backend/config/src/main/resources/logback-spring.xml b/backend/config/src/main/resources/logback-spring.xml index 6f496fa..d3d82ad 100644 --- a/backend/config/src/main/resources/logback-spring.xml +++ b/backend/config/src/main/resources/logback-spring.xml @@ -14,8 +14,8 @@ - - + + diff --git a/backend/portal-service/Dockerfile b/backend/portal-service/Dockerfile index 1f91f39..eefcf0a 100644 --- a/backend/portal-service/Dockerfile +++ b/backend/portal-service/Dockerfile @@ -1,6 +1,8 @@ # openjdk8 base image FROM openjdk:8-jre-alpine +# directory 생성 +RUN mkdir -p /usr/app/msa-attach-volume/messages # jar 파일이 복사되는 위치 ENV APP_HOME=/usr/app/ # 작업 시작 위치 diff --git a/backend/portal-service/src/main/resources/logback-spring.xml b/backend/portal-service/src/main/resources/logback-spring.xml index 561f8b0..cfdd9f0 100644 --- a/backend/portal-service/src/main/resources/logback-spring.xml +++ b/backend/portal-service/src/main/resources/logback-spring.xml @@ -15,7 +15,7 @@ - + diff --git a/backend/user-service/Dockerfile b/backend/user-service/Dockerfile index b0d8366..33cba04 100644 --- a/backend/user-service/Dockerfile +++ b/backend/user-service/Dockerfile @@ -1,7 +1,8 @@ # openjdk8 base image FROM openjdk:8-jre-alpine -RUN mkdir -p /usr/app/msa-attach-volume +# directory 생성 +RUN mkdir -p /usr/app/msa-attach-volume/messages # jar 파일이 복사되는 위치 ENV APP_HOME=/usr/app/ # 작업 시작 위치 diff --git a/backend/user-service/src/main/resources/logback-spring.xml b/backend/user-service/src/main/resources/logback-spring.xml index 28f6265..eeeb082 100644 --- a/backend/user-service/src/main/resources/logback-spring.xml +++ b/backend/user-service/src/main/resources/logback-spring.xml @@ -15,7 +15,7 @@ - + diff --git a/config/application.yml b/config/application.yml index af563ea..59ff97b 100644 --- a/config/application.yml +++ b/config/application.yml @@ -16,12 +16,10 @@ eureka: # file attach location - messages{lang}.properties 도 이 경로에 위치한다. file: - directory: ${user.home}/msa-attach-volume # url 사용시에는 사용되지 않는다 + directory: ${app.home:${user.home}}/msa-attach-volume # url 사용시에는 사용되지 않는다 url: http://localhost:8080 # nginx 로 파일 다운로드 처리 messages: directory: ${file.directory}/messages -logstash: - url: localhost:8086 apigateway: host: http://localhost:${server.port} @@ -29,12 +27,12 @@ apigateway: # rabbitmq server spring: rabbitmq: - host: localhost + host: ${rabbitmq.hostname:${localhost}} port: 5672 username: guest password: guest zipkin: - base-url: http://localhost:8085 + base-url: http://${zipkin.hostname:${localhost}}:8085 egov: message: hello \ No newline at end of file diff --git a/config/board-service.yml b/config/board-service.yml index 48f3f59..982099c 100644 --- a/config/board-service.yml +++ b/config/board-service.yml @@ -1,5 +1,5 @@ database: - url: jdbc:mysql://localhost:3306/msaportal + url: jdbc:mysql://${mysql.hostname:localhost}:3306/msaportal spring: datasource: diff --git a/config/portal-service.yml b/config/portal-service.yml index 50b7dbc..d031f33 100644 --- a/config/portal-service.yml +++ b/config/portal-service.yml @@ -1,5 +1,5 @@ database: - url: jdbc:mysql://localhost:3306/msaportal + url: jdbc:mysql://${mysql.hostname:localhost}:3306/msaportal spring: datasource: diff --git a/config/reserve-check-service.yml b/config/reserve-check-service.yml index 86b3b35..c0e2aa6 100644 --- a/config/reserve-check-service.yml +++ b/config/reserve-check-service.yml @@ -1,6 +1,6 @@ spring: r2dbc: - url: r2dbc:mysql://localhost:3306/reservation?serverTimezone=Asia/Seoul + url: r2dbc:mysql://${mysql.hostname:localhost}:3306/reservation?serverTimezone=Asia/Seoul username: msaportal password: msaportal cloud: diff --git a/config/reserve-item-service.yml b/config/reserve-item-service.yml index e15f1d3..c14f1f6 100644 --- a/config/reserve-item-service.yml +++ b/config/reserve-item-service.yml @@ -1,6 +1,6 @@ spring: r2dbc: - url: r2dbc:mysql://localhost:3306/msaportal?serverTimezone=Asia/Seoul + url: r2dbc:mysql://${mysql.hostname:localhost}:3306/msaportal?serverTimezone=Asia/Seoul username: msaportal password: msaportal cloud: diff --git a/config/reserve-request-service.yml b/config/reserve-request-service.yml index 4594f84..8b6d989 100644 --- a/config/reserve-request-service.yml +++ b/config/reserve-request-service.yml @@ -1,6 +1,6 @@ spring: r2dbc: - url: r2dbc:mysql://localhost:3306/reservation?serverTimezone=Asia/Seoul + url: r2dbc:mysql://${mysql.hostname:localhost}:3306/reservation?serverTimezone=Asia/Seoul username: msaportal password: msaportal cloud: diff --git a/config/user-service.yml b/config/user-service.yml index 83fb314..e3e4150 100644 --- a/config/user-service.yml +++ b/config/user-service.yml @@ -1,5 +1,5 @@ database: - url: jdbc:mysql://localhost:3306/msaportal + url: jdbc:mysql://${mysql.hostname:localhost}:3306/msaportal spring: datasource: diff --git a/docker-compose/app/docker-compose.yml b/docker-compose/app/docker-compose.yml index d9b2b08..fc94368 100644 --- a/docker-compose/app/docker-compose.yml +++ b/docker-compose/app/docker-compose.yml @@ -1,41 +1,53 @@ -version: '3.8' +version: '3' services: - egov-user-service: - container_name: egov-user-service + userservice: + container_name: userservice image: egovframe/msa-user-service:latest restart: always - #networks: egovnetwork volumes: - - ${HOME}/msa-attach-volume:/usr/app/msa-attach-volume + - ${HOME}/workspace/docker-compose:/usr/app/msa-attach-volume environment: + SPRING_CLOUD_CONFIG_URI: http://config:8888 SPRING_PROFILES_ACTIVE: default - depends_on: - - egov-apigateway + APP_HOME: /usr/app + logstash_hostname: logstash:5001 + EUREKA_INSTANCE_HOSTNAME: discovery + MYSQL_HOSTNAME: mysql + RABBITMQ_HOSTNAME: rabbitmq + ZIPKIN_HOSTNAME: zipkin + TZ: Asia/Seoul - egov-board-service: - container_name: egov-board-service + boardservice: + container_name: boardservice image: egovframe/msa-board-service:latest restart: always - #networks: egovnetwork volumes: - - ${HOME}/msa-attach-volume:/usr/app/msa-attach-volume + - ${HOME}/workspace:/usr/app/msa-attach-volume environment: + SPRING_CLOUD_CONFIG_URI: http://config:8888 SPRING_PROFILES_ACTIVE: default - depends_on: - - egov-apigateway + EUREKA_INSTANCE_HOSTNAME: discovery + APP_HOME: /usr/app + logstash_hostname: logstash:5001 + MYSQL_HOSTNAME: mysql + TZ: Asia/Seoul - egov-portal-service: - container_name: egov-portal-service + portalservice: + container_name: portalservice image: egovframe/msa-portal-service:latest restart: always - #networks: egovnetwork volumes: - - ${HOME}/msa-attach-volume:/usr/app/msa-attach-volume + - ${HOME}/workspace:/usr/app/msa-attach-volume environment: + SPRING_CLOUD_CONFIG_URI: http://config:8888 SPRING_PROFILES_ACTIVE: default - depends_on: - - egov-apigateway + EUREKA_INSTANCE_HOSTNAME: discovery + APP_HOME: /usr/app + logstash_hostname: logstash:5001 + MYSQL_HOSTNAME: mysql + TZ: Asia/Seoul -# networks: -# egovnetwork: -# driver: bridge \ No newline at end of file +networks: + default: + external: + name: egov-network \ No newline at end of file diff --git a/docker-compose/app/mesh/docker-compose.yml b/docker-compose/app/mesh/docker-compose.yml index 7799582..df43144 100644 --- a/docker-compose/app/mesh/docker-compose.yml +++ b/docker-compose/app/mesh/docker-compose.yml @@ -10,6 +10,9 @@ services: - ${HOME}/workspace/egovframe-msa-edu/config:/usr/app/config # volume bind environment: ENCRYPT_KEY: token_secret + logstash_hostname: logstash:5001 + RABBITMQ_HOSTNAME: rabbitmq + ZIPKIN_HOSTNAME: zipkin TZ: Asia/Seoul discovery: @@ -35,6 +38,9 @@ services: SPRING_CLOUD_CONFIG_URI: http://config:8888 SPRING_PROFILES_ACTIVE: default EUREKA_INSTANCE_HOSTNAME: discovery + RABBITMQ_HOSTNAME: rabbitmq + ZIPKIN_HOSTNAME: zipkin + APP_HOME: /usr/app TZ: Asia/Seoul depends_on: - config diff --git a/docker-compose/elk/docker-compose.yml b/docker-compose/elk/docker-compose.yml index 8b5afa5..016cddc 100644 --- a/docker-compose/elk/docker-compose.yml +++ b/docker-compose/elk/docker-compose.yml @@ -14,10 +14,8 @@ services: memlock: soft: -1 hard: -1 - networks: - - elastic volumes: - - ${HOME}/docker-volume/elasticsearch/data:/usr/share/elasticsearch/data + - ${PWD}/data:/usr/share/elasticsearch/data logstash: container_name: logstash @@ -37,8 +35,6 @@ services: source: ${PWD}/logstash/pipeline target: /usr/share/logstash/pipeline read_only: true - networks: - - elastic depends_on: - elasticsearch @@ -57,11 +53,10 @@ services: source: ${PWD}/kibana/config/kibana.yml target: /usr/share/kibana/config/kibana.yml read_only: true - networks: - - elastic depends_on: - elasticsearch networks: - elastic: - driver: bridge \ No newline at end of file + default: + external: + name: egov-network \ No newline at end of file diff --git a/docker-compose/mysql/docker-compose.yml b/docker-compose/mysql/docker-compose.yml index 44f2bc8..6c27b3e 100644 --- a/docker-compose/mysql/docker-compose.yml +++ b/docker-compose/mysql/docker-compose.yml @@ -17,3 +17,8 @@ services: ports: - "3306:3306" container_name: mysql + +networks: + default: + external: + name: egov-network \ No newline at end of file