This commit is contained in:
@ -16,3 +16,6 @@ dist
|
||||
*.swp
|
||||
*.swo
|
||||
*~
|
||||
bun.lock
|
||||
.git
|
||||
.gitea
|
@ -12,6 +12,9 @@ jobs:
|
||||
- name: 释放内存
|
||||
run: docker system prune -a -f
|
||||
|
||||
- name: 设置 Docker Buildx
|
||||
run: docker buildx create --use
|
||||
|
||||
- name: 拉取自定义 checkout action
|
||||
run: git clone http://114.67.155.184:3000//niyyzf/checkout.git ./.actions/checkout
|
||||
|
||||
@ -23,7 +26,7 @@ jobs:
|
||||
max-attempts: 5
|
||||
|
||||
- name: 构建 Docker 镜像
|
||||
run: docker build -t watch-stock-list:latest .
|
||||
run: docker build --cache-from type=gha --cache-to type=gha,mode=max -t watch-stock-list:latest .
|
||||
|
||||
- name: 启动/重启服务(Docker Compose)
|
||||
run: |
|
||||
|
@ -9,7 +9,9 @@ WORKDIR /app
|
||||
|
||||
# 安装依赖
|
||||
COPY package.json ./
|
||||
RUN npm install
|
||||
# 使用 npm 缓存来加速构建
|
||||
RUN npm config set cache /tmp/npm-cache && \
|
||||
npm install --cache /tmp/npm-cache --prefer-offline --no-audit --no-fund
|
||||
|
||||
# 构建阶段
|
||||
FROM base AS builder
|
||||
|
25
build.sh
Normal file
25
build.sh
Normal file
@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 本地构建脚本 - 包含缓存优化
|
||||
set -e
|
||||
|
||||
echo "🚀 开始构建 Docker 镜像..."
|
||||
|
||||
# 清理旧镜像(可选)
|
||||
# docker system prune -f
|
||||
|
||||
# 使用 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 \
|
||||
.
|
||||
|
||||
echo "✅ 构建完成!"
|
||||
|
||||
# 启动容器(可选)
|
||||
echo "🐳 启动容器..."
|
||||
docker-compose up -d
|
||||
|
||||
echo "🎉 部署完成!应用运行在 http://localhost:7799"
|
Reference in New Issue
Block a user