diff --git a/.gitignore b/.gitignore index 90f535a..988d812 100644 --- a/.gitignore +++ b/.gitignore @@ -52,4 +52,8 @@ unpackage/ .vscode/ # [mac] -.DS_Store \ No newline at end of file +.DS_Store + +docker/rocketmq/broker/logs/ +docker/rocketmq/broker/store/ +docker/rocketmq/namesrv/ \ No newline at end of file diff --git a/conf/manager/application.yml b/conf/manager/application.yml index ebc9aed..2f1172e 100644 --- a/conf/manager/application.yml +++ b/conf/manager/application.yml @@ -30,9 +30,9 @@ spring: number_format: '#' #数字格式进行原样显示,不加格式化字符例如 100,00 datasource: # yml填写url连接串, 无需将&符号进行转义 - url: jdbc:mysql://127.0.0.1:3306/jeepaydb?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true - username: root - password: + url: jdbc:mysql://172.20.0.10:3306/jeepaydb?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true + username: jeepay + password: jeepay druid: # 连接池配置项 initial-size: 5 #初始化时建立物理连接的个数 @@ -55,7 +55,7 @@ spring: cache: type: redis redis: - host: 127.0.0.1 + host: 172.20.0.12 port: 6379 database: 1 #1库:运营平台 #2库:商户系统 #3库:支付网关 timeout: 1000 @@ -63,7 +63,7 @@ spring: # #activeMQ配置 ( 注意: activeMQ配置项需在spring的下级 ) activemq: - broker-url: failover:(tcp://127.0.0.1:61616?wireFormat.maxInactivityDuration=0) #连接地址 + broker-url: failover:(tcp://172.20.0.11:61616?wireFormat.maxInactivityDuration=0) #连接地址 in-memory: false # Jeepay项目不可使用内存模式, 需要连接多个消费者。 user: system # activeMQ默认无需账密认证。 打开认证:activemq.xml添加simpleAuthenticationPlugin标签,账密在credentials.properties文件。 password: manager @@ -74,17 +74,18 @@ spring: # # #rabbitmq配置 ( 注意: rabbitmq配置项需在spring的下级 ) # rabbitmq: -# addresses: 127.0.0.1:5672 -# username: guest -# password: guest +# addresses: 172.20.0.11:5672 +# username: admin +# password: admin # dynamic: true -# virtual-host: / +# virtual-host: jeepay + ## rocketmq配置 ( 注意:rocketmq配置项请放置到根目录, 不是spring的二级配置! ) -#rocketmq: -# name-server: 127.0.0.1:9876 -# producer: -# group: JEEPAY-GROUP +rocketmq: + name-server: 172.20.0.11:9876 + producer: + group: JEEPAY-GROUP ## 阿里云rocketmq配置 ( 注意:aliyun-rocketmq配置项请放置到根目录, 不是spring的二级配置!需要阿里云开通rocketMQ产品,创建Group和Topic ) #aliyun-rocketmq: diff --git a/conf/merchant/application.yml b/conf/merchant/application.yml index 2b3f0ec..3475d42 100644 --- a/conf/merchant/application.yml +++ b/conf/merchant/application.yml @@ -30,9 +30,9 @@ spring: number_format: '#' #数字格式进行原样显示,不加格式化字符例如 100,00 datasource: # yml填写url连接串, 无需将&符号进行转义 - url: jdbc:mysql://127.0.0.1:3306/jeepaydb?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true - username: root - password: + url: jdbc:mysql://172.20.0.10:3306/jeepaydb?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true + username: jeepay + password: jeepay druid: # 连接池配置项 initial-size: 5 #初始化时建立物理连接的个数 @@ -55,7 +55,7 @@ spring: cache: type: redis redis: - host: 127.0.0.1 + host: 172.20.0.12 port: 6379 database: 2 #1库:运营平台 #2库:商户系统 #3库:支付网关 timeout: 1000 @@ -63,7 +63,7 @@ spring: # #activeMQ配置 ( 注意: activeMQ配置项需在spring的下级 ) activemq: - broker-url: failover:(tcp://127.0.0.1:61616?wireFormat.maxInactivityDuration=0) #连接地址 + broker-url: failover:(tcp://172.20.0.11:61616?wireFormat.maxInactivityDuration=0) #连接地址 in-memory: false # Jeepay项目不可使用内存模式, 需要连接多个消费者。 user: system # activeMQ默认无需账密认证。 打开认证:activemq.xml添加simpleAuthenticationPlugin标签,账密在credentials.properties文件。 password: manager @@ -74,15 +74,16 @@ spring: # # #rabbitmq配置 ( 注意: rabbitmq配置项需在spring的下级 ) # rabbitmq: -# addresses: 127.0.0.1:5672 -# username: guest -# password: guest +# addresses: 172.20.0.11:5672 +# username: admin +# password: admin # dynamic: true -# virtual-host: / +# virtual-host: jeepay + ## rocketmq配置 ( 注意:rocketmq配置项请放置到根目录, 不是spring的二级配置! ) #rocketmq: -# name-server: 127.0.0.1:9876 +# name-server: 172.20.0.11:9876 # producer: # group: JEEPAY-GROUP diff --git a/conf/payment/application.yml b/conf/payment/application.yml index 1e98bab..28eeac0 100644 --- a/conf/payment/application.yml +++ b/conf/payment/application.yml @@ -30,9 +30,9 @@ spring: number_format: '#' #数字格式进行原样显示,不加格式化字符例如 100,00 datasource: # yml填写url连接串, 无需将&符号进行转义 - url: jdbc:mysql://127.0.0.1:3306/jeepaydb?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true - username: root - password: + url: jdbc:mysql://172.20.0.10:3306/jeepaydb?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true + username: jeepay + password: jeepay druid: # 连接池配置项 initial-size: 5 #初始化时建立物理连接的个数 @@ -55,7 +55,7 @@ spring: cache: type: redis redis: - host: 127.0.0.1 + host: 172.20.0.12 port: 6379 database: 3 #1库:运营平台 #2库:商户系统 #3库:支付网关 timeout: 1000 @@ -63,7 +63,7 @@ spring: # #activeMQ配置 ( 注意: activeMQ配置项需在spring的下级 ) activemq: - broker-url: failover:(tcp://127.0.0.1:61616?wireFormat.maxInactivityDuration=0) #连接地址 + broker-url: failover:(tcp://172.20.0.11:61616?wireFormat.maxInactivityDuration=0) #连接地址 in-memory: false # Jeepay项目不可使用内存模式, 需要连接多个消费者。 user: system # activeMQ默认无需账密认证。 打开认证:activemq.xml添加simpleAuthenticationPlugin标签,账密在credentials.properties文件。 password: manager @@ -74,17 +74,16 @@ spring: # # #rabbitmq配置 ( 注意: rabbitmq配置项需在spring的下级 ) # rabbitmq: -# addresses: 127.0.0.1:5672 -# username: guest -# password: guest +# addresses: 172.20.0.11:5672 +# username: admin +# password: admin # dynamic: true -# virtual-host: / +# virtual-host: jeepay ## rocketmq配置 ( 注意:rocketmq配置项请放置到根目录, 不是spring的二级配置! ) #rocketmq: -# name-server: 127.0.0.1:9876 +# name-server: 172.20.0.11:9876 # producer: -# group: JEEPAY-GROUP ## 阿里云rocketmq配置 ( 注意:aliyun-rocketmq配置项请放置到根目录, 不是spring的二级配置!需要阿里云开通rocketMQ产品,创建Group和Topic ) #aliyun-rocketmq: diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..9374ba6 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,197 @@ +version: '3' + +# Maven 依赖提前编译,修改 MQ 队列 (修改 jeepay-components-mq 依赖) 也需要重新运行此命令 +# docker build -t jeepay-deps:latest -f docs/Dockerfile . +# 启动命令 docker-compose up +# 启动并运行在后台 docker-compose up -d +# 重新编译 docker-compose up --build +# 重新创建 docker-composer up --force-recreate +# 重新编译并覆盖之前的 docker-composer up --build --force-recreate + +services: + mysql: + hostname: mysql + container_name: jeepay-mysql + # amd64 平台 + image: mysql/mysql-server:latest + #image: mysql:8 + environment: + MYSQL_ROOT_PASSWORD: "rootroot" + MYSQL_DATABASE: "jeepaydb" + MYSQL_USER: "jeepay" + MYSQL_PASSWORD: "jeepay" + ports: + - "3306:3306" + volumes: + - mysql:/var/lib/mysql + - ./docs/sql/init.sql:/docker-entrypoint-initdb.d/init.sql:ro + networks: + jeepay: + ipv4_address: 172.20.0.10 + activemq: + build: + context: ./docker/activemq + dockerfile: Dockerfile + hostname: activemq + container_name: jeepay-activemq + image: jeepay-activemq:latest + ports: #- "1883:1883" + #- "5672:5672" + - "8161:8161" + #- "61613:61613" + #- "61614:61614" + - "61616:61616" + volumes: + - activemq:/opt/activemq + - ./docker/activemq/activemq.xml:/opt/activemq/conf/activemq.xml + networks: + jeepay: + ipv4_address: 172.20.0.11 + # 扩展额外延迟插件的 RabbitMQ + #rabbitmq: + # build: + # context: ./docker/rabbitmq + # dockerfile: Dockerfile + # hostname: rabbitmq + # container_name: jeepay-rabbitmq + # image: jeepay-rabbitmq:latest + # ports: + # - "15672:15672" + # - "4369:4369" + # - "5672:5672" + # - "25672:25672" + # environment: + # RABBITMQ_DEFAULT_USER: 'admin' + # RABBITMQ_DEFAULT_PASS: 'admin' + # RABBITMQ_DEFAULT_VHOST: 'jeepay' + # volumes: + # - rabbitmq:/var/lib/rabbitmq + # networks: + # jeepay: + # ipv4_address: 172.20.0.11 + # 使用 activemq 如有需要请修改 docker/activemq.xml 下相关配置 + #rocketmq-namesrv: + # image: apache/rocketmq:4.9.3 + # container_name: rmqnamesrv + # ports: + # - 9876:9876 + # volumes: + # - ./docker/rocketmq/namesrv/logs:/home/rocketmq/logs + # command: sh mqnamesrv + # networks: + # jeepay: + # ipv4_address: 172.20.0.11 + #rocketmq-broker: + # image: apache/rocketmq:4.9.3 + # container_name: rmqbroker + # ports: + # - 10909:10909 + # - 10911:10911 + # - 10912:10912 + # environment: + # - NAMESRV_ADDR=namesrv:9876 + # volumes: + # - ./docker/rocketmq/broker/logs:/home/rocketmq/logs + # - ./docker/rocketmq/broker/store:/home/rocketmq/store + # - ./docker/rocketmq/broker/conf/broker.conf:/opt/rocketmq-4.9.3/conf/broker.conf + # command: sh mqbroker -c /opt/rocketmq-4.9.3/conf/broker.conf + # depends_on: + # - rocketmq-namesrv + # networks: + # jeepay: + # ipv4_address: 172.20.0.13 + redis: + hostname: redis + container_name: jeepay-redis + image: redis:latest + ports: + - "6380:6379" + networks: + jeepay: + ipv4_address: 172.20.0.12 + volumes: + - redis:/data + payment: + build: + context: . + dockerfile: Dockerfile + args: + PORT: 9216 + PLATFORM: payment + image: jeepay_payment:latest + hostname: payment + container_name: jeepay-payment + ports: + - "9216:9216" + depends_on: + - mysql + - redis + - activemq + - rabbitmq + - rocketmq-broker + networks: + jeepay: + ipv4_address: 172.20.0.21 + volumes: + - ./logs/payment:/workspace/logs + - ./conf/payment/application.yml:/workspace/application.yml + manager: + build: + context: . + dockerfile: Dockerfile + args: + PORT: 9217 + PLATFORM: manager + image: jeepay_manager:latest + hostname: manager + container_name: jeepay-manager + ports: + - "9217:9217" + depends_on: + - mysql + - redis + - activemq + - rabbitmq + - rocketmq-broker + networks: + jeepay: + ipv4_address: 172.20.0.22 + volumes: + - ./logs/manager:/workspace/logs + - ./conf/manager/application.yml:/workspace/application.yml + merchant: + build: + context: . + dockerfile: Dockerfile + args: + PORT: 9218 + PLATFORM: merchant + image: jeepay_merchant:latest + hostname: merchant + container_name: jeepay-merchant + ports: + - "9218:9218" + depends_on: + - mysql + - redis + - activemq + - rabbitmq + - rocketmq-broker + networks: + jeepay: + ipv4_address: 172.20.0.23 + volumes: + - ./logs/merchant:/workspace/logs + - ./conf/merchant/application.yml:/workspace/application.yml + +networks: + jeepay: + ipam: + config: + - subnet: 172.20.0.0/16 + +volumes: + mysql: + redis: + activemq: +# rabbitmq: \ No newline at end of file diff --git a/docker/activemq/Dockerfile b/docker/activemq/Dockerfile new file mode 100644 index 0000000..5423b48 --- /dev/null +++ b/docker/activemq/Dockerfile @@ -0,0 +1,24 @@ +FROM bellsoft/liberica-openjdk-alpine:13 + +ENV ACTIVEMQ_VERSION 5.16.4 +ENV ACTIVEMQ apache-activemq-$ACTIVEMQ_VERSION +ENV ACTIVEMQ_HOME /opt/activemq + +RUN apk add --update curl && \ + rm -rf /var/cache/apk/* && \ + mkdir -p /opt && \ + curl -s -S https://archive.apache.org/dist/activemq/$ACTIVEMQ_VERSION/$ACTIVEMQ-bin.tar.gz | tar -xvz -C /opt && \ + ln -s /opt/$ACTIVEMQ $ACTIVEMQ_HOME && \ + addgroup -S activemq && \ + adduser -S -H -G activemq -h $ACTIVEMQ_HOME activemq && \ + chown -R activemq:activemq /opt/$ACTIVEMQ && \ + chown -h activemq:activemq $ACTIVEMQ_HOME + +COPY ./activemq.xml $ACTIVEMQ_HOME/conf/activemq.xml + +EXPOSE 1883 5672 8161 61613 61614 61616 + +USER activemq +WORKDIR $ACTIVEMQ_HOME + +CMD ["/bin/sh", "-c", "bin/activemq console"] \ No newline at end of file diff --git a/docker/activemq/activemq.xml b/docker/activemq/activemq.xml new file mode 100644 index 0000000..e9ec8cc --- /dev/null +++ b/docker/activemq/activemq.xml @@ -0,0 +1,160 @@ + + + + + + + + file:${activemq.conf}/credentials.properties + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docker/rabbitmq/Dockerfile b/docker/rabbitmq/Dockerfile new file mode 100644 index 0000000..2ec6502 --- /dev/null +++ b/docker/rabbitmq/Dockerfile @@ -0,0 +1,9 @@ +FROM rabbitmq:3.9-management + +RUN apt-get -o Acquire::Check-Date=false update && apt-get install -y curl + +RUN curl -L https://github.com/rabbitmq/rabbitmq-delayed-message-exchange/releases/download/3.9.0/rabbitmq_delayed_message_exchange-3.9.0.ez > $RABBITMQ_HOME/plugins/rabbitmq_delayed_message_exchange-3.9.0.ez + +RUN chown rabbitmq:rabbitmq $RABBITMQ_HOME/plugins/rabbitmq_delayed_message_exchange-3.9.0.ez + +RUN rabbitmq-plugins enable rabbitmq_delayed_message_exchange \ No newline at end of file diff --git a/docker/rocketmq/broker/conf/broker.conf b/docker/rocketmq/broker/conf/broker.conf new file mode 100644 index 0000000..a8f04e2 --- /dev/null +++ b/docker/rocketmq/broker/conf/broker.conf @@ -0,0 +1,7 @@ +brokerClusterName = DefaultCluster +brokerName = broker-a +brokerId = 0 +deleteWhen = 04 +fileReservedTime = 48 +brokerRole = ASYNC_MASTER +flushDiskType = ASYNC_FLUSH