| 1 | #!/bin/bash |
| 2 | # 构建所有服务的 Docker 镜像(本地构建,不推送) |
| 3 | # Build all service Docker images (local build, no push) |
| 4 | set -e |
| 5 | |
| 6 | SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" |
| 7 | PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" |
| 8 | |
| 9 | echo "=== Building backend images ===" |
| 10 | |
| 11 | cd "$PROJECT_ROOT/project/aitoearn-backend" |
| 12 | |
| 13 | DATE_TAG="$(node -e "console.log(new Date().toISOString().slice(0, 10).replace(/-/g, ''))")" |
| 14 | GIT_HASH="$(git rev-parse --short HEAD)" |
| 15 | IMAGE_TAG="${DATE_TAG}-${GIT_HASH}" |
| 16 | |
| 17 | # 构建 aitoearn-server(不带 -p,不推送到远端) |
| 18 | echo "--- Building aitoearn-server ---" |
| 19 | node scripts/build-docker.mjs aitoearn-server |
| 20 | |
| 21 | # 构建 aitoearn-ai |
| 22 | echo "--- Building aitoearn-ai ---" |
| 23 | node scripts/build-docker.mjs aitoearn-ai |
| 24 | |
| 25 | # 重新 tag 为 docker-compose 期望的名称 |
| 26 | echo "--- Tagging images for docker-compose ---" |
| 27 | docker tag "aitoearn-server:${IMAGE_TAG}" aitoearn/aitoearn-server:latest |
| 28 | docker tag "aitoearn-ai:${IMAGE_TAG}" aitoearn/aitoearn-ai:latest |
| 29 | |
| 30 | echo "=== Building frontend image ===" |
| 31 | |
| 32 | cd "$PROJECT_ROOT/project/aitoearn-web" |
| 33 | docker build \ |
| 34 | -t aitoearn/aitoearn-web:latest . |
| 35 | |
| 36 | echo "=== All images built successfully ===" |
| 37 | echo "" |
| 38 | echo "Images:" |
| 39 | docker images --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}" | grep -E "aitoearn|REPOSITORY" |
| 40 | echo "" |
| 41 | echo "Run 'docker compose up -d --pull never' to start all services with local images." |
| 42 |