Passing environment variables to build

Is there any way to pass environment variables or args to the docker build step? If we had this we could templatize the build process so that those could be passed to docker build env or args.

Thank you!


Not currently. I’d support any PRs that work towards this.

Ok i just discovered waypoint config command. Those dont get passed to the docker or packer build?

These are only for the deployment environment.

And to clarify my previous: I’d support any work towards adding env var support specifically to Docker because I think many Dockerfiles utilize env vars.

Ok thanks for the reply. Yep we need to pass environment variable so that during the build process the it can use those variables to point to the correct backend for example.

1 Like

Not exactly but there’s some workarounds.
Inside your .hcl file, on the build step simply assign some value like this:

use "docker" {
  dockerfile = templatefile("${}/Dockerfile", {
    # Values I wanna send to Dockerfile
    my_arg1 = "strawberry"
    my_arg2 = "banana"

And then recover the variables on the Dockerfile like this:

ENV my_arg1=${my_arg1}
ENV my_arg2=${my_arg2}
1 Like

Hey, guys, I’ve created a pull request to implement this. This is my first Open Source contribution, so I would be happy to adjust as needed. docker: support build args by psihachina · Pull Request #1346 · hashicorp/waypoint · GitHub Please let me know if this needs any additional work or it can be merged as-is.