Using the maven plugin. How can I set environment variables within the container?
Also, when is 0.9.10 likely to be released as I need the label feature?
One workaround for now would be to build your own custom base image that preloads the environment variables you want and make Jib point to that base image. (Jib will propagate the env vars in the base image when building an image (https://github.com/GoogleContainerTools/jib/issues/595#issuecomment-410264838).)
Ok thanks, any idea when that feature might be added and when 0.9.10 is likely to be released?
@matt-shaw 0.9.10 should be released within the next day or two if all goes well.
@matt-shaw 0.9.10 has been released with labels support.
We were also wondering why you'd like to set environment variables through the plugin at build time rather than during deployment?
We change the behaviour of the spring boot application using environment variables. Some of these variables are set when the app is run via docker and others when it鈥檚 run as a stand-alone java app. To be honest it鈥檚 also in the docker spec so would be nice to be able to set them. We use the alpine-jre base image.
That's an interesting use case and we're currently discussing adding this in because it's in the docker spec.
Just out of curiousity:
docker run -e WHATEVER=whateverNo, it鈥檚 not really runtime dependent, more build time, I.e. it鈥檚 set because it鈥檚 run in docker and doesn鈥檛 change at runtime.
@matt-shaw We have released version 0.9.11 with the <container><environment> configuration for setting environment variables!
Hey @coollog. Thanks a lot for making that nice tool! But have u tested the <container><environment> configuration cause I have the following config:
...
<container>
<environment>
<var-1>123</var-1>
<var-2>456</var-2>
</environment>
</container>
...
And after executing mvn jib:exportDockerContext in the resulting Dockerfile I don't see ENV declarations.
Hi @dzmitryh , thanks for catching this bug! Looks like we did not attach the ENV generator to the docker context goals/tasks. We will definitely add this in and release a fix in version 0.9.12 soon. In the meantime, the Jib image builds should work (jib:build/jib:dockerBuild) with environment variables.
Update: the docker context problem has been fixed and will be available in v0.9.13 (already released for Gradle, working on Maven and should be released either later today or tomorrow).
@dzmitryh jib-maven-plugin version 0.9.13 is released with the fix for adding the environment definitions to the exported Dockerfile!
Most helpful comment
@dzmitryh
jib-maven-pluginversion0.9.13is released with the fix for adding the environment definitions to the exported Dockerfile!