docker-bake.hcl 3.4 KB

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