Files
NodecastV2/build-push.sh
Blomios a25ecbf47c feat(docker): add configurable Gitea image publishing (#52)
Build and push an image from the local checkout with configurable repository and tag; configure Compose to pull that image without an upstream build.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-23 00:00:05 +02:00

40 lines
1.4 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
set -euo pipefail
usage() {
printf '%s\n' 'Usage: build-push.sh [TAG]' \
'Build this checkout and push it to the Gitea container registry.' \
'TAG defaults to NODECAST_TAG or latest; NODECAST_IMAGE overrides the image repository.'
}
if [[ $# -eq 1 && ( $1 == --help || $1 == -h ) ]]; then
usage
exit 0
fi
if [[ $# -gt 1 ]]; then
usage >&2
exit 1
fi
repo_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
image="${NODECAST_IMAGE:-gitea.anthonybouteiller.ovh/blomios/nodecast-tv}"
tag="${1-${NODECAST_TAG:-latest}}"
if [[ ! $tag =~ ^[a-zA-Z0-9_][a-zA-Z0-9_.-]{0,127}$ ]]; then
printf '%s\n' 'Error: Invalid Docker tag (1–128 letters, digits, underscores, dots or hyphens; cannot start with dot/hyphen).' >&2
exit 1
fi
if [[ $image != */* || $image == *://* || $image == *@* || $image =~ [[:space:]] || ${image##*/} == *:* ]]; then
printf '%s\n' 'Error: NODECAST_IMAGE must be a registry/repository path without a tag or digest.' >&2
exit 1
fi
if ! command -v docker >/dev/null 2>&1; then
printf '%s\n' 'Error: Docker is required to build and push the image.' >&2
exit 1
fi
reference="${image}:${tag}"
printf 'Building %s from %s\n' "$reference" "$repo_dir"
docker build --file "$repo_dir/Dockerfile" --tag "$reference" "$repo_dir"
printf 'Pushing %s\n' "$reference"
docker push "$reference"