|
| 1 | +# |
| 2 | +# Copyright © contributors to CloudNativePG, established as |
| 3 | +# CloudNativePG a Series of LF Projects, LLC. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | +# |
| 17 | +# SPDX-License-Identifier: Apache-2.0 |
| 18 | +# |
| 19 | + |
| 20 | +variable "environment" { |
| 21 | + default = "testing" |
| 22 | + validation { |
| 23 | + condition = contains(["testing", "production"], environment) |
| 24 | + error_message = "environment must be either testing or production" |
| 25 | + } |
| 26 | +} |
| 27 | + |
| 28 | +variable "registry" { |
| 29 | + default = "localhost:5000" |
| 30 | +} |
| 31 | + |
| 32 | +variable "insecure" { |
| 33 | + default = "false" |
| 34 | +} |
| 35 | + |
| 36 | +variable "latest" { |
| 37 | + default = "false" |
| 38 | +} |
| 39 | + |
| 40 | +variable "buildVersion" { |
| 41 | + default = "dev" |
| 42 | +} |
| 43 | + |
| 44 | +variable "revision" { |
| 45 | + default = "" |
| 46 | +} |
| 47 | + |
| 48 | +variable "distributions" { |
| 49 | + default = [ |
| 50 | + "trixie" |
| 51 | + ] |
| 52 | +} |
| 53 | + |
| 54 | +variable "pgVersions" { |
| 55 | + default = [ |
| 56 | + "18" |
| 57 | + ] |
| 58 | +} |
| 59 | + |
| 60 | +fullname = ( environment == "testing") ? "${registry}/postgres-keycloak-oauth-validator-testing" : "${registry}/postgres-keycloak-oauth-validator" |
| 61 | + |
| 62 | +title = "PostgreSQL OAuth validator module for Keycloak" |
| 63 | +description = "This module enables PostgreSQL to delegate authorization decisions to Keycloak using OAuth tokens, leveraging Keycloak Authorization Services for fine-grained, token-based access control." |
| 64 | +authors = "The CloudNativePG Contributors" |
| 65 | +url = "https://github.com/cloudnative-pg/postgres-keycloak-oauth-validator" |
| 66 | +documentation = "https://cloudnative-pg.io/" |
| 67 | +license = "Apache-2.0" |
| 68 | +now = timestamp() |
| 69 | + |
| 70 | +target "default" { |
| 71 | + matrix = { |
| 72 | + pgVersion = pgVersions |
| 73 | + distro = distributions |
| 74 | + } |
| 75 | + |
| 76 | + name = "${pgVersion}-${distro}" |
| 77 | + platforms = [ |
| 78 | + "linux/amd64", |
| 79 | + "linux/arm64" |
| 80 | + ] |
| 81 | + tags = [ |
| 82 | + "${fullname}:${pgVersion}-${buildVersion}-${distro}", |
| 83 | + "${fullname}:${pgVersion}-${buildVersion}-${formatdate("YYYYMMDDhhmm", now)}-${distro}", |
| 84 | + latest("${fullname}", "${latest}"), |
| 85 | + ] |
| 86 | + |
| 87 | + dockerfile = "docker/Dockerfile" |
| 88 | + context = "." |
| 89 | + |
| 90 | + args = { |
| 91 | + BASE = "${getBaseImage(distro, pgVersion)}" |
| 92 | + PG_MAJOR = pgVersion |
| 93 | + } |
| 94 | + |
| 95 | + output = [ |
| 96 | + "type=image,registry.insecure=${insecure}", |
| 97 | + ] |
| 98 | + |
| 99 | + attest = [ |
| 100 | + "type=provenance,mode=max", |
| 101 | + "type=sbom" |
| 102 | + ] |
| 103 | + annotations = [ |
| 104 | + "index,manifest:org.opencontainers.image.created=${now}", |
| 105 | + "index,manifest:org.opencontainers.image.url=${url}", |
| 106 | + "index,manifest:org.opencontainers.image.source=${url}", |
| 107 | + "index,manifest:org.opencontainers.image.version=${buildVersion}", |
| 108 | + "index,manifest:org.opencontainers.image.revision=${revision}", |
| 109 | + "index,manifest:org.opencontainers.image.vendor=${authors}", |
| 110 | + "index,manifest:org.opencontainers.image.title=${title}", |
| 111 | + "index,manifest:org.opencontainers.image.description=${description}", |
| 112 | + "index,manifest:org.opencontainers.image.documentation=${documentation}", |
| 113 | + "index,manifest:org.opencontainers.image.authors=${authors}", |
| 114 | + "index,manifest:org.opencontainers.image.licenses=${license}", |
| 115 | + "index,manifest:org.opencontainers.image.base.name=${getBaseImage(distro, pgVersion)}", |
| 116 | + ] |
| 117 | + labels = { |
| 118 | + "org.opencontainers.image.created" = "${now}", |
| 119 | + "org.opencontainers.image.url" = "${url}", |
| 120 | + "org.opencontainers.image.source" = "${url}", |
| 121 | + "org.opencontainers.image.version" = "${buildVersion}", |
| 122 | + "org.opencontainers.image.revision" = "${revision}", |
| 123 | + "org.opencontainers.image.vendor" = "${authors}", |
| 124 | + "org.opencontainers.image.title" = "${title}", |
| 125 | + "org.opencontainers.image.description" = "${description}", |
| 126 | + "org.opencontainers.image.documentation" = "${documentation}", |
| 127 | + "org.opencontainers.image.authors" = "${authors}", |
| 128 | + "org.opencontainers.image.licenses" = "${license}", |
| 129 | + "org.opencontainers.image.base.name" = "${getBaseImage(distro, pgVersion)}", |
| 130 | + "name" = "${title}", |
| 131 | + "maintainer" = "${authors}", |
| 132 | + "vendor" = "${authors}", |
| 133 | + "version" = "${buildVersion}", |
| 134 | + "release" = "1", |
| 135 | + "description" = "${description}", |
| 136 | + "summary" = "${description}", |
| 137 | + } |
| 138 | +} |
| 139 | + |
| 140 | +function latest { |
| 141 | + params = [ image, latest ] |
| 142 | + result = (latest == "true") ? "${image}:latest" : "" |
| 143 | +} |
| 144 | + |
| 145 | +function getBaseImage { |
| 146 | + params = [ distro, pgVersion ] |
| 147 | + result = format("ghcr.io/cloudnative-pg/postgresql:%s-minimal-%s", pgVersion, distro) |
| 148 | +} |
0 commit comments