This commit is contained in:
@ -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
|
@ -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
18
build-docker.sh
Normal 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"
|
4
build.sh
4
build.sh
@ -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 \
|
||||
.
|
||||
|
Reference in New Issue
Block a user