Initial commit
Build and Push Multi-Arch Docker Image / build (push) Has been cancelled

This commit is contained in:
dido committed 2026-09-03 11:19:41 +03:00
commit 8ce01cb00a
34 files changed
+8346

No files matched your search

+88
View File
@@ -0,0 +1,88 @@
#!/bin/bash
# Build and Push Script for WebSSH
# Builds Docker image and pushes to Docker Hub
set -e
# Configuration
IMAGE_NAME="danaildr/webssh"
VERSION="0.3.1"
PLATFORMS="linux/amd64,linux/arm64,linux/arm/v7"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
echo -e "${BLUE}🐳 Docker Hub Build & Push Script${NC}"
echo -e "${BLUE}=================================${NC}"
ensure_buildx_builder() {
if ! docker buildx inspect >/dev/null 2>&1; then
docker buildx create --use --name webssh-builder >/dev/null
fi
docker buildx inspect --bootstrap >/dev/null
}
# Function to build and push to Docker Hub
build_and_push() {
# Check if user is logged in to Docker Hub
if ! docker info | grep -q "Username"; then
echo -e "${YELLOW}⚠️ You're not logged in to Docker Hub${NC}"
echo -e "${BLUE}ℹ️ Please run: docker login${NC}"
return 1
fi
ensure_buildx_builder
echo -e "${GREEN}🏗 Building & pushing multi-arch image ${IMAGE_NAME}:${VERSION} (${PLATFORMS})...${NC}"
docker buildx build \
--platform "${PLATFORMS}" \
--tag "${IMAGE_NAME}:${VERSION}" \
--tag "${IMAGE_NAME}:latest" \
--push \
--file deployment/Dockerfile \
.
echo -e "${GREEN}✅ Docker build & push successful${NC}"
echo ""
echo -e "${YELLOW}⚠️ Don't forget to create a GitHub release!${NC}"
}
# Function to show usage
show_usage() {
echo "Usage: $0 [options]"
echo ""
echo "Options:"
echo " -v, --version Show configured version tag"
echo " -b, --build Build and push to Docker Hub"
echo " -h, --help Show this help message"
echo ""
echo "Examples:"
echo " $0 --version # Show version tag"
echo " $0 --build # Build and push multi-arch image"
}
# Parse command line arguments
case "${1:-}" in
-v|--version)
echo "${VERSION}"
;;
-b|--build)
build_and_push
;;
-h|--help|"")
show_usage
;;
*)
echo -e "${RED}❌ Unknown option: $1${NC}"
show_usage
exit 1
;;
esac