|
| 1 | +#!/usr/bin/env bash |
| 2 | +# Copyright The Kubernetes Authors. |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | +set -euo pipefail |
| 16 | + |
| 17 | +REPO_ROOT=$(git rev-parse --show-toplevel) |
| 18 | +cd "$REPO_ROOT" |
| 19 | + |
| 20 | +if [[ -z ${IMG_PREFIX:-} ]]; then |
| 21 | + echo "IMG_PREFIX is not set" |
| 22 | + exit 1 |
| 23 | +fi |
| 24 | + |
| 25 | +if [[ -z ${IMG_TAG:-} ]]; then |
| 26 | + # Match versions.mk VERSION_W_COMMIT (e.g. v25.8.0-dev-f2eaddd6) for release |
| 27 | + # commits, use the exact git tag as the image tag. |
| 28 | + if git describe --exact-match --tags HEAD >/dev/null 2>&1; then |
| 29 | + IMG_TAG=$(git describe --exact-match --tags HEAD) |
| 30 | + else |
| 31 | + IMG_TAG=$(make --no-print-directory -f "${REPO_ROOT}/versions.mk" print-VERSION_W_COMMIT) |
| 32 | + fi |
| 33 | +fi |
| 34 | +echo "Using IMG_TAG=${IMG_TAG}" |
| 35 | + |
| 36 | +if [[ -z ${GIT_COMMIT:-} ]]; then |
| 37 | + GIT_COMMIT=$(git rev-parse HEAD) |
| 38 | +fi |
| 39 | +echo "Using GIT_COMMIT=${GIT_COMMIT}" |
| 40 | + |
| 41 | +export CI=true |
| 42 | +export DOCKER_CLI_EXPERIMENTAL=enabled |
| 43 | + |
| 44 | +# Register gcloud as a Docker credential helper. |
| 45 | +# Required for "docker buildx build --push". |
| 46 | +gcloud auth configure-docker us-central1-docker.pkg.dev --quiet |
| 47 | + |
| 48 | +docker buildx create --name nv-dra-driver-gpu-builder || true |
| 49 | +docker buildx use nv-dra-driver-gpu-builder |
| 50 | +docker buildx inspect --bootstrap |
| 51 | + |
| 52 | +make -f deployments/container/Makefile build \ |
| 53 | + BUILD_MULTI_ARCH_IMAGES=true \ |
| 54 | + PUSH_ON_BUILD=true \ |
| 55 | + REGISTRY="${IMG_PREFIX}" \ |
| 56 | + VERSION="${IMG_TAG}" \ |
| 57 | + GIT_COMMIT="${GIT_COMMIT}" |
0 commit comments