Skip to content
This repository has been archived by the owner on Oct 2, 2023. It is now read-only.

support build stamp with docker_push #3

Closed
mikedanese opened this issue Apr 12, 2017 · 8 comments
Closed

support build stamp with docker_push #3

mikedanese opened this issue Apr 12, 2017 · 8 comments
Assignees

Comments

@mikedanese
Copy link

I should be able to use a variable from my workspace status to tag a docker image when running docker_push.

@mattmoor
Copy link
Contributor

docker_push supports make-style expansion for the components:

vardef("MY_TAG", "latest")

docker_push(
    name = "foo_push",
    image = ":foo_image",
    registry = "gcr.io",
    repository = "foo/bar/baz",
    tag = "$(MY_TAG)",
)

Or is that not what you want?

@mattmoor
Copy link
Contributor

@damienmg How can I access this in skylark?

@mattmoor
Copy link
Contributor

Ok, blocked by: bazelbuild/bazel#1054

@ixdy
Copy link
Contributor

ixdy commented Apr 26, 2017

Similar / clarifying request: I'd like to be able to tag an image automatically using the git sha of the workspace. We use --workspace_status_command to set this for go rules, but there's currently no way to use that in docker rules.

Make-style expansion isn't ideal, since that requires adding --defines to the bazel command line.

@mattmoor
Copy link
Contributor

In other places we allow @foo to load the value from a file. I wonder if this would be sufficient for your purposes?

@ixdy
Copy link
Contributor

ixdy commented Apr 26, 2017

That might work. I implemented a hack (ixdy/bazel@3b29803) to do that a few months ago, and it's what the kubernetes bazel build is currently using, though it still feels pretty hacky

(I got preoccupied with other things and didn't follow up on some review feedback, and now things have moved around a bit so I'd need to rebase my change.)

The go rules got around waiting for Skylark support (bazelbuild/bazel#1054) by implementing stamping through reading the ctx.info_file and ctx.version_file directly.

Since IIRC most of the actual docker image/layer-building implementation happens in python, I wonder if we could do something similar and have the info/version files passed through to the scripts on stamp=1?
I haven't thought through all of the implications yet, or if the rules will work correctly with unexpanded variables in skylark.

@mikedanese
Copy link
Author

Is this fixed?

@mattmoor
Copy link
Contributor

mattmoor commented May 4, 2017

docker_push doesn't support it, but docker_bundle does.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants