podman-binexp/build.sh

41 lines
976 B
Bash
Executable File

#!/bin/sh
# Static configuration
REGISTRY="gitea.slebba.net"
REPO="seb/podman-binexp-img"
TAG=$(date -u +%Y-%m-%d-%H%M)
PUSH=true # Set to 'true' to push the image after build
IMAGE="$REGISTRY/$REPO:$TAG"
LATEST_IMAGE="$REGISTRY/$REPO:latest"
echo "Building image: $IMAGE"
# Ensure Containerfile exists
if [ ! -f Containerfile ]; then
echo "Error: Containerfile not found!" >&2
exit 1
fi
# Build the image
if podman build -t "$IMAGE" -f Containerfile .; then
echo "Build successful: $IMAGE"
# Tag the image as latest
podman tag "$IMAGE" "$LATEST_IMAGE"
echo "Tagged $IMAGE as $LATEST_IMAGE"
# Push the image if PUSH is enabled
if [ "$PUSH" = "true" ]; then
echo "Pushing image: $IMAGE and $LATEST_IMAGE"
if podman push "$IMAGE" && podman push "$LATEST_IMAGE"; then
echo "Images pushed successfully: $IMAGE, $LATEST_IMAGE"
else
echo "Failed to push images!" >&2
exit 1
fi
fi
else
echo "Build failed!" >&2
exit 1
fi