-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-image.sh
More file actions
executable file
·34 lines (23 loc) · 1.14 KB
/
Copy pathbuild-image.sh
File metadata and controls
executable file
·34 lines (23 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env bash
set -euo pipefail
VERSION="${VERSION:-unknown}"
COMMIT="${COMMIT:-unknown}"
TREE_STATE="${TREE_STATE:-unknown}"
TARGETARCH="${TARGETARCH:-amd64}"
IMAGE="${IMAGE:-cert-manager-webhook-bunny}"
IMAGE_TAG="${IMAGE_TAG:-latest}"
BASE_IMAGE="gcr.io/distroless/static-debian13:nonroot"
echo "Building ${IMAGE}:${IMAGE_TAG} (arch=${TARGETARCH}, version=${VERSION})"
CGO_ENABLED=0 GOOS=linux GOARCH="${TARGETARCH}" go build -ldflags="-w -extldflags '-static'" -o webhook .
CTR=$(buildah from "${BASE_IMAGE}")
buildah copy "${CTR}" webhook /webhook
buildah config --os linux --arch "${TARGETARCH}" "${CTR}"
buildah config --label "org.opencontainers.image.title=cert-manager-webhook-bunny" "${CTR}"
buildah config --label "org.opencontainers.image.description=cert-manager webhook for bunny.net DNS" "${CTR}"
buildah config --label "org.opencontainers.image.licenses=Apache-2.0" "${CTR}"
buildah config --label "org.opencontainers.image.version=${VERSION}" "${CTR}"
buildah config --entrypoint '["/webhook"]' "${CTR}"
buildah commit --format docker "${CTR}" "${IMAGE}:${IMAGE_TAG}"
buildah rm "${CTR}"
rm -f webhook
echo "Built ${IMAGE}:${IMAGE_TAG}"