自动工作流

This commit is contained in:
cheney 2026-04-05 15:40:30 +08:00
parent 64c4a03241
commit 0c4db31b56
3 changed files with 40 additions and 1 deletions

View File

@ -0,0 +1,16 @@
name: Docker Build and Push
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

23
Dockerfile Normal file
View File

@ -0,0 +1,23 @@
# 使用官方Node.js 18镜像作为基础
FROM node:18-alpine
# 设置工作目录
WORKDIR /app
# 复制package.json和package-lock.json
COPY package*.json ./
# 安装依赖
RUN npm install
# 复制项目文件
COPY . .
# 构建项目
RUN npm run build
# 暴露3000端口
EXPOSE 3000
# 启动生产服务器
CMD ["npm", "start"]