修复缓存
Some checks failed
构建并运行 Docker / build (push) Failing after 12m17s

This commit is contained in:
2025-07-29 14:25:03 +08:00
parent cfdc5e5d9a
commit f96e141b17
4 changed files with 26 additions and 11 deletions

View File

@ -13,7 +13,9 @@ jobs:
run: docker system prune -a -f
- name: 设置 Docker Buildx
run: docker buildx create --use
run: |
docker buildx create --use --name builder
docker buildx inspect --bootstrap
- name: 拉取自定义 checkout action
run: git clone http://114.67.155.184:3000//niyyzf/checkout.git ./.actions/checkout
@ -25,10 +27,7 @@ jobs:
persist-credentials: false
max-attempts: 5
- name: 构建 Docker 镜像
run: docker build --cache-from type=gha --cache-to type=gha,mode=max -t watch-stock-list:latest .
- name: 启动/重启服务Docker Compose
- name: 构建并部署
run: |
docker compose down || true
docker compose up -d --force-recreate
chmod +x build-docker.sh
./build-docker.sh

View File

@ -11,7 +11,7 @@ WORKDIR /app
COPY package.json ./
# 使用 npm 缓存来加速构建
RUN npm config set cache /tmp/npm-cache && \
npm install --cache /tmp/npm-cache --prefer-offline --no-audit --no-fund
npm install --cache /tmp/npm-cache --prefer-offline --no-audit --no-fund --production=false
# 构建阶段
FROM base AS builder

18
build-docker.sh Normal file
View File

@ -0,0 +1,18 @@
#!/bin/bash
# Gitea Actions 专用构建脚本
set -e
echo "🚀 开始构建 Docker 镜像..."
# 使用标准 docker build 命令
docker build -t watch-stock-list:latest .
echo "✅ 构建完成!"
# 启动容器
echo "🐳 启动容器..."
docker-compose down || true
docker-compose up -d --force-recreate
echo "🎉 部署完成!应用运行在 http://localhost:7799"

View File

@ -8,10 +8,8 @@ echo "🚀 开始构建 Docker 镜像..."
# 清理旧镜像(可选)
# docker system prune -f
# 使用 Buildx 和缓存构建
# 使用 Buildx 构建
docker buildx build \
--cache-from type=local,src=/tmp/.buildx-cache \
--cache-to type=local,dest=/tmp/.buildx-cache,mode=max \
--tag watch-stock-list:latest \
--load \
.