-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
一个docker包,支持部署无数个环境。不再需要不同环境打不同的包。 #2343
Conversation
…定端口,避免与宿主机上的原有端口占用冲突 2.对docker CMD入口的startup.sh文件,增加可执行授权指令,防止在某些时候该文件被打包进入后没有执行权限的麻烦(已实际遇到,又回头重新打包)
2、原本需要再build.sh(bat)中配置的参数 portal 的数据库连接信息、config和admin的数据库连接信息、metaserver信息,都将不需要了。 3、这些信息,都提取到环境变量中来配置。不管你是普通部署还是docker部署,都可以通过环境变量来配置信息。 完全杜绝同环境不同包的问题。一次编译,多次运行!
------------------------------------------------------------------------------------------ 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/ApolloPortalDB?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/ApolloPortalDB?characterEncoding=utf8" DS_USERNAME: "shanhy" DS_PASSWORD: "xzxiaoshan@123" depends_on: - apollo-configservice logging: driver: "json-file" options: max-size: "200k" max-file: "10"
如果用户没有做任何配置,从使用角度来说其使用方法和结果与本次修改前一样。本次修改是一种完全兼容式修改。无任何副作用。 |
示例 docker-compose.yml 中的dockerhub镜像,是基于1.4.0 tag+fork修改后(pull request是master),直接build打包的。未做任何二次配置。打包后直接docker-compose直接使用。也就是说,打包前0配置,打包后通过环境变量配置。 |
代码有冲突,麻烦解决一下 |
冲突已处理 |
Codecov Report
@@ Coverage Diff @@
## master #2343 +/- ##
============================================
- Coverage 50.05% 49.97% -0.08%
+ Complexity 1992 1990 -2
============================================
Files 404 404
Lines 12429 12429
Branches 1275 1275
============================================
- Hits 6221 6212 -9
- Misses 5765 5773 +8
- Partials 443 444 +1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
1、maven编译,不再需要为每个config环境都修改build.sh(bat),只需要进行一次maven编译。一次docker打包。
2、原本需要再build.sh(bat)中配置的参数 portal 的数据库连接信息、config和admin的数据库连接信息、metaserver信息,都将不需要了。
3、这些信息,都提取到环境变量中来配置。不管你是普通部署还是docker部署,都可以通过环境变量来配置信息。
完全杜绝同环境不同包的问题。一次编译,多次运行!
下面是一个完全通过env配置的docker-compose.yml示例,包括了数据库和MetaServer的配置: