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>
This commit is contained in:
2026-10-23 00:00:05 +02:00
parent afb5a044ee
commit a25ecbf47c
5 changed files with 68 additions and 6 deletions

39
build-push.sh Executable file
View File

@ -0,0 +1,39 @@
#!/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"