Files
jellytau/scripts/build-builder-image.sh
T
dtourolle 28b600304f fix(scripts): check registry auth properly before pushing the builder image
`docker info | grep Username` only reports a Docker Hub session, so for a
private registry the guard never matched: every push dropped into an interactive
docker login, which hangs a non-interactive run. Checks the credential store for
the specific registry instead, and refuses with instructions rather than
prompting when there is no TTY.
2026-08-20 21:06:23 +02:00

61 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
# Build and push the JellyTau builder Docker image to your registry
set -e
# Configuration
REGISTRY_HOST="${REGISTRY_HOST:-gitea.tourolle.paris}"
REGISTRY_USER="${REGISTRY_USER:-dtourolle}"
IMAGE_NAME="jellytau-builder"
IMAGE_TAG="${1:-latest}"
FULL_IMAGE_NAME="${REGISTRY_HOST}/${REGISTRY_USER}/${IMAGE_NAME}:${IMAGE_TAG}"
echo "🐳 Building JellyTau Builder Image"
echo "=================================="
echo "Registry: $REGISTRY_HOST"
echo "User: $REGISTRY_USER"
echo "Image: $FULL_IMAGE_NAME"
echo ""
# Step 1: Build locally
echo "🔨 Building Docker image locally..."
docker build -f Dockerfile.builder -t ${IMAGE_NAME}:${IMAGE_TAG} .
# Step 2: Tag for registry
echo "🏷️ Tagging for registry..."
docker tag ${IMAGE_NAME}:${IMAGE_TAG} ${FULL_IMAGE_NAME}
# Step 3: Login to registry (if not already logged in)
#
# `docker info | grep Username` only ever reports a Docker Hub session, so for a
# private registry it never matched — meaning this branch fired on every push and
# dropped into an interactive `docker login`, which hangs any non-interactive run
# (a scripted release, or CI). Check the credential store for this specific
# registry instead, and refuse rather than prompt when there is no TTY to
# prompt on.
echo "🔐 Checking registry authentication..."
DOCKER_CFG="${DOCKER_CONFIG:-$HOME/.docker}/config.json"
if ! grep -q "\"${REGISTRY_HOST}\"" "$DOCKER_CFG" 2>/dev/null; then
if [ -t 0 ]; then
echo "Not authenticated to ${REGISTRY_HOST}. Logging in..."
docker login "${REGISTRY_HOST}"
else
echo "❌ Not authenticated to ${REGISTRY_HOST}, and stdin is not a TTY."
echo " Run this first: docker login ${REGISTRY_HOST}"
exit 1
fi
else
echo " Using stored credentials for ${REGISTRY_HOST}."
fi
# Step 4: Push to registry
echo "📤 Pushing image to registry..."
docker push ${FULL_IMAGE_NAME}
echo ""
echo "✅ Successfully built and pushed: ${FULL_IMAGE_NAME}"
echo ""
echo "Update your workflow to use:"
echo " container:"
echo " image: ${FULL_IMAGE_NAME}"