7
1、maven编译,不再需要为每个config环境都修改build.sh(bat),只需要进行一次maven编译。一次docker打包。
2、原本需要再build.sh(bat)中配置的参数 portal 的数据库连接信息、config和admin的数据库连接信息、metaserver信息,都将不需要了。
3、这些信息,都提取到环境变量中来配置。不管你是普通部署还是docker部署,都可以通过环境变量来配置信息。
完全杜绝同环境不同包的问题。一次编译,多次运行!
下面是一个完全通过env配置的docker-compose.yml示例,包括了数据库和MetaServer的配置:
version: '3'
services:
apollo-portal:
image: docker.io/xzxiaoshan/apollo-portal:1.4.0
container_name: apollo-portal
network_mode: "host"
environment:
SERVER_PORT: 5555
# DataSource Info
DS_URL: "jdbc:mysql://pro.shanhy.com:3306/ApolloPortalDB?characterEncoding=utf8"
DS_USERNAME: "shanhy"
DS_PASSWORD: "xzxiaoshan@123"
# Environmental variable declaration (meta server url, different environments should have different meta server addresses)
DEV_META: "http://dev.shanhy.com:6666"
FAT_META: ""
UAT_META: ""
LPT_META: ""
PRO_META: "http://pro.shanhy.com:6666"
depends_on:
- apollo-adminservice
logging:
driver: "json-file"
options:
max-size: "200k"
max-file: "10"
apollo-configservice:
image: docker.io/xzxiaoshan/apollo-configservice:1.4.0
container_name: apollo-configservice
network_mode: "host"
environment:
SERVER_PORT: 6666
# DataSource Info
DS_URL: "jdbc:mysql://pro.shanhy.com:3306/ApolloConfigDB?characterEncoding=utf8"
DS_USERNAME: "shanhy"
DS_PASSWORD: "xzxiaoshan@123"
logging:
driver: "json-file"
options:
max-size: "200k"
max-file: "10"
apollo-adminservice:
image: docker.io/xzxiaoshan/apollo-adminservice:1.4.0
container_name: apollo-adminservice
network_mode: "host"
environment:
SERVER_PORT: 6667
# DataSource Info
DS_URL: "jdbc:mysql://pro.shanhy.com:3306/ApolloConfigDB?characterEncoding=utf8"
DS_USERNAME: "shanhy"
DS_PASSWORD: "xzxiaoshan@123"
depends_on:
- apollo-configservice
logging:
driver: "json-file"
options:
max-size: "200k"
max-file: "10"