113 lines
3.4 KiB
Bash
Executable File
113 lines
3.4 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
# Configuration
|
|
REGISTRY="<YOUR_REGISTRY_URL>"
|
|
VERSION="v1.3.9"
|
|
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 PieFed ${VERSION} Containers for ARM64...${NC}"
|
|
echo -e "${BLUE}This will build:${NC}"
|
|
echo -e " • ${YELLOW}piefed-base${NC} - Shared base image"
|
|
echo -e " • ${YELLOW}piefed-web${NC} - Web server (Nginx + Django/uWSGI)"
|
|
echo -e " • ${YELLOW}piefed-worker${NC} - Background workers (Celery + Beat)"
|
|
echo
|
|
|
|
# Build base image first
|
|
echo -e "${YELLOW}Step 1/3: Building base image...${NC}"
|
|
cd piefed-base
|
|
docker build \
|
|
--network=host \
|
|
--platform $PLATFORM \
|
|
--build-arg PIEFED_VERSION=${VERSION} \
|
|
--tag piefed-base:$VERSION \
|
|
--tag piefed-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 piefed-web
|
|
docker build \
|
|
--network=host \
|
|
--platform $PLATFORM \
|
|
--tag $REGISTRY/library/piefed-web:$VERSION \
|
|
--tag $REGISTRY/library/piefed-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 piefed-worker
|
|
docker build \
|
|
--network=host \
|
|
--platform $PLATFORM \
|
|
--tag $REGISTRY/library/piefed-worker:$VERSION \
|
|
--tag $REGISTRY/library/piefed-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/piefed-web:$VERSION${NC}"
|
|
echo -e " • ${GREEN}$REGISTRY/library/piefed-worker:$VERSION${NC}"
|
|
|
|
# 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/piefed-web:$VERSION
|
|
docker push $REGISTRY/library/piefed-web:latest
|
|
|
|
# Push worker container
|
|
echo -e "${BLUE}Pushing worker container...${NC}"
|
|
docker push $REGISTRY/library/piefed-worker:$VERSION
|
|
docker push $REGISTRY/library/piefed-worker:latest
|
|
|
|
echo -e "${GREEN}✓ All containers pushed successfully!${NC}"
|
|
echo -e "${GREEN}Images available at:${NC}"
|
|
echo -e " • ${BLUE}$REGISTRY/library/piefed-web:$VERSION${NC}"
|
|
echo -e " • ${BLUE}$REGISTRY/library/piefed-worker:$VERSION${NC}"
|
|
else
|
|
echo -e "${YELLOW}Build completed. To push later, run:${NC}"
|
|
echo "docker push $REGISTRY/library/piefed-web:$VERSION"
|
|
echo "docker push $REGISTRY/library/piefed-web:latest"
|
|
echo "docker push $REGISTRY/library/piefed-worker:$VERSION"
|
|
echo "docker push $REGISTRY/library/piefed-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}" |