This commit is contained in:
2025-06-12 09:00:16 +09:00
parent 4226d6ccd6
commit 18a3b5312e
6 changed files with 526 additions and 16 deletions

View File

@ -2,14 +2,47 @@
set -euo pipefail
# Build Docker image for Voice RSS Summary project
# Usage: ./build-docker-image.sh [tag] [build-args...]
# Usage: ./build-docker-image.sh [tag] [--platform=platform] [build-args...]
IMAGE_NAME="voice-rss-summary"
TAG="${1:-latest}"
TAG="latest"
PLATFORM=""
BUILD_ARGS=()
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--platform=*)
PLATFORM="${1#*=}"
shift
;;
--platform)
PLATFORM="$2"
shift 2
;;
-*)
BUILD_ARGS+=("$1")
shift
;;
*)
if [[ -z "${TAG_SET:-}" ]]; then
TAG="$1"
TAG_SET=true
else
BUILD_ARGS+=("$1")
fi
shift
;;
esac
done
FULL_TAG="${IMAGE_NAME}:${TAG}"
echo "Building Docker image: ${FULL_TAG}"
echo "Build context: $(pwd)"
if [[ -n "$PLATFORM" ]]; then
echo "Target platform: ${PLATFORM}"
fi
# Check if Dockerfile exists
if [[ ! -f "Dockerfile" ]]; then
@ -18,15 +51,34 @@ if [[ ! -f "Dockerfile" ]]; then
fi
# Build with build cache and progress output
exec docker build \
--tag "${FULL_TAG}" \
--progress=plain \
--build-arg BUILDKIT_INLINE_CACHE=1 \
"${@:2}" \
.
DOCKER_CMD=(docker build --tag "${FULL_TAG}" --progress=plain --build-arg BUILDKIT_INLINE_CACHE=1)
# Add platform if specified
if [[ -n "$PLATFORM" ]]; then
DOCKER_CMD+=(--platform "$PLATFORM")
fi
# Add any additional build args
if [[ ${#BUILD_ARGS[@]} -gt 0 ]]; then
DOCKER_CMD+=("${BUILD_ARGS[@]}")
fi
# Add build context
DOCKER_CMD+=(.)
echo "Running: ${DOCKER_CMD[*]}"
"${DOCKER_CMD[@]}"
# Display image info
echo "\nBuild completed successfully!"
echo ""
echo "Build completed successfully!"
echo "Image: ${FULL_TAG}"
if [[ -n "$PLATFORM" ]]; then
echo "Platform: ${PLATFORM}"
fi
echo "Size: $(docker images --format 'table {{.Size}}' "${FULL_TAG}" | tail -n +2)"
echo "\nTo run the container, use: ./run-docker.sh"
echo ""
echo "To run the container, use: ./run-docker.sh"
if [[ -n "$PLATFORM" && "$PLATFORM" != "linux/amd64" ]]; then
echo "Note: Cross-platform image built. May need to push to registry for deployment."
fi