deis / builder

Git server and application builder for Deis Workflow
https://deis.com
MIT License
40 stars 41 forks source link

Use build args to capture build time data #450

Open jchauncey opened 8 years ago

jchauncey commented 8 years ago

Acceptance Criteria:

You will need to do the following in the dockerfile to persist the data into the image:

ARG VERSION
ARG BUILD_DATE
ENV VERSION $VERSION
ENV BUILD_DATE $BUILD_DATE
jayjun commented 7 years ago

388 implies that config variables are available during Docker builds, but that's certainly untrue. However, naively passing all config variables to --build-args probably isn't wise.

Docker discourages,

using build-time variables for passing secrets like github keys, user credentials etc.

So I'm wondering how we can pass secrets to Docker builds as well. I have an actual need for this, related to integrating Google Cloud SQL.

bacongobbler commented 7 years ago

@jayjun I think you're talking about something else different. This issue is talking about passing in build args when we build the component itself, not the app. Apps are certainly passed in envvars during the build.

bacongobbler commented 7 years ago

See https://github.com/deis/builder/blob/master/pkg/gitreceive/build.go#L98-L102.

jayjun commented 7 years ago

@bacongobbler Yes, config variables are mapped to the build pod's env variables.

But running docker build doesn't automatically inject the surrounding pod's env variables into the app container that it's building (unlike buildpack shell scripts).

In fact, there's no way to add build-time environment variables until ARG was introduced.

bacongobbler commented 7 years ago

So, to clarify your request, you would like to have environment variables injected into the build environment when you are performing a git push with an app that uses a Dockerfile. Is that correct? I was unaware that we didn't already do that. That can easily be rectified. For reference we already do this for apps that rely on buildpacks.

If it is, can you open another ticket for that? That request is separate than what is requested here.

Cryptophobia commented 6 years ago

This issue was moved to teamhephy/builder#26