@@ -45,8 +45,8 @@ variable "DISTROS" {
4545 ]
4646}
4747
48- variable "PKGS " {
49- description = " List of packages to build from ./pkg directory. Don't forget to update _pkg-* target if you add/remove a package ."
48+ variable "PKGS_BASE " {
49+ description = " Base list of packages built from this repo. Use PKGS_EXTRA in an override file to add downstream packages ."
5050 default = [
5151 " buildx" ,
5252 " compose" ,
@@ -59,6 +59,49 @@ variable "PKGS" {
5959 ]
6060}
6161
62+ variable "PKGS_EXTRA" {
63+ description = " Additional packages to append from an override bake definition."
64+ default = []
65+ }
66+
67+ variable "PKGS" {
68+ description = " Full list of packages to build from ./pkg directory or an override-provided package context."
69+ default = concat (PKGS_BASE, PKGS_EXTRA)
70+ }
71+
72+ variable "PKG_PLATFORMS_BASE" {
73+ description = " Base package platform mapping. Use PKG_PLATFORMS_EXTRA in an override bake definition to add downstream packages."
74+ default = {
75+ # https://github.com/docker/buildx/blob/0c747263ef1426f5fa217fcdb616eddf33da6c2d/docker-bake.hcl#L156-L174
76+ buildx = [" darwin/amd64" , " darwin/arm64" , " linux/amd64" , " linux/arm/v6" , " linux/arm/v7" , " linux/arm64" , " linux/ppc64le" , " linux/riscv64" , " linux/s390x" , " windows/amd64" , " windows/arm64" ]
77+ # https://github.com/docker/compose/blob/c626befee1596abcc74578cb10dd96ae1667f76f/docker-bake.hcl#L112-L124
78+ compose = [" darwin/amd64" , " darwin/arm64" , " linux/amd64" , " linux/arm/v6" , " linux/arm/v7" , " linux/arm64" , " linux/ppc64le" , " linux/riscv64" , " linux/s390x" , " windows/amd64" , " windows/arm64" ]
79+ # https://github.com/containerd/containerd/blob/e373060a953aeaa35554e2f667043fed73ff6248/.github/workflows/ci.yml#L142-L162
80+ # https://github.com/containerd/containerd/blob/e373060a953aeaa35554e2f667043fed73ff6248/.github/workflows/ci.yml#L133-L134
81+ containerd = [" linux/amd64" , " linux/arm/v6" , " linux/arm/v7" , " linux/arm64" , " linux/ppc64le" , " linux/s390x" , " windows/amd64" , " windows/arm64" ]
82+ # https://github.com/docker/docker-credential-helpers/blob/f9d3010165b642df37215b1be945552f2c6f0e3b/docker-bake.hcl#L56-L66
83+ credential-helpers = [" darwin/amd64" , " darwin/arm64" , " linux/amd64" , " linux/arm/v6" , " linux/arm/v7" , " linux/arm64" , " linux/ppc64le" , " linux/s390x" , " windows/amd64" ]
84+ # https://github.com/docker/cli/blob/84038691220e7ba3329a177e4e3357b4ee0e3a52/docker-bake.hcl#L30-L42
85+ docker-cli = [" darwin/amd64" , " darwin/arm64" , " linux/386" , " linux/amd64" , " linux/arm/v6" , " linux/arm/v7" , " linux/arm64" , " linux/ppc64le" , " linux/riscv64" , " linux/s390x" , " windows/amd64" , " windows/arm64" ]
86+ # https://github.com/moby/moby/blob/83264918d3e1c61341511e360a7277150b914b3f/docker-bake.hcl#L82-L91
87+ docker-engine = [" linux/amd64" , " linux/arm/v6" , " linux/arm/v7" , " linux/arm64" , " linux/ppc64le" , " linux/s390x" , " windows/amd64" , " windows/arm64" ]
88+ # https://github.com/docker/model-runner/blob/039f7a31c0365f9161c9b9b6bb3888161d16e388/cmd/cli/Makefile#L39-L43
89+ model = [" darwin/amd64" , " darwin/arm64" , " linux/amd64" , " linux/arm64" , " linux/arm/v7" , " windows/amd64" , " windows/arm64" ]
90+ # https://github.com/docker/docker-agent/blob/5b9feaabe743a5ad577f2247ed55d5dcb2678e8b/Taskfile.yml#L79
91+ agent = [" darwin/amd64" , " darwin/arm64" , " linux/amd64" , " linux/arm64" , " windows/amd64" , " windows/arm64" ]
92+ }
93+ }
94+
95+ variable "PKG_PLATFORMS_EXTRA" {
96+ description = " Additional package platform mapping to merge from an override bake definition."
97+ default = {}
98+ }
99+
100+ variable "PKG_CONTEXTS_EXTRA" {
101+ description = " Additional package context mapping to merge from an override bake definition."
102+ default = {}
103+ }
104+
62105variable "DISTRO_NAME" {
63106 description = " Name of the distro."
64107 default = null
@@ -631,25 +674,12 @@ target "_pkg-agent" {
631674# Returns the list of supported platforms for a given package.
632675function "pkgPlatforms" {
633676 params = [pkg ]
634- result = lookup ({
635- # https://github.com/docker/buildx/blob/0c747263ef1426f5fa217fcdb616eddf33da6c2d/docker-bake.hcl#L156-L174
636- buildx = [" darwin/amd64" , " darwin/arm64" , " linux/amd64" , " linux/arm/v6" , " linux/arm/v7" , " linux/arm64" , " linux/ppc64le" , " linux/riscv64" , " linux/s390x" , " windows/amd64" , " windows/arm64" ]
637- # https://github.com/docker/compose/blob/c626befee1596abcc74578cb10dd96ae1667f76f/docker-bake.hcl#L112-L124
638- compose = [" darwin/amd64" , " darwin/arm64" , " linux/amd64" , " linux/arm/v6" , " linux/arm/v7" , " linux/arm64" , " linux/ppc64le" , " linux/riscv64" , " linux/s390x" , " windows/amd64" , " windows/arm64" ]
639- # https://github.com/containerd/containerd/blob/e373060a953aeaa35554e2f667043fed73ff6248/.github/workflows/ci.yml#L142-L162
640- # https://github.com/containerd/containerd/blob/e373060a953aeaa35554e2f667043fed73ff6248/.github/workflows/ci.yml#L133-L134
641- containerd = [" linux/amd64" , " linux/arm/v6" , " linux/arm/v7" , " linux/arm64" , " linux/ppc64le" , " linux/s390x" , " windows/amd64" , " windows/arm64" ]
642- # https://github.com/docker/docker-credential-helpers/blob/f9d3010165b642df37215b1be945552f2c6f0e3b/docker-bake.hcl#L56-L66
643- credential-helpers = [" darwin/amd64" , " darwin/arm64" , " linux/amd64" , " linux/arm/v6" , " linux/arm/v7" , " linux/arm64" , " linux/ppc64le" , " linux/s390x" , " windows/amd64" ]
644- # https://github.com/docker/cli/blob/84038691220e7ba3329a177e4e3357b4ee0e3a52/docker-bake.hcl#L30-L42
645- docker-cli = [" darwin/amd64" , " darwin/arm64" , " linux/386" , " linux/amd64" , " linux/arm/v6" , " linux/arm/v7" , " linux/arm64" , " linux/ppc64le" , " linux/riscv64" , " linux/s390x" , " windows/amd64" , " windows/arm64" ]
646- # https://github.com/moby/moby/blob/83264918d3e1c61341511e360a7277150b914b3f/docker-bake.hcl#L82-L91
647- docker-engine = [" linux/amd64" , " linux/arm/v6" , " linux/arm/v7" , " linux/arm64" , " linux/ppc64le" , " linux/s390x" , " windows/amd64" , " windows/arm64" ]
648- # https://github.com/docker/model-runner/blob/039f7a31c0365f9161c9b9b6bb3888161d16e388/cmd/cli/Makefile#L39-L43
649- model = [" darwin/amd64" , " darwin/arm64" , " linux/amd64" , " linux/arm64" , " linux/arm/v7" , " windows/amd64" , " windows/arm64" ]
650- # https://github.com/docker/docker-agent/blob/5b9feaabe743a5ad577f2247ed55d5dcb2678e8b/Taskfile.yml#L79
651- agent = [" darwin/amd64" , " darwin/arm64" , " linux/amd64" , " linux/arm64" , " windows/amd64" , " windows/arm64" ]
652- }, pkg, [])
677+ result = lookup (merge (PKG_PLATFORMS_BASE, PKG_PLATFORMS_EXTRA), pkg, [])
678+ }
679+
680+ function "pkgContext" {
681+ params = [pkg ]
682+ result = lookup (PKG_CONTEXTS_EXTRA, pkg, " ./pkg/${ pkg } " )
653683}
654684
655685#
@@ -694,7 +724,7 @@ target "pkg" {
694724 pkg = PKGS
695725 distro = DISTROS
696726 }
697- context = " ./ pkg/ ${ pkg } "
727+ context = pkgContext ( pkg)
698728 contexts = {
699729 scripts = " ./hack/scripts"
700730 }
@@ -717,7 +747,7 @@ target "verify" {
717747 pkg = PKGS
718748 distro = DISTROS
719749 }
720- context = " ./ pkg/ ${ pkg } "
750+ context = pkgContext ( pkg)
721751 dockerfile = " verify.Dockerfile"
722752 contexts = {
723753 scripts = " ./hack/scripts"
@@ -750,7 +780,7 @@ target "metadata" {
750780 matrix = {
751781 pkg = PKGS
752782 }
753- context = " ./ pkg/ ${ pkg } "
783+ context = pkgContext ( pkg)
754784 contexts = {
755785 scripts = " ./hack/scripts"
756786 }
0 commit comments