16
如何打包一个镜像三个环境都可以使用?
source link: https://www.v2ex.com/t/790104
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
如何打包一个镜像三个环境都可以使用? - V2EX
有个 Java 项目,代码里面有个配置文件写死了 nacos 配置中心的地址以及一些其它参数,如何构建镜像才能实现三个不同的环境使用?或者有没有更灵活的办法呢?
比如三个环境的 nacos 地址
Uat 环境 nacos 地址 uat.nacos.com
Stag 环境 nacos 地址 stag.nacos.com
Prod 环境 nacos 地址 prod.nacos.com
12 条回复 • 2021-07-17 23:10:11 +08:00
creanme 6 小时 34 分钟前
蹭主题,顺便问问前端如何打包一次,能在两个环境中使用。代码中有调用其它系统接口,测试环境和生产环境接口不同。之前要么在本地或者 pipeline 中打包两次,分别对应测试环境和生产环境,或者在代码里面根据当前域名来判断是否是生产环境,不过都不太好的样子。
xuanbg 5 小时 33 分钟前 1
JAVA_OPTIONS="-Dspring.profiles.active=prod"
JAVA_OPTIONS="-Dspring.profiles.active=stag"
JAVA_OPTIONS="-Dspring.profiles.active=stag"
zhzy0077 4 小时 27 分钟前
所有环境相关的配置,比如数据库连接,配置中心啥的,都应该是容器 /代码无关的,一般是通过环境变量拿进去。
12 factor app 可以看看: III. Config
Store config in the environment
12 factor app 可以看看: III. Config
Store config in the environment
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK