Docker Compose 支持

This commit is contained in:
陈泉 2022-03-30 15:00:57 +08:00
parent bb149173ea
commit d565b50905
9 changed files with 437 additions and 35 deletions

6
.gitignore vendored
View File

@ -52,4 +52,8 @@ unpackage/
.vscode/ .vscode/
# [mac] # [mac]
.DS_Store .DS_Store
docker/rocketmq/broker/logs/
docker/rocketmq/broker/store/
docker/rocketmq/namesrv/

View File

@ -30,9 +30,9 @@ spring:
number_format: '#' #数字格式进行原样显示,不加格式化字符例如 100,00 number_format: '#' #数字格式进行原样显示,不加格式化字符例如 100,00
datasource: datasource:
# yml填写url连接串 无需将&符号进行转义 # yml填写url连接串 无需将&符号进行转义
url: jdbc:mysql://127.0.0.1:3306/jeepaydb?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true url: jdbc:mysql://172.20.0.10:3306/jeepaydb?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true
username: root username: jeepay
password: password: jeepay
druid: druid:
# 连接池配置项 # 连接池配置项
initial-size: 5 #初始化时建立物理连接的个数 initial-size: 5 #初始化时建立物理连接的个数
@ -55,7 +55,7 @@ spring:
cache: cache:
type: redis type: redis
redis: redis:
host: 127.0.0.1 host: 172.20.0.12
port: 6379 port: 6379
database: 1 #1库运营平台 #2库商户系统 #3库支付网关 database: 1 #1库运营平台 #2库商户系统 #3库支付网关
timeout: 1000 timeout: 1000
@ -63,7 +63,7 @@ spring:
# #activeMQ配置 ( 注意: activeMQ配置项需在spring的下级 ) # #activeMQ配置 ( 注意: activeMQ配置项需在spring的下级 )
activemq: 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项目不可使用内存模式 需要连接多个消费者。 in-memory: false # Jeepay项目不可使用内存模式 需要连接多个消费者。
user: system # activeMQ默认无需账密认证。 打开认证activemq.xml添加simpleAuthenticationPlugin标签账密在credentials.properties文件。 user: system # activeMQ默认无需账密认证。 打开认证activemq.xml添加simpleAuthenticationPlugin标签账密在credentials.properties文件。
password: manager password: manager
@ -74,17 +74,18 @@ spring:
# #
# #rabbitmq配置 ( 注意: rabbitmq配置项需在spring的下级 ) # #rabbitmq配置 ( 注意: rabbitmq配置项需在spring的下级 )
# rabbitmq: # rabbitmq:
# addresses: 127.0.0.1:5672 # addresses: 172.20.0.11:5672
# username: guest # username: admin
# password: guest # password: admin
# dynamic: true # dynamic: true
# virtual-host: / # virtual-host: jeepay
## rocketmq配置 ( 注意rocketmq配置项请放置到根目录 不是spring的二级配置 ) ## rocketmq配置 ( 注意rocketmq配置项请放置到根目录 不是spring的二级配置 )
#rocketmq: rocketmq:
# name-server: 127.0.0.1:9876 name-server: 172.20.0.11:9876
# producer: producer:
# group: JEEPAY-GROUP group: JEEPAY-GROUP
## 阿里云rocketmq配置 ( 注意aliyun-rocketmq配置项请放置到根目录 不是spring的二级配置需要阿里云开通rocketMQ产品创建Group和Topic ) ## 阿里云rocketmq配置 ( 注意aliyun-rocketmq配置项请放置到根目录 不是spring的二级配置需要阿里云开通rocketMQ产品创建Group和Topic )
#aliyun-rocketmq: #aliyun-rocketmq:

View File

@ -30,9 +30,9 @@ spring:
number_format: '#' #数字格式进行原样显示,不加格式化字符例如 100,00 number_format: '#' #数字格式进行原样显示,不加格式化字符例如 100,00
datasource: datasource:
# yml填写url连接串 无需将&符号进行转义 # yml填写url连接串 无需将&符号进行转义
url: jdbc:mysql://127.0.0.1:3306/jeepaydb?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true url: jdbc:mysql://172.20.0.10:3306/jeepaydb?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true
username: root username: jeepay
password: password: jeepay
druid: druid:
# 连接池配置项 # 连接池配置项
initial-size: 5 #初始化时建立物理连接的个数 initial-size: 5 #初始化时建立物理连接的个数
@ -55,7 +55,7 @@ spring:
cache: cache:
type: redis type: redis
redis: redis:
host: 127.0.0.1 host: 172.20.0.12
port: 6379 port: 6379
database: 2 #1库运营平台 #2库商户系统 #3库支付网关 database: 2 #1库运营平台 #2库商户系统 #3库支付网关
timeout: 1000 timeout: 1000
@ -63,7 +63,7 @@ spring:
# #activeMQ配置 ( 注意: activeMQ配置项需在spring的下级 ) # #activeMQ配置 ( 注意: activeMQ配置项需在spring的下级 )
activemq: 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项目不可使用内存模式 需要连接多个消费者。 in-memory: false # Jeepay项目不可使用内存模式 需要连接多个消费者。
user: system # activeMQ默认无需账密认证。 打开认证activemq.xml添加simpleAuthenticationPlugin标签账密在credentials.properties文件。 user: system # activeMQ默认无需账密认证。 打开认证activemq.xml添加simpleAuthenticationPlugin标签账密在credentials.properties文件。
password: manager password: manager
@ -74,15 +74,16 @@ spring:
# #
# #rabbitmq配置 ( 注意: rabbitmq配置项需在spring的下级 ) # #rabbitmq配置 ( 注意: rabbitmq配置项需在spring的下级 )
# rabbitmq: # rabbitmq:
# addresses: 127.0.0.1:5672 # addresses: 172.20.0.11:5672
# username: guest # username: admin
# password: guest # password: admin
# dynamic: true # dynamic: true
# virtual-host: / # virtual-host: jeepay
## rocketmq配置 ( 注意rocketmq配置项请放置到根目录 不是spring的二级配置 ) ## rocketmq配置 ( 注意rocketmq配置项请放置到根目录 不是spring的二级配置 )
#rocketmq: #rocketmq:
# name-server: 127.0.0.1:9876 # name-server: 172.20.0.11:9876
# producer: # producer:
# group: JEEPAY-GROUP # group: JEEPAY-GROUP

View File

@ -30,9 +30,9 @@ spring:
number_format: '#' #数字格式进行原样显示,不加格式化字符例如 100,00 number_format: '#' #数字格式进行原样显示,不加格式化字符例如 100,00
datasource: datasource:
# yml填写url连接串 无需将&符号进行转义 # yml填写url连接串 无需将&符号进行转义
url: jdbc:mysql://127.0.0.1:3306/jeepaydb?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true url: jdbc:mysql://172.20.0.10:3306/jeepaydb?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true
username: root username: jeepay
password: password: jeepay
druid: druid:
# 连接池配置项 # 连接池配置项
initial-size: 5 #初始化时建立物理连接的个数 initial-size: 5 #初始化时建立物理连接的个数
@ -55,7 +55,7 @@ spring:
cache: cache:
type: redis type: redis
redis: redis:
host: 127.0.0.1 host: 172.20.0.12
port: 6379 port: 6379
database: 3 #1库运营平台 #2库商户系统 #3库支付网关 database: 3 #1库运营平台 #2库商户系统 #3库支付网关
timeout: 1000 timeout: 1000
@ -63,7 +63,7 @@ spring:
# #activeMQ配置 ( 注意: activeMQ配置项需在spring的下级 ) # #activeMQ配置 ( 注意: activeMQ配置项需在spring的下级 )
activemq: 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项目不可使用内存模式 需要连接多个消费者。 in-memory: false # Jeepay项目不可使用内存模式 需要连接多个消费者。
user: system # activeMQ默认无需账密认证。 打开认证activemq.xml添加simpleAuthenticationPlugin标签账密在credentials.properties文件。 user: system # activeMQ默认无需账密认证。 打开认证activemq.xml添加simpleAuthenticationPlugin标签账密在credentials.properties文件。
password: manager password: manager
@ -74,17 +74,16 @@ spring:
# #
# #rabbitmq配置 ( 注意: rabbitmq配置项需在spring的下级 ) # #rabbitmq配置 ( 注意: rabbitmq配置项需在spring的下级 )
# rabbitmq: # rabbitmq:
# addresses: 127.0.0.1:5672 # addresses: 172.20.0.11:5672
# username: guest # username: admin
# password: guest # password: admin
# dynamic: true # dynamic: true
# virtual-host: / # virtual-host: jeepay
## rocketmq配置 ( 注意rocketmq配置项请放置到根目录 不是spring的二级配置 ) ## rocketmq配置 ( 注意rocketmq配置项请放置到根目录 不是spring的二级配置 )
#rocketmq: #rocketmq:
# name-server: 127.0.0.1:9876 # name-server: 172.20.0.11:9876
# producer: # producer:
# group: JEEPAY-GROUP
## 阿里云rocketmq配置 ( 注意aliyun-rocketmq配置项请放置到根目录 不是spring的二级配置需要阿里云开通rocketMQ产品创建Group和Topic ) ## 阿里云rocketmq配置 ( 注意aliyun-rocketmq配置项请放置到根目录 不是spring的二级配置需要阿里云开通rocketMQ产品创建Group和Topic )
#aliyun-rocketmq: #aliyun-rocketmq:

197
docker-compose.yml Normal file
View File

@ -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:

View File

@ -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"]

View File

@ -0,0 +1,160 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- START SNIPPET: example -->
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
<!-- Allows us to use system properties as variables in this configuration file -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>file:${activemq.conf}/credentials.properties</value>
</property>
</bean>
<!-- Allows accessing the server log -->
<bean id="logQuery" class="io.fabric8.insight.log.log4j.Log4jLogQuery"
lazy-init="false" scope="singleton"
init-method="start" destroy-method="stop">
</bean>
<!--
The <broker> element is used to configure the ActiveMQ broker.
-->
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.data}">
<destinationPolicy>
<policyMap>
<policyEntries>
<policyEntry topic=">">
<!-- The constantPendingMessageLimitStrategy is used to prevent
slow topic consumers to block producers and affect other consumers
by limiting the number of messages that are retained
For more information, see:
http://activemq.apache.org/slow-consumer-handling.html
-->
<pendingMessageLimitStrategy>
<constantPendingMessageLimitStrategy limit="1000"/>
</pendingMessageLimitStrategy>
</policyEntry>
</policyEntries>
</policyMap>
</destinationPolicy>
<!--
The managementContext is used to configure how ActiveMQ is exposed in
JMX. By default, ActiveMQ uses the MBean server that is started by
the JVM. For more information, see:
http://activemq.apache.org/jmx.html
-->
<managementContext>
<managementContext createConnector="false"/>
</managementContext>
<!--
Configure message persistence for the broker. The default persistence
mechanism is the KahaDB store (identified by the kahaDB tag).
For more information, see:
http://activemq.apache.org/persistence.html
-->
<persistenceAdapter>
<kahaDB directory="${activemq.data}/kahadb"/>
</persistenceAdapter>
<!--
The systemUsage controls the maximum amount of space the broker will
use before disabling caching and/or slowing down producers. For more information, see:
http://activemq.apache.org/producer-flow-control.html
-->
<systemUsage>
<systemUsage>
<memoryUsage>
<memoryUsage percentOfJvmHeap="70"/>
</memoryUsage>
<storeUsage>
<storeUsage limit="100 gb"/>
</storeUsage>
<tempUsage>
<tempUsage limit="50 gb"/>
</tempUsage>
</systemUsage>
</systemUsage>
<!--
The transport connectors expose ActiveMQ over a given protocol to
clients and other brokers. For more information, see:
http://activemq.apache.org/configuring-transports.html
-->
<transportConnectors>
<!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
<transportConnector name="openwire"
uri="tcp://0.0.0.0:61616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
<transportConnector name="amqp"
uri="amqp://0.0.0.0:5672?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
<transportConnector name="stomp"
uri="stomp://0.0.0.0:61613?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
<transportConnector name="mqtt"
uri="mqtt://0.0.0.0:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
<transportConnector name="ws"
uri="ws://0.0.0.0:61614?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
</transportConnectors>
<!-- destroy the spring context on shutdown to stop jetty -->
<shutdownHooks>
<bean xmlns="http://www.springframework.org/schema/beans"
class="org.apache.activemq.hooks.SpringContextHook"/>
</shutdownHooks>
<!-- Add AuthenticationPlugin -->
<plugins>
<!-- 简单认证插件 -->
<simpleAuthenticationPlugin>
<users>
<authenticationUser username="test" password="test" groups="users,admins"/>
<authenticationUser username="system" password="manager" groups="users,admins"/>
<authenticationUser username="user" password="password" groups="users"/>
<authenticationUser username="guest" password="password" groups="guests"/>
</users>
</simpleAuthenticationPlugin>
<!-- JAAS认证插件
<jaasAuthenticationPlugin configuration="activemq-domain" />
-->
</plugins>
</broker>
<!--
Enable web consoles, REST and Ajax APIs and demos
The web consoles requires by default login, you can disable this in the jetty.xml file
Take a look at ${ACTIVEMQ_HOME}/conf/jetty.xml for more details
-->
<import resource="jetty.xml"/>
</beans>
<!-- END SNIPPET: example -->

View File

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

View File

@ -0,0 +1,7 @@
brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH