docker-bake.hcl 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. variable "APT_MIRROR" {
  2. default = ""
  3. }
  4. variable "DOCKER_DEBUG" {
  5. default = ""
  6. }
  7. variable "DOCKER_STATIC" {
  8. default = "1"
  9. }
  10. variable "DOCKER_LDFLAGS" {
  11. default = ""
  12. }
  13. variable "DOCKER_BUILDTAGS" {
  14. default = ""
  15. }
  16. variable "DOCKER_GITCOMMIT" {
  17. default = "HEAD"
  18. }
  19. # Docker version such as 23.0.0-dev. Automatically generated through Git ref.
  20. variable "VERSION" {
  21. default = ""
  22. }
  23. # The platform name, such as "Docker Engine - Community".
  24. variable "PLATFORM" {
  25. default = ""
  26. }
  27. # The product name, used to set version.ProductName, which is used to set
  28. # BuildKit's ExportedProduct variable in order to show useful error messages
  29. # to users when a certain version of the product doesn't support a BuildKit feature.
  30. variable "PRODUCT" {
  31. default = ""
  32. }
  33. # Sets the version.DefaultProductLicense string, such as "Community Engine".
  34. # This field can contain a summary of the product license of the daemon if a
  35. # commercial license has been applied to the daemon.
  36. variable "DEFAULT_PRODUCT_LICENSE" {
  37. default = ""
  38. }
  39. # The name of the packager (e.g. "Docker, Inc."). This used to set CompanyName
  40. # in the manifest.
  41. variable "PACKAGER_NAME" {
  42. default = ""
  43. }
  44. # GITHUB_REF is the actual ref that triggers the workflow and used as version
  45. # when tag is pushed: https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
  46. variable "GITHUB_REF" {
  47. default = ""
  48. }
  49. # GITHUB_SHA is the commit SHA that triggered the workflow and used as commit.
  50. # https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
  51. variable "GITHUB_SHA" {
  52. default = ""
  53. }
  54. # Special target: https://github.com/docker/metadata-action#bake-definition
  55. target "docker-metadata-action" {
  56. tags = ["moby-bin:local"]
  57. }
  58. # Defines the output folder
  59. variable "DESTDIR" {
  60. default = ""
  61. }
  62. function "bindir" {
  63. params = [defaultdir]
  64. result = DESTDIR != "" ? DESTDIR : "./bundles/${defaultdir}"
  65. }
  66. target "_common" {
  67. args = {
  68. BUILDKIT_CONTEXT_KEEP_GIT_DIR = 1
  69. APT_MIRROR = APT_MIRROR
  70. DOCKER_DEBUG = DOCKER_DEBUG
  71. DOCKER_STATIC = DOCKER_STATIC
  72. DOCKER_LDFLAGS = DOCKER_LDFLAGS
  73. DOCKER_BUILDTAGS = DOCKER_BUILDTAGS
  74. DOCKER_GITCOMMIT = DOCKER_GITCOMMIT != "" ? DOCKER_GITCOMMIT : GITHUB_SHA
  75. VERSION = VERSION != "" ? VERSION : GITHUB_REF
  76. PLATFORM = PLATFORM
  77. PRODUCT = PRODUCT
  78. DEFAULT_PRODUCT_LICENSE = DEFAULT_PRODUCT_LICENSE
  79. PACKAGER_NAME = PACKAGER_NAME
  80. }
  81. }
  82. group "default" {
  83. targets = ["binary"]
  84. }
  85. target "_platforms" {
  86. platforms = [
  87. "linux/amd64",
  88. "linux/arm/v5",
  89. "linux/arm/v6",
  90. "linux/arm/v7",
  91. "linux/arm64",
  92. "linux/ppc64le",
  93. "linux/s390x",
  94. "windows/amd64"
  95. ]
  96. }
  97. #
  98. # build dockerd and docker-proxy
  99. #
  100. target "binary" {
  101. inherits = ["_common"]
  102. target = "binary"
  103. output = [bindir(DOCKER_STATIC == "1" ? "binary" : "dynbinary")]
  104. }
  105. target "dynbinary" {
  106. inherits = ["binary"]
  107. output = [bindir("dynbinary")]
  108. args = {
  109. DOCKER_STATIC = "0"
  110. }
  111. }
  112. target "binary-cross" {
  113. inherits = ["binary", "_platforms"]
  114. }
  115. target "binary-smoketest" {
  116. inherits = ["_common"]
  117. target = "smoketest"
  118. output = ["type=cacheonly"]
  119. platforms = [
  120. "linux/amd64",
  121. "linux/arm/v6",
  122. "linux/arm/v7",
  123. "linux/arm64",
  124. "linux/ppc64le",
  125. "linux/s390x"
  126. ]
  127. }
  128. #
  129. # same as binary but with extra tools as well (containerd, runc, ...)
  130. #
  131. target "all" {
  132. inherits = ["_common"]
  133. target = "all"
  134. output = [bindir(DOCKER_STATIC == "1" ? "binary" : "dynbinary")]
  135. }
  136. target "all-cross" {
  137. inherits = ["all", "_platforms"]
  138. }
  139. #
  140. # bin image
  141. #
  142. target "bin-image" {
  143. inherits = ["all", "docker-metadata-action"]
  144. output = ["type=docker"]
  145. }
  146. target "bin-image-cross" {
  147. inherits = ["bin-image"]
  148. output = ["type=image"]
  149. platforms = [
  150. "linux/amd64",
  151. "linux/arm/v6",
  152. "linux/arm/v7",
  153. "linux/arm64",
  154. "linux/ppc64le",
  155. "linux/s390x",
  156. "windows/amd64"
  157. ]
  158. }
  159. #
  160. # dev
  161. #
  162. variable "SYSTEMD" {
  163. default = "false"
  164. }
  165. target "dev" {
  166. inherits = ["_common"]
  167. target = "dev"
  168. args = {
  169. SYSTEMD = SYSTEMD
  170. }
  171. tags = ["docker-dev"]
  172. output = ["type=docker"]
  173. }