Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bake: initial implementation #16

Merged
merged 4 commits into from
Apr 10, 2019
Merged

bake: initial implementation #16

merged 4 commits into from
Apr 10, 2019

Conversation

tonistiigi
Copy link
Member

@tonistiigi tonistiigi commented Apr 10, 2019

Initial implementation for #13 (formely buildfile)

Testing:

> make
cd compose
docker buildx bake
docker buildx bake -f config.hcl release
docker buildx bake -f config.hcl --set db.args.FOO=bar release
# see config.hcl for full data format
# --print shows the parameters that would be used by individual builds without invoking it

The compose part is pretty basic and should work as expected. The full internal datastructure for defining targets probably needs some design work and doesn't look right to me.

Alternative designs:

group "default" {
	targets = ["db", "webapp"]
}


target "%-cross" {
	platforms = [
		"linux/amd64",
		"linux/arm64"
	]
}

---
docker buildx bake default-cross
target "default" {
	targets = ["db", "webapp"]
}

target "default-cross" {
	targets = ["db", "webapp-cross"]
}

target "webapp" {
	context = "./"
	dockerfile = "Dockerfile.webapp"
	args = {
		buildno = "123"
	}
}
group "default" {
	targets = ["db", "webapp"]
}

group "default-cross" {
        inherits = ["cross"]
	targets = ["db", "webapp"]
}
target "cross" {
	platforms = [
		"linux/amd64",
		"linux/arm64"
	]
}

---
docker buildx bake default-cross

Outputs not supported yet, thinking if this should be per target or global.

@tiborvass @AkihiroSuda @seemethere @dmcgowan

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
@AkihiroSuda
Copy link
Collaborator

Looks good, but why HCL?

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
@tonistiigi
Copy link
Member Author

@AkihiroSuda I don't really care about the format that much. Could accept anything that we can parse. You can use JSON as well (and thinking if we should allow json5). Examples use HCL cause I personally found it more readable and better than toml on comparisons. I'm not a big fan of yaml but the main thing is that I'd want to avoid something that looks like compose but isn't compose. Atm. bake accepts vanilla compose with no changes and I think we should keep it this way. If you want you can use compose with the override logic as well. If you as a user like yaml and compose already you can just keep using that and never care about the other formats.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
@tonistiigi
Copy link
Member Author

updated buildkit to bring in moby/buildkit#929

return ParseHCL(dt)
}

cfg, err := ParseCompose(dt)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there compose files without .yml or .yaml suffixes? Why not error out?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea. Does compose force you to use .yml suffix currently, I think not.

Tags: t.Tags,
BuildArgs: t.Args,
Labels: t.Labels,
// CacheFrom: t.CacheFrom,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key does not exist atm. but should later.

commands/bake.go Outdated Show resolved Hide resolved
commands/bake.go Outdated Show resolved Hide resolved
commands/bake.go Outdated Show resolved Hide resolved
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Copy link

@seemethere seemethere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@tonistiigi tonistiigi merged commit e552d50 into master Apr 10, 2019
@tonistiigi tonistiigi mentioned this pull request Apr 15, 2019
@tiborvass tiborvass deleted the bake branch April 25, 2019 03:25
@FernandoMiguel
Copy link
Contributor

@tonistiigi what ever happened to --set db.args.FOO=bar ?

@tonistiigi
Copy link
Member Author

@FernandoMiguel wdym?

@FernandoMiguel
Copy link
Contributor

@FernandoMiguel wdym?

@tonistiigi in the OP example
docker buildx bake -f config.hcl --set db.args.FOO=bar release

I'm trying to pass args to my buildx

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

Successfully merging this pull request may close these issues.

5 participants