docker-bake.hcl 2.8 KB

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