#!/bin/bash set -e # Configuration REGISTRY="registry.keyboardvagabond.com" VERSION="v0.12.6" PLATFORM="linux/arm64" # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color echo -e "${GREEN}Building Pixelfed ${VERSION} Containers for ARM64...${NC}" echo -e "${BLUE}This will build:${NC}" echo -e " • ${YELLOW}pixelfed-base${NC} - Shared base image" echo -e " • ${YELLOW}pixelfed-web${NC} - Web server (Nginx + PHP-FPM)" echo -e " • ${YELLOW}pixelfed-worker${NC} - Background workers (Horizon + Scheduler)" echo # Build base image first echo -e "${YELLOW}Step 1/3: Building base image...${NC}" cd pixelfed-base docker build \ --network=host \ --platform $PLATFORM \ --tag pixelfed-base:$VERSION \ --tag pixelfed-base:latest \ . cd .. echo -e "${GREEN}✓ Base image built successfully!${NC}" # Build web container echo -e "${YELLOW}Step 2/3: Building web container...${NC}" cd pixelfed-web docker build \ --network=host \ --platform $PLATFORM \ --tag $REGISTRY/library/pixelfed-web:$VERSION \ --tag $REGISTRY/library/pixelfed-web:latest \ . cd .. echo -e "${GREEN}✓ Web container built successfully!${NC}" # Build worker container echo -e "${YELLOW}Step 3/3: Building worker container...${NC}" cd pixelfed-worker docker build \ --network=host \ --platform $PLATFORM \ --tag $REGISTRY/library/pixelfed-worker:$VERSION \ --tag $REGISTRY/library/pixelfed-worker:latest \ . cd .. echo -e "${GREEN}✓ Worker container built successfully!${NC}" echo -e "${GREEN}🎉 All containers built successfully!${NC}" echo -e "${BLUE}Built containers:${NC}" echo -e " • ${GREEN}$REGISTRY/library/pixelfed-web:$VERSION${NC}" echo -e " • ${GREEN}$REGISTRY/library/pixelfed-worker:$VERSION${NC}" # Show image sizes echo echo -e "${BLUE}📊 Built image sizes:${NC}" docker images --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}" | grep -E "(pixelfed-base|pixelfed-web|pixelfed-worker)" | head -10 # Ask about pushing to registry echo read -p "Push all containers to Harbor registry? (y/N): " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then echo -e "${YELLOW}Pushing containers to registry...${NC}" # Check if logged in if ! docker info | grep -q "Username:"; then echo -e "${YELLOW}Logging into Harbor registry...${NC}" docker login $REGISTRY fi # Push web container echo -e "${BLUE}Pushing web container...${NC}" docker push $REGISTRY/library/pixelfed-web:$VERSION docker push $REGISTRY/library/pixelfed-web:latest # Push worker container echo -e "${BLUE}Pushing worker container...${NC}" docker push $REGISTRY/library/pixelfed-worker:$VERSION docker push $REGISTRY/library/pixelfed-worker:latest echo -e "${GREEN}✓ All containers pushed successfully!${NC}" echo -e "${GREEN}Images available at:${NC}" echo -e " • ${BLUE}$REGISTRY/library/pixelfed-web:$VERSION${NC}" echo -e " • ${BLUE}$REGISTRY/library/pixelfed-worker:$VERSION${NC}" else echo -e "${YELLOW}Build completed. To push later, run:${NC}" echo "docker push $REGISTRY/library/pixelfed-web:$VERSION" echo "docker push $REGISTRY/library/pixelfed-web:latest" echo "docker push $REGISTRY/library/pixelfed-worker:$VERSION" echo "docker push $REGISTRY/library/pixelfed-worker:latest" fi # Clean up build cache echo read -p "Clean up build cache? (y/N): " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]]; then echo -e "${YELLOW}Cleaning up build cache...${NC}" docker builder prune -f echo -e "${GREEN}✓ Build cache cleaned!${NC}" fi echo -e "${GREEN}🚀 All done! Ready for Kubernetes deployment.${NC}"