diff --git a/Dockerfile b/Dockerfile index c2c975a..315c511 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ COPY . . RUN npm run build # Stage 2: Production -FROM node:18-alpine AS production +FROM node:22-alpine AS production WORKDIR /app diff --git a/build-and-push.sh b/build-and-push.sh index adbba2a..87fe3ab 100755 --- a/build-and-push.sh +++ b/build-and-push.sh @@ -1,7 +1,8 @@ #!/bin/bash -# Build and Push Docker Image Script -# This script builds the Docker image and pushes it to a registry +# Build and Push Multi-Platform Docker Image Script +# This script builds the Docker image for multiple platforms (Linux amd64, arm64) +# and pushes it to a registry set -e # Exit on error @@ -11,17 +12,38 @@ REGISTRY="renolation" # Change this to your Docker Hub username or registry URL VERSION="latest" FULL_IMAGE="${REGISTRY}/${IMAGE_NAME}:${VERSION}" -echo "🏗️ Building Docker image..." -docker build -t ${IMAGE_NAME}:${VERSION} . +# Colors for output +GREEN='\033[0;32m' +BLUE='\033[0;34m' +YELLOW='\033[1;33m' +NC='\033[0m' # No Color -echo "🏷️ Tagging image for registry..." -docker tag ${IMAGE_NAME}:${VERSION} ${FULL_IMAGE} +echo -e "${BLUE}🔧 Setting up Docker Buildx...${NC}" +# Create and use a new builder instance that supports multi-platform builds +docker buildx create --use --name multiplatform-builder --driver docker-container --bootstrap 2>/dev/null || docker buildx use multiplatform-builder -echo "📤 Pushing image to registry..." -docker push ${FULL_IMAGE} - -echo "✅ Successfully built and pushed: ${FULL_IMAGE}" +echo -e "${BLUE}🏗️ Building multi-platform Docker image...${NC}" +echo -e "${YELLOW} Platforms: linux/amd64, linux/arm64${NC}" +echo -e "${YELLOW} Image: ${FULL_IMAGE}${NC}" echo "" -echo "To use this image on another server, run:" -echo " docker pull ${FULL_IMAGE}" -echo " docker-compose -f docker-compose.prod.yml up -d" + +# Build and push for multiple platforms +docker buildx build \ + --platform linux/amd64,linux/arm64 \ + --tag ${FULL_IMAGE} \ + --push \ + . + +echo "" +echo -e "${GREEN}✅ Successfully built and pushed multi-platform image: ${FULL_IMAGE}${NC}" +echo "" +echo -e "${BLUE}📦 Image supports:${NC}" +echo " - Linux AMD64 (x86_64) - Most cloud servers, VPS" +echo " - Linux ARM64 (aarch64) - AWS Graviton, Raspberry Pi, Apple Silicon" +echo "" +echo -e "${BLUE}📝 To use this image on another server, run:${NC}" +echo " docker pull ${FULL_IMAGE}" +echo " docker-compose -f docker-compose.prod.yml up -d" +echo "" +echo -e "${BLUE}🔍 To inspect the image:${NC}" +echo " docker buildx imagetools inspect ${FULL_IMAGE}"