docker-bake.hcl 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. // Copyright 2022 Docker Compose CLI authors
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. variable "GO_VERSION" {
  15. # default ARG value set in Dockerfile
  16. default = null
  17. }
  18. variable "BUILD_TAGS" {
  19. default = "e2e"
  20. }
  21. variable "DOCS_FORMATS" {
  22. default = "md,yaml"
  23. }
  24. # Defines the output folder to override the default behavior.
  25. # See Makefile for details, this is generally only useful for
  26. # the packaging scripts and care should be taken to not break
  27. # them.
  28. variable "DESTDIR" {
  29. default = ""
  30. }
  31. function "outdir" {
  32. params = [defaultdir]
  33. result = DESTDIR != "" ? DESTDIR : "${defaultdir}"
  34. }
  35. # Special target: https://github.com/docker/metadata-action#bake-definition
  36. target "meta-helper" {}
  37. target "_common" {
  38. args = {
  39. GO_VERSION = GO_VERSION
  40. BUILD_TAGS = BUILD_TAGS
  41. BUILDKIT_CONTEXT_KEEP_GIT_DIR = 1
  42. }
  43. }
  44. group "default" {
  45. targets = ["binary"]
  46. }
  47. group "validate" {
  48. targets = ["lint", "vendor-validate", "license-validate"]
  49. }
  50. target "lint" {
  51. inherits = ["_common"]
  52. target = "lint"
  53. output = ["type=cacheonly"]
  54. }
  55. target "license-validate" {
  56. target = "license-validate"
  57. output = ["type=cacheonly"]
  58. }
  59. target "license-update" {
  60. target = "license-update"
  61. output = ["."]
  62. }
  63. target "vendor-validate" {
  64. inherits = ["_common"]
  65. target = "vendor-validate"
  66. output = ["type=cacheonly"]
  67. }
  68. target "vendor-update" {
  69. inherits = ["_common"]
  70. target = "vendor-update"
  71. output = ["."]
  72. }
  73. target "test" {
  74. inherits = ["_common"]
  75. target = "test-coverage"
  76. output = [outdir("./bin/coverage/unit")]
  77. }
  78. target "binary-with-coverage" {
  79. inherits = ["_common"]
  80. target = "binary"
  81. args = {
  82. BUILD_FLAGS = "-cover -covermode=atomic"
  83. }
  84. output = [outdir("./bin/build")]
  85. platforms = ["local"]
  86. }
  87. target "binary" {
  88. inherits = ["_common"]
  89. target = "binary"
  90. output = [outdir("./bin/build")]
  91. platforms = ["local"]
  92. }
  93. target "binary-cross" {
  94. inherits = ["binary"]
  95. platforms = [
  96. "darwin/amd64",
  97. "darwin/arm64",
  98. "linux/amd64",
  99. "linux/arm/v6",
  100. "linux/arm/v7",
  101. "linux/arm64",
  102. "linux/ppc64le",
  103. "linux/riscv64",
  104. "linux/s390x",
  105. "windows/amd64",
  106. "windows/arm64"
  107. ]
  108. }
  109. target "release" {
  110. inherits = ["binary-cross"]
  111. target = "release"
  112. output = [outdir("./bin/release")]
  113. }
  114. target "docs-validate" {
  115. inherits = ["_common"]
  116. target = "docs-validate"
  117. output = ["type=cacheonly"]
  118. }
  119. target "docs-update" {
  120. inherits = ["_common"]
  121. target = "docs-update"
  122. output = ["./docs"]
  123. }
  124. target "image-cross" {
  125. inherits = ["meta-helper", "binary-cross"]
  126. output = ["type=image"]
  127. }