docker-bake.hcl 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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
  25. variable "DESTDIR" {
  26. default = ""
  27. }
  28. function "bindir" {
  29. params = [defaultdir]
  30. result = DESTDIR != "" ? DESTDIR : "./bin/${defaultdir}"
  31. }
  32. # Special target: https://github.com/docker/metadata-action#bake-definition
  33. target "meta-helper" {}
  34. target "_common" {
  35. args = {
  36. GO_VERSION = GO_VERSION
  37. BUILD_TAGS = BUILD_TAGS
  38. BUILDKIT_CONTEXT_KEEP_GIT_DIR = 1
  39. }
  40. }
  41. group "default" {
  42. targets = ["binary"]
  43. }
  44. group "validate" {
  45. targets = ["lint", "vendor-validate", "license-validate"]
  46. }
  47. target "lint" {
  48. inherits = ["_common"]
  49. target = "lint"
  50. output = ["type=cacheonly"]
  51. }
  52. target "license-validate" {
  53. target = "license-validate"
  54. output = ["type=cacheonly"]
  55. }
  56. target "license-update" {
  57. target = "license-update"
  58. output = ["."]
  59. }
  60. target "vendor-validate" {
  61. inherits = ["_common"]
  62. target = "vendor-validate"
  63. output = ["type=cacheonly"]
  64. }
  65. target "vendor-update" {
  66. inherits = ["_common"]
  67. target = "vendor-update"
  68. output = ["."]
  69. }
  70. target "test" {
  71. inherits = ["_common"]
  72. target = "test-coverage"
  73. output = [bindir("coverage")]
  74. }
  75. target "binary-with-coverage" {
  76. inherits = ["_common"]
  77. target = "binary"
  78. args = {
  79. BUILD_FLAGS = "-cover"
  80. }
  81. output = [bindir("build")]
  82. platforms = ["local"]
  83. }
  84. target "binary" {
  85. inherits = ["_common"]
  86. target = "binary"
  87. output = [bindir("build")]
  88. platforms = ["local"]
  89. }
  90. target "binary-cross" {
  91. inherits = ["binary"]
  92. platforms = [
  93. "darwin/amd64",
  94. "darwin/arm64",
  95. "linux/amd64",
  96. "linux/arm/v6",
  97. "linux/arm/v7",
  98. "linux/arm64",
  99. "linux/ppc64le",
  100. "linux/riscv64",
  101. "linux/s390x",
  102. "windows/amd64",
  103. "windows/arm64"
  104. ]
  105. }
  106. target "release" {
  107. inherits = ["binary-cross"]
  108. target = "release"
  109. output = [bindir("release")]
  110. }
  111. target "docs-validate" {
  112. inherits = ["_common"]
  113. target = "docs-validate"
  114. output = ["type=cacheonly"]
  115. }
  116. target "docs-update" {
  117. inherits = ["_common"]
  118. target = "docs-update"
  119. output = ["./docs"]
  120. }
  121. target "image-cross" {
  122. inherits = ["meta-helper", "binary-cross"]
  123. output = ["type=image"]
  124. }