|
|
|
@@ -375,7 +375,7 @@ jobs:
|
|
|
|
|
'
|
|
|
|
|
- name: Install dependencies
|
|
|
|
|
shell: sh
|
|
|
|
|
run: "set -eu\nNPM_CACHE_VOLUME=\"xiaoxia-npm-cache\"\nif ! docker volume inspect \"$NPM_CACHE_VOLUME\" >/dev/null 2>&1; then\n docker volume create \"$NPM_CACHE_VOLUME\" >/dev/null\n echo \"Created npm cache volume: $NPM_CACHE_VOLUME\"\nfi\n\ndocker run --rm \\\n -v \"$PWD:/workspace\" \\\n -v \"$NPM_CACHE_VOLUME:/workspace/apps/web/node_modules\" -w /workspace/apps/web \\\n docker.m.daocloud.io/library/node:20 \\\n sh -lc 'PACKAGE_LOCK_HASH=$(md5sum package-lock.json 2>/dev/null | cut -d\" \" -f1)\nCACHE_HASH_FILE=\"node_modules/.package-lock-hash\"\nCACHE_VALID=false\nif [ -f \"$CACHE_HASH_FILE\" ] && [ \"$(cat \"$CACHE_HASH_FILE\")\" = \"$PACKAGE_LOCK_HASH\" ] && [ -x \"node_modules/.bin/eslint\" ] && [ -x \"node_modules/.bin/tsc\" ] && [ -x \"node_modules/.bin/prettier\" ] && [ -x \"node_modules/.bin/vitest\" ]; then\n CACHE_VALID=true\n echo \"Cache hit: dependencies valid, skipping npm ci\"\nfi\nif [ \"$CACHE_VALID\" = \"false\" ]; then\n echo \"Cache miss or invalid: running npm ci...\"\n if ! npm ci --include=dev; then\n echo \"npm ci failed, cleaning node_modules and retrying...\"\n rm -rf node_modules\n mkdir -p node_modules\n npm ci --include=dev\n fi\n # Post-install integrity check: verify all critical tools exist\n if [ ! -x \"node_modules/.bin/eslint\" ] || [ ! -x \"node_modules/.bin/tsc\" ] || [ ! -x \"node_modules/.bin/prettier\" ] || [ ! -x \"node_modules/.bin/vitest\" ]; then\n echo \"Post-install check failed: critical binaries missing, cleaning and retrying...\"\n rm -rf node_modules\n mkdir -p node_modules\n npm ci --include=dev\n fi\n echo \"$PACKAGE_LOCK_HASH\" > \"$CACHE_HASH_FILE\"\n echo \"Dependencies installed, cache updated\"\nfi'\n"
|
|
|
|
|
run: "set -eu\nNPM_CACHE_VOLUME=\"xiaoxia-npm-cache\"\nif ! docker volume inspect \"$NPM_CACHE_VOLUME\" >/dev/null 2>&1; then\n docker volume create \"$NPM_CACHE_VOLUME\" >/dev/null\n echo \"Created npm cache volume: $NPM_CACHE_VOLUME\"\nfi\n\ndocker run --rm \\\n -v \"$PWD:/workspace\" \\\n -v \"$NPM_CACHE_VOLUME:/workspace/apps/web/node_modules\" -w /workspace/apps/web \\\n docker.m.daocloud.io/library/node:20 \\\n sh -lc 'PACKAGE_LOCK_HASH=$(md5sum package-lock.json 2>/dev/null | cut -d\" \" -f1)\nCACHE_HASH_FILE=\"node_modules/.package-lock-hash\"\nCACHE_VALID=false\nif [ -f \"$CACHE_HASH_FILE\" ] && [ \"$(cat \"$CACHE_HASH_FILE\")\" = \"$PACKAGE_LOCK_HASH\" ] && [ -x \"node_modules/.bin/eslint\" ]; then\n CACHE_VALID=true\n echo \"Cache hit: dependencies valid, skipping npm ci\"\nfi\nif [ \"$CACHE_VALID\" = \"false\" ]; then\n echo \"Cache miss or invalid: running npm ci...\"\n if ! npm ci --include=dev; then\n echo \"npm ci failed, cleaning node_modules and retrying...\"\n rm -rf node_modules\n mkdir -p node_modules\n npm ci --include=dev\n fi\n echo \"$PACKAGE_LOCK_HASH\" > \"$CACHE_HASH_FILE\"\n echo \"Dependencies installed, cache updated\"\nfi'\n"
|
|
|
|
|
- name: Run ESLint
|
|
|
|
|
shell: sh
|
|
|
|
|
run: "set -eu\nNPM_CACHE_VOLUME=\"xiaoxia-npm-cache\"\nif ! docker volume inspect \"$NPM_CACHE_VOLUME\" >/dev/null 2>&1; then\n docker volume create \"$NPM_CACHE_VOLUME\" >/dev/null\n echo \"Created npm cache volume: $NPM_CACHE_VOLUME\"\nfi\n\ndocker run --rm \\\n -v \"$PWD:/workspace\" \\\n -v \"$NPM_CACHE_VOLUME:/workspace/apps/web/node_modules\" -w /workspace/apps/web \\\n docker.m.daocloud.io/library/node:20 \\\n sh -lc 'npx --no-install eslint src --ext .ts,.tsx --max-warnings 50'\n"
|
|
|
|
@@ -448,20 +448,8 @@ jobs:
|
|
|
|
|
run: "set -eu\n# 确保使用 docker-container driver 以支持 cache export 功能\nif ! docker buildx inspect ci-builder > /dev/null 2>&1; then\n docker buildx create --use --name ci-builder --driver docker-container\n echo \"Created ci-builder (docker-container driver)\"\nelse\n docker buildx use ci-builder\n echo \"Using existing ci-builder\"\nfi\ndocker buildx inspect --bootstrap\n"
|
|
|
|
|
- name: Build and push API image (buildx cache)
|
|
|
|
|
shell: sh
|
|
|
|
|
run: "set -eu
|
|
|
|
|
REGISTRY=\"git.xiaoxiajianji.com/xiaoxia/xiaoxia-saas\"
|
|
|
|
|
IMAGE_TAG=\"${REGISTRY}/xiaoxia-saas-api:${GITHUB_SHA}\"
|
|
|
|
|
CACHE_REF=\"${REGISTRY}/api-cache:${GITHUB_REF_NAME}\"
|
|
|
|
|
|
|
|
|
|
bash scripts/ci/docker_build_push.sh \
|
|
|
|
|
infra/docker/api.Dockerfile \
|
|
|
|
|
\"${IMAGE_TAG}\" \
|
|
|
|
|
\"${CACHE_REF}\" \
|
|
|
|
|
APP_VERSION=\"${GITHUB_SHA}\"
|
|
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
echo \"API image pushed: ${IMAGE_TAG}\"
|
|
|
|
|
"
|
|
|
|
|
run: "set -eu\nREGISTRY=\"git.xiaoxiajianji.com/xiaoxia/xiaoxia-saas\"\nIMAGE_NAME=\"xiaoxia-saas-api\"\nCACHE_REF=\"${REGISTRY}/api-cache:develop\"\n\nCACHE_FROM=\"type=registry,ref=${CACHE_REF},ignore-error=true\"\n\nif [ \"${CACHE_MODE}\" = \"read-write\" ]; then\n CACHE_TO=\"type=registry,ref=${CACHE_REF},mode=max\"\n echo \"Building API image with read-write cache...\"\n docker buildx build --build-arg APP_VERSION=\"${GITHUB_SHA}\" --cache-from \"${CACHE_FROM}\" --cache-to \"${CACHE_TO}\" -f infra/docker/api.Dockerfile -t \"${REGISTRY}/${IMAGE_NAME}:${GITHUB_SHA}\" --push .\nelse\n echo \"Building API image with read-only cache...\"\n docker buildx build --build-arg APP_VERSION=\"${GITHUB_SHA}\" --cache-from \"${CACHE_FROM}\" -f infra/docker/api.Dockerfile -t \"${REGISTRY}/${IMAGE_NAME}:${GITHUB_SHA}\" --push .\nfi\necho\
|
|
|
|
|
\ \"API image pushed: ${REGISTRY}/${IMAGE_NAME}:${GITHUB_SHA}\"\n"
|
|
|
|
|
- name: Job duration summary
|
|
|
|
|
if: always()
|
|
|
|
|
shell: sh
|
|
|
|
@@ -522,20 +510,8 @@ echo \"API image pushed: ${IMAGE_TAG}\"
|
|
|
|
|
run: "set -eu\n# 确保使用 docker-container driver 以支持 cache export 功能\nif ! docker buildx inspect ci-builder > /dev/null 2>&1; then\n docker buildx create --use --name ci-builder --driver docker-container\n echo \"Created ci-builder (docker-container driver)\"\nelse\n docker buildx use ci-builder\n echo \"Using existing ci-builder\"\nfi\ndocker buildx inspect --bootstrap\n"
|
|
|
|
|
- name: Build and push Worker image (buildx cache)
|
|
|
|
|
shell: sh
|
|
|
|
|
run: "set -eu
|
|
|
|
|
REGISTRY=\"git.xiaoxiajianji.com/xiaoxia/xiaoxia-saas\"
|
|
|
|
|
IMAGE_TAG=\"${REGISTRY}/xiaoxia-saas-worker:${GITHUB_SHA}\"
|
|
|
|
|
CACHE_REF=\"${REGISTRY}/worker-cache:${GITHUB_REF_NAME}\"
|
|
|
|
|
|
|
|
|
|
bash scripts/ci/docker_build_push.sh \
|
|
|
|
|
infra/docker/worker.Dockerfile \
|
|
|
|
|
\"${IMAGE_TAG}\" \
|
|
|
|
|
\"${CACHE_REF}\" \
|
|
|
|
|
APP_VERSION=\"${GITHUB_SHA}\"
|
|
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
echo \"WORKER image pushed: ${IMAGE_TAG}\"
|
|
|
|
|
"
|
|
|
|
|
run: "set -eu\nREGISTRY=\"git.xiaoxiajianji.com/xiaoxia/xiaoxia-saas\"\nIMAGE_NAME=\"xiaoxia-saas-worker\"\nCACHE_REF=\"${REGISTRY}/worker-cache:develop\"\n\nCACHE_FROM=\"type=registry,ref=${CACHE_REF},ignore-error=true\"\n\nif [ \"${CACHE_MODE}\" = \"read-write\" ]; then\n CACHE_TO=\"type=registry,ref=${CACHE_REF},mode=min\"\n echo \"Building Worker image with read-write cache...\"\n docker buildx build --build-arg APP_VERSION=\"${GITHUB_SHA}\" --cache-from \"${CACHE_FROM}\" --cache-to \"${CACHE_TO}\" -f infra/docker/worker.Dockerfile -t \"${REGISTRY}/${IMAGE_NAME}:${GITHUB_SHA}\" --push .\nelse\n echo \"Building Worker image with read-only cache...\"\n docker buildx build --build-arg APP_VERSION=\"${GITHUB_SHA}\" --cache-from \"${CACHE_FROM}\" -f infra/docker/worker.Dockerfile -t \"${REGISTRY}/${IMAGE_NAME}:${GITHUB_SHA}\" --push \
|
|
|
|
|
\ .\nfi\necho \"Worker image pushed: ${REGISTRY}/${IMAGE_NAME}:${GITHUB_SHA}\"\n"
|
|
|
|
|
- name: Job duration summary
|
|
|
|
|
if: always()
|
|
|
|
|
shell: sh
|
|
|
|
@@ -599,20 +575,8 @@ echo \"WORKER image pushed: ${IMAGE_TAG}\"
|
|
|
|
|
run: "set -eu\n# 确保使用 docker-container driver 以支持 cache export 功能\nif ! docker buildx inspect ci-builder > /dev/null 2>&1; then\n docker buildx create --use --name ci-builder --driver docker-container\n echo \"Created ci-builder (docker-container driver)\"\nelse\n docker buildx use ci-builder\n echo \"Using existing ci-builder\"\nfi\ndocker buildx inspect --bootstrap\n"
|
|
|
|
|
- name: Build and push Web image (buildx cache)
|
|
|
|
|
shell: sh
|
|
|
|
|
run: "set -eu
|
|
|
|
|
REGISTRY=\"git.xiaoxiajianji.com/xiaoxia/xiaoxia-saas\"
|
|
|
|
|
IMAGE_TAG=\"${REGISTRY}/xiaoxia-saas-web:${GITHUB_SHA}\"
|
|
|
|
|
CACHE_REF=\"${REGISTRY}/web-cache:${GITHUB_REF_NAME}\"
|
|
|
|
|
|
|
|
|
|
bash scripts/ci/docker_build_push.sh \
|
|
|
|
|
infra/docker/web.Dockerfile \
|
|
|
|
|
\"${IMAGE_TAG}\" \
|
|
|
|
|
\"${CACHE_REF}\" \
|
|
|
|
|
APP_VERSION=\"${GITHUB_SHA}\"
|
|
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
echo \"WEB image pushed: ${IMAGE_TAG}\"
|
|
|
|
|
"
|
|
|
|
|
run: "set -eu\nREGISTRY=\"git.xiaoxiajianji.com/xiaoxia/xiaoxia-saas\"\nIMAGE_NAME=\"xiaoxia-saas-web\"\nCACHE_REF=\"${REGISTRY}/web-cache:develop\"\nNGINX_CONF=\"infra/docker/nginx-staging.conf\"\n\nCACHE_FROM=\"type=registry,ref=${CACHE_REF},ignore-error=true\"\n\nif [ \"${CACHE_MODE}\" = \"read-write\" ]; then\n CACHE_TO=\"type=registry,ref=${CACHE_REF},mode=max\"\n echo \"Building Web image with read-write cache...\"\n docker buildx build --cache-from \"${CACHE_FROM}\" --cache-to \"${CACHE_TO}\" -f infra/docker/web-artifact.Dockerfile --build-arg \"NGINX_CONF=${NGINX_CONF}\" -t \"${REGISTRY}/${IMAGE_NAME}:${GITHUB_SHA}\" --push .\nelse\n echo \"Building Web image with read-only cache...\"\n docker buildx build --cache-from \"${CACHE_FROM}\" -f infra/docker/web-artifact.Dockerfile --build-arg \"NGINX_CONF=${NGINX_CONF}\" -t \"${REGISTRY}/${IMAGE_NAME}:${GITHUB_SHA}\"\
|
|
|
|
|
\ --push .\nfi\necho \"Web image pushed: ${REGISTRY}/${IMAGE_NAME}:${GITHUB_SHA}\"\n"
|
|
|
|
|
- name: Job duration summary
|
|
|
|
|
if: always()
|
|
|
|
|
shell: sh
|
|
|
|
@@ -861,20 +825,24 @@ echo \"WEB image pushed: ${IMAGE_TAG}\"
|
|
|
|
|
run: "set -eu\n# 确保使用 docker-container driver 以支持 cache export 功能\nif ! docker buildx inspect ci-builder > /dev/null 2>&1; then\n docker buildx create --use --name ci-builder --driver docker-container\n echo \"Created ci-builder (docker-container driver)\"\nelse\n docker buildx use ci-builder\n echo \"Using existing ci-builder\"\nfi\ndocker buildx inspect --bootstrap\n"
|
|
|
|
|
- name: Build and push API image (buildx cache)
|
|
|
|
|
shell: sh
|
|
|
|
|
run: "set -eu
|
|
|
|
|
REGISTRY=\"git.xiaoxiajianji.com/xiaoxia/xiaoxia-saas\"
|
|
|
|
|
IMAGE_TAG=\"${REGISTRY}/xiaoxia-saas-api:${GITHUB_SHA}\"
|
|
|
|
|
CACHE_REF=\"${REGISTRY}/api-cache:${GITHUB_REF_NAME}\"
|
|
|
|
|
run: 'set -eu
|
|
|
|
|
|
|
|
|
|
bash scripts/ci/docker_build_push.sh \
|
|
|
|
|
infra/docker/api.Dockerfile \
|
|
|
|
|
\"${IMAGE_TAG}\" \
|
|
|
|
|
\"${CACHE_REF}\" \
|
|
|
|
|
APP_VERSION=\"${GITHUB_SHA}\"
|
|
|
|
|
REGISTRY="git.xiaoxiajianji.com/xiaoxia/xiaoxia-saas"
|
|
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
echo \"API image pushed: ${IMAGE_TAG}\"
|
|
|
|
|
"
|
|
|
|
|
IMAGE_NAME="xiaoxia-saas-api"
|
|
|
|
|
|
|
|
|
|
VERSION="${GITHUB_REF_NAME}"
|
|
|
|
|
|
|
|
|
|
CACHE_REF="${REGISTRY}/api-cache:main"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo "Building Production API image: ${VERSION}"
|
|
|
|
|
|
|
|
|
|
docker buildx build --build-arg APP_VERSION="${VERSION}" --cache-from "type=registry,ref=${CACHE_REF},ignore-error=true" --cache-to "type=registry,ref=${CACHE_REF},mode=max" -f infra/docker/api.Dockerfile -t "${REGISTRY}/${IMAGE_NAME}:${VERSION}" --push .
|
|
|
|
|
|
|
|
|
|
echo "Production API image pushed: ${REGISTRY}/${IMAGE_NAME}:${VERSION}"
|
|
|
|
|
|
|
|
|
|
'
|
|
|
|
|
- name: Job duration summary
|
|
|
|
|
if: always()
|
|
|
|
|
shell: sh
|
|
|
|
@@ -932,20 +900,24 @@ echo \"API image pushed: ${IMAGE_TAG}\"
|
|
|
|
|
run: "set -eu\n# 确保使用 docker-container driver 以支持 cache export 功能\nif ! docker buildx inspect ci-builder > /dev/null 2>&1; then\n docker buildx create --use --name ci-builder --driver docker-container\n echo \"Created ci-builder (docker-container driver)\"\nelse\n docker buildx use ci-builder\n echo \"Using existing ci-builder\"\nfi\ndocker buildx inspect --bootstrap\n"
|
|
|
|
|
- name: Build and push Worker image (buildx cache)
|
|
|
|
|
shell: sh
|
|
|
|
|
run: "set -eu
|
|
|
|
|
REGISTRY=\"git.xiaoxiajianji.com/xiaoxia/xiaoxia-saas\"
|
|
|
|
|
IMAGE_TAG=\"${REGISTRY}/xiaoxia-saas-worker:${GITHUB_SHA}\"
|
|
|
|
|
CACHE_REF=\"${REGISTRY}/worker-cache:${GITHUB_REF_NAME}\"
|
|
|
|
|
run: 'set -eu
|
|
|
|
|
|
|
|
|
|
bash scripts/ci/docker_build_push.sh \
|
|
|
|
|
infra/docker/worker.Dockerfile \
|
|
|
|
|
\"${IMAGE_TAG}\" \
|
|
|
|
|
\"${CACHE_REF}\" \
|
|
|
|
|
APP_VERSION=\"${GITHUB_SHA}\"
|
|
|
|
|
REGISTRY="git.xiaoxiajianji.com/xiaoxia/xiaoxia-saas"
|
|
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
echo \"WORKER image pushed: ${IMAGE_TAG}\"
|
|
|
|
|
"
|
|
|
|
|
IMAGE_NAME="xiaoxia-saas-worker"
|
|
|
|
|
|
|
|
|
|
VERSION="${GITHUB_REF_NAME}"
|
|
|
|
|
|
|
|
|
|
CACHE_REF="${REGISTRY}/worker-cache:main"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo "Building Production Worker image: ${VERSION}"
|
|
|
|
|
|
|
|
|
|
docker buildx build --build-arg APP_VERSION="${VERSION}" --cache-from "type=registry,ref=${CACHE_REF},ignore-error=true" --cache-to "type=registry,ref=${CACHE_REF},mode=min" -f infra/docker/worker.Dockerfile -t "${REGISTRY}/${IMAGE_NAME}:${VERSION}" --push .
|
|
|
|
|
|
|
|
|
|
echo "Production Worker image pushed: ${REGISTRY}/${IMAGE_NAME}:${VERSION}"
|
|
|
|
|
|
|
|
|
|
'
|
|
|
|
|
- name: Job duration summary
|
|
|
|
|
if: always()
|
|
|
|
|
shell: sh
|
|
|
|
@@ -1006,20 +978,26 @@ echo \"WORKER image pushed: ${IMAGE_TAG}\"
|
|
|
|
|
run: "set -eu\n# 确保使用 docker-container driver 以支持 cache export 功能\nif ! docker buildx inspect ci-builder > /dev/null 2>&1; then\n docker buildx create --use --name ci-builder --driver docker-container\n echo \"Created ci-builder (docker-container driver)\"\nelse\n docker buildx use ci-builder\n echo \"Using existing ci-builder\"\nfi\ndocker buildx inspect --bootstrap\n"
|
|
|
|
|
- name: Build and push Web image (buildx cache)
|
|
|
|
|
shell: sh
|
|
|
|
|
run: "set -eu
|
|
|
|
|
REGISTRY=\"git.xiaoxiajianji.com/xiaoxia/xiaoxia-saas\"
|
|
|
|
|
IMAGE_TAG=\"${REGISTRY}/xiaoxia-saas-web:${GITHUB_SHA}\"
|
|
|
|
|
CACHE_REF=\"${REGISTRY}/web-cache:${GITHUB_REF_NAME}\"
|
|
|
|
|
run: 'set -eu
|
|
|
|
|
|
|
|
|
|
bash scripts/ci/docker_build_push.sh \
|
|
|
|
|
infra/docker/web.Dockerfile \
|
|
|
|
|
\"${IMAGE_TAG}\" \
|
|
|
|
|
\"${CACHE_REF}\" \
|
|
|
|
|
APP_VERSION=\"${GITHUB_SHA}\"
|
|
|
|
|
REGISTRY="git.xiaoxiajianji.com/xiaoxia/xiaoxia-saas"
|
|
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
echo \"WEB image pushed: ${IMAGE_TAG}\"
|
|
|
|
|
"
|
|
|
|
|
IMAGE_NAME="xiaoxia-saas-web"
|
|
|
|
|
|
|
|
|
|
VERSION="${GITHUB_REF_NAME}"
|
|
|
|
|
|
|
|
|
|
CACHE_REF="${REGISTRY}/web-cache:main"
|
|
|
|
|
|
|
|
|
|
NGINX_CONF="infra/docker/nginx-production.conf"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo "Building Production Web image: ${VERSION}"
|
|
|
|
|
|
|
|
|
|
docker buildx build --cache-from "type=registry,ref=${CACHE_REF},ignore-error=true" --cache-to "type=registry,ref=${CACHE_REF},mode=max" -f infra/docker/web-artifact.Dockerfile --build-arg "NGINX_CONF=${NGINX_CONF}" -t "${REGISTRY}/${IMAGE_NAME}:${VERSION}" --push .
|
|
|
|
|
|
|
|
|
|
echo "Production Web image pushed: ${REGISTRY}/${IMAGE_NAME}:${VERSION}"
|
|
|
|
|
|
|
|
|
|
'
|
|
|
|
|
- name: Cleanup old Docker images
|
|
|
|
|
if: always()
|
|
|
|
|
shell: sh
|
|
|
|
|