Maven设置Dockerfile参数
项目中需要根据不同环境,镜像里tomct中catalina.sh里某个参数值也要不同。
项目中用了docker-maven-plugin插件管理docker,所以想到通过maven参数进行设置。
pom配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| # 在docker-maven-plugin插件中增加配置 <plugin> ... <configuration> ... <buildArgs> # 标签名为key,标签值为value <APP_NAME>${appName}</APP_NAME> </buildArgs> ... </configuration> ... </plugin>
# 环境配置 <profiles> <profile> <id>ci</id> <properties> <appName>hello-ci</appName> </properties> </profile> ... </profiles>
|
dockerfile配置
1 2 3 4 5
| ...
ARG APP_NAME
ENV CATALINA_OPTS -DapplicationName=$APP_NAME
|
one more thing
除了用docker插件,还可以是用exec插件,运行shell脚本或java文件,这种方式更自由一点。
Related Issues not found
Please contact @wonius to initialize the comment