- Removed Dockerfile and added multiple Dockerfiles for various tools (ClickHouse, MongoDB, MinIO, Caddy, Redis) with Deno runtime. - Updated package.json to reflect new repository structure and versioning. - Added comprehensive README and technical notes for architecture overview and usage. - Implemented build and test scripts for streamlined image creation and validation. - Introduced bash scripts for NVM functionality in Docker images.
131 lines
3.8 KiB
Bash
131 lines
3.8 KiB
Bash
#!/bin/bash
|
|
set -e
|
|
|
|
echo "Building ht-docker-tools Images"
|
|
echo "================================"
|
|
echo ""
|
|
|
|
# Color codes
|
|
GREEN='\033[0;32m'
|
|
BLUE='\033[0;34m'
|
|
YELLOW='\033[1;33m'
|
|
RED='\033[0;31m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Check if buildx is available
|
|
if ! docker buildx version &> /dev/null; then
|
|
echo -e "${YELLOW}Warning: docker buildx not found. Installing...${NC}"
|
|
docker buildx create --use
|
|
fi
|
|
|
|
# Ensure buildx builder is running
|
|
echo -e "${BLUE}Setting up buildx builder...${NC}"
|
|
if ! docker buildx inspect default-builder &> /dev/null; then
|
|
docker buildx create --name default-builder --use
|
|
else
|
|
docker buildx use default-builder
|
|
fi
|
|
echo -e "${GREEN}Buildx ready${NC}"
|
|
echo ""
|
|
|
|
# Build function for single platform (for local testing)
|
|
build_native_image() {
|
|
local dockerfile=$1
|
|
local tag=$2
|
|
local description=$3
|
|
local platform=$(uname -m)
|
|
|
|
# Convert platform name
|
|
if [ "$platform" = "x86_64" ]; then
|
|
platform="linux/amd64"
|
|
elif [ "$platform" = "aarch64" ] || [ "$platform" = "arm64" ]; then
|
|
platform="linux/arm64"
|
|
fi
|
|
|
|
echo -e "${BLUE}Building: ${NC}${description}"
|
|
echo -e "${YELLOW} Dockerfile: ${NC}${dockerfile}"
|
|
echo -e "${YELLOW} Tag: ${NC}${tag}"
|
|
echo -e "${YELLOW} Platform: ${NC}${platform} (native)"
|
|
|
|
if docker buildx build \
|
|
--platform "${platform}" \
|
|
-f "${dockerfile}" \
|
|
-t "${tag}" \
|
|
--load \
|
|
.; then
|
|
echo -e "${GREEN}Success: ${NC}${tag} (${platform})"
|
|
echo ""
|
|
else
|
|
echo -e "${RED}Failed: ${NC}${tag}"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
echo -e "${BLUE}======================================${NC}"
|
|
echo -e "${BLUE}Building Official Base Images${NC}"
|
|
echo -e "${BLUE}======================================${NC}"
|
|
echo ""
|
|
echo -e "${YELLOW}Note: Building for native platform only (for local testing)${NC}"
|
|
echo -e "${YELLOW}For multi-arch builds, use: docker buildx build --platform linux/amd64,linux/arm64 --push ...${NC}"
|
|
echo ""
|
|
|
|
# Official base images
|
|
build_native_image "Dockerfile_clickhouse" \
|
|
"ht-docker-tools:clickhouse" \
|
|
"ClickHouse (official base) + Deno"
|
|
|
|
build_native_image "Dockerfile_mongodb" \
|
|
"ht-docker-tools:mongodb" \
|
|
"MongoDB (official base) + Deno"
|
|
|
|
build_native_image "Dockerfile_minio" \
|
|
"ht-docker-tools:minio" \
|
|
"MinIO (official base) + Deno"
|
|
|
|
build_native_image "Dockerfile_caddy" \
|
|
"ht-docker-tools:caddy" \
|
|
"Caddy (official base) + Deno"
|
|
|
|
build_native_image "Dockerfile_redis" \
|
|
"ht-docker-tools:redis" \
|
|
"Redis (official base) + Deno"
|
|
|
|
echo -e "${BLUE}======================================${NC}"
|
|
echo -e "${BLUE}Building Alpine Images${NC}"
|
|
echo -e "${BLUE}======================================${NC}"
|
|
echo ""
|
|
|
|
# Alpine images
|
|
build_native_image "Dockerfile_clickhouse_alpine" \
|
|
"ht-docker-tools:clickhouse-alpine" \
|
|
"ClickHouse Alpine + NVM + Deno"
|
|
|
|
build_native_image "Dockerfile_mongodb_alpine" \
|
|
"ht-docker-tools:mongodb-alpine" \
|
|
"MongoDB Alpine + NVM + Deno"
|
|
|
|
build_native_image "Dockerfile_minio_alpine" \
|
|
"ht-docker-tools:minio-alpine" \
|
|
"MinIO Alpine + NVM + Deno"
|
|
|
|
build_native_image "Dockerfile_caddy_alpine" \
|
|
"ht-docker-tools:caddy-alpine" \
|
|
"Caddy Alpine + NVM + Deno"
|
|
|
|
build_native_image "Dockerfile_redis_alpine" \
|
|
"ht-docker-tools:redis-alpine" \
|
|
"Redis Alpine + NVM + Deno"
|
|
|
|
# Summary
|
|
echo -e "${GREEN}======================================${NC}"
|
|
echo -e "${GREEN}All Images Built Successfully!${NC}"
|
|
echo -e "${GREEN}======================================${NC}"
|
|
echo ""
|
|
echo "Built Images:"
|
|
echo ""
|
|
docker images | grep "ht-docker-tools:" | awk '{printf " %-40s %10s\n", $1":"$2, $7" "$8}'
|
|
echo ""
|
|
echo -e "${YELLOW}These images are built for your native architecture for local testing.${NC}"
|
|
echo -e "${YELLOW}In CI/CD, build with: docker buildx build --platform linux/amd64,linux/arm64 --push${NC}"
|
|
echo ""
|