|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -euo pipefail |
| 4 | + |
| 5 | +RELEASE_DIR="./docker" |
| 6 | +REPO_NAME="doocs/md" |
| 7 | +PLATFORMS="linux/amd64,linux/arm64" |
| 8 | + |
| 9 | +echo "๐ง Multi-arch Docker build started..." |
| 10 | +echo "๐ Scanning directory: $RELEASE_DIR" |
| 11 | + |
| 12 | +for app_ver in "$RELEASE_DIR"/*; do |
| 13 | + [ -d "$app_ver" ] || continue |
| 14 | + |
| 15 | + tag=$(basename "$app_ver") |
| 16 | + env_file="$app_ver/.env" |
| 17 | + |
| 18 | + if [ ! -f "$env_file" ]; then |
| 19 | + echo "โ ๏ธ Skipping $tag - missing .env file" |
| 20 | + continue |
| 21 | + fi |
| 22 | + |
| 23 | + set -a |
| 24 | + . "$env_file" |
| 25 | + set +a |
| 26 | + |
| 27 | + echo "๐ Building images for version: $tag" |
| 28 | + echo " VER_APP: $VER_APP" |
| 29 | + echo " VER_NGX: $VER_NGX" |
| 30 | + echo " VER_GOLANG: $VER_GOLANG" |
| 31 | + echo " VER_ALPINE: $VER_ALPINE" |
| 32 | + |
| 33 | + # ๆๅปบ base ้ๅ |
| 34 | + if [ -f "$app_ver/Dockerfile.base" ]; then |
| 35 | + echo "๐ฆ Building base image: $REPO_NAME:${VER_APP}-assets" |
| 36 | + docker buildx build \ |
| 37 | + --platform "$PLATFORMS" \ |
| 38 | + --build-arg VER_APP="$VER_APP" \ |
| 39 | + -f "$app_ver/Dockerfile.base" \ |
| 40 | + -t "$REPO_NAME:${VER_APP}-assets" \ |
| 41 | + --push \ |
| 42 | + "$app_ver" |
| 43 | + fi |
| 44 | + |
| 45 | + # ๆๅปบ nginx ้ๅ |
| 46 | + if [ -f "$app_ver/Dockerfile.nginx" ]; then |
| 47 | + echo "๐ฆ Building nginx image: $REPO_NAME:${VER_APP}-nginx" |
| 48 | + docker buildx build \ |
| 49 | + --platform "$PLATFORMS" \ |
| 50 | + --build-arg VER_APP="$VER_APP" \ |
| 51 | + --build-arg VER_NGX="$VER_NGX" \ |
| 52 | + -f "$app_ver/Dockerfile.nginx" \ |
| 53 | + -t "$REPO_NAME:${VER_APP}-nginx" \ |
| 54 | + --push \ |
| 55 | + "$app_ver" |
| 56 | + fi |
| 57 | + |
| 58 | + # ๆๅปบ standalone ้ๅ |
| 59 | + if [ -f "$app_ver/Dockerfile.standalone" ]; then |
| 60 | + echo "๐ฆ Building standalone image: $REPO_NAME:${VER_APP}" |
| 61 | + docker buildx build \ |
| 62 | + --platform "$PLATFORMS" \ |
| 63 | + --build-arg VER_APP="$VER_APP" \ |
| 64 | + --build-arg VER_NGX="$VER_NGX" \ |
| 65 | + -f "$app_ver/Dockerfile.standalone" \ |
| 66 | + -t "$REPO_NAME:${VER_APP}" \ |
| 67 | + --push \ |
| 68 | + "$app_ver" |
| 69 | + fi |
| 70 | + |
| 71 | + # ๆๅปบ static ้ๅ |
| 72 | + if [ -f "$app_ver/Dockerfile.static" ]; then |
| 73 | + echo "๐ฆ Building static image: $REPO_NAME:${VER_APP}-static" |
| 74 | + docker buildx build \ |
| 75 | + --platform "$PLATFORMS" \ |
| 76 | + --build-arg VER_APP="$VER_APP" \ |
| 77 | + --build-arg VER_NGX="$VER_NGX" \ |
| 78 | + -f "$app_ver/Dockerfile.static" \ |
| 79 | + -t "$REPO_NAME:${VER_APP}-static" \ |
| 80 | + --push \ |
| 81 | + "$app_ver" |
| 82 | + fi |
| 83 | + |
| 84 | + echo "โ
Completed version: $tag" |
| 85 | +done |
| 86 | + |
| 87 | +echo "๐ All images built and pushed successfully." |
0 commit comments