docker-bake.hcl 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. variable "GO_VERSION" {
  2. default = "1.23.8"
  3. }
  4. variable "VERSION" {
  5. default = ""
  6. }
  7. variable "USE_GLIBC" {
  8. default = ""
  9. }
  10. variable "STRIP_TARGET" {
  11. default = ""
  12. }
  13. variable "IMAGE_NAME" {
  14. default = "docker-cli"
  15. }
  16. # Sets the name of the company that produced the windows binary.
  17. variable "PACKAGER_NAME" {
  18. default = ""
  19. }
  20. target "_common" {
  21. args = {
  22. GO_VERSION = GO_VERSION
  23. BUILDKIT_CONTEXT_KEEP_GIT_DIR = 1
  24. }
  25. }
  26. target "_platforms" {
  27. platforms = [
  28. "darwin/amd64",
  29. "darwin/arm64",
  30. "linux/amd64",
  31. "linux/arm/v6",
  32. "linux/arm/v7",
  33. "linux/arm64",
  34. "linux/ppc64le",
  35. "linux/riscv64",
  36. "linux/s390x",
  37. "windows/amd64",
  38. "windows/arm64"
  39. ]
  40. }
  41. group "default" {
  42. targets = ["binary"]
  43. }
  44. target "binary" {
  45. inherits = ["_common"]
  46. target = "binary"
  47. platforms = ["local"]
  48. output = ["build"]
  49. args = {
  50. BASE_VARIANT = USE_GLIBC == "1" ? "debian" : "alpine"
  51. VERSION = VERSION
  52. PACKAGER_NAME = PACKAGER_NAME
  53. GO_STRIP = STRIP_TARGET
  54. }
  55. }
  56. target "dynbinary" {
  57. inherits = ["binary"]
  58. args = {
  59. GO_LINKMODE = "dynamic"
  60. }
  61. }
  62. target "plugins" {
  63. inherits = ["_common"]
  64. target = "plugins"
  65. platforms = ["local"]
  66. output = ["build"]
  67. args = {
  68. BASE_VARIANT = USE_GLIBC == "1" ? "debian" : "alpine"
  69. VERSION = VERSION
  70. GO_STRIP = STRIP_TARGET
  71. }
  72. }
  73. target "cross" {
  74. inherits = ["binary", "_platforms"]
  75. }
  76. target "dynbinary-cross" {
  77. inherits = ["dynbinary", "_platforms"]
  78. }
  79. target "plugins-cross" {
  80. inherits = ["plugins", "_platforms"]
  81. }
  82. target "lint" {
  83. inherits = ["_common"]
  84. dockerfile = "./dockerfiles/Dockerfile.lint"
  85. target = "lint"
  86. output = ["type=cacheonly"]
  87. }
  88. target "shellcheck" {
  89. inherits = ["_common"]
  90. dockerfile = "./dockerfiles/Dockerfile.shellcheck"
  91. target = "shellcheck"
  92. output = ["type=cacheonly"]
  93. }
  94. target "validate-vendor" {
  95. inherits = ["_common"]
  96. dockerfile = "./dockerfiles/Dockerfile.vendor"
  97. target = "validate"
  98. output = ["type=cacheonly"]
  99. }
  100. target "update-vendor" {
  101. inherits = ["_common"]
  102. dockerfile = "./dockerfiles/Dockerfile.vendor"
  103. target = "update"
  104. output = ["."]
  105. }
  106. target "mod-outdated" {
  107. inherits = ["_common"]
  108. dockerfile = "./dockerfiles/Dockerfile.vendor"
  109. target = "outdated"
  110. no-cache-filter = ["outdated"]
  111. output = ["type=cacheonly"]
  112. }
  113. target "validate-authors" {
  114. inherits = ["_common"]
  115. dockerfile = "./dockerfiles/Dockerfile.authors"
  116. target = "validate"
  117. output = ["type=cacheonly"]
  118. }
  119. target "update-authors" {
  120. inherits = ["_common"]
  121. dockerfile = "./dockerfiles/Dockerfile.authors"
  122. target = "update"
  123. output = ["."]
  124. }
  125. target "test" {
  126. inherits = ["_common"]
  127. target = "test"
  128. output = ["type=cacheonly"]
  129. }
  130. target "test-coverage" {
  131. inherits = ["_common"]
  132. target = "test-coverage"
  133. output = ["build/coverage"]
  134. }
  135. target "e2e-image" {
  136. inherits = ["_common"]
  137. target = "e2e"
  138. output = ["type=docker"]
  139. tags = ["${IMAGE_NAME}"]
  140. args = {
  141. BASE_VARIANT = USE_GLIBC == "1" ? "debian" : "alpine"
  142. VERSION = VERSION
  143. }
  144. }
  145. target "e2e-gencerts" {
  146. inherits = ["_common"]
  147. dockerfile = "./e2e/testdata/Dockerfile.gencerts"
  148. output = ["./e2e/testdata"]
  149. }
  150. target "docker-metadata-action" {
  151. tags = ["cli-bin:local"]
  152. }
  153. target "bin-image" {
  154. inherits = ["binary", "docker-metadata-action"]
  155. target = "bin-image"
  156. output = ["type=docker"]
  157. }
  158. target "bin-image-cross" {
  159. inherits = ["bin-image"]
  160. output = ["type=image"]
  161. platforms = [
  162. "darwin/amd64",
  163. "darwin/arm64",
  164. "linux/amd64",
  165. "linux/arm/v6",
  166. "linux/arm/v7",
  167. "linux/arm64",
  168. "linux/ppc64le",
  169. "linux/s390x",
  170. "windows/amd64",
  171. "windows/arm64"
  172. ]
  173. }