feat: add Docker support with multi-stage build and CI/CD workflow
All checks were successful
Build and Push Docker Image / build (push) Successful in 1m42s

- Introduced Dockerfile for multi-stage build process using Node.js and Nginx.
- Added .dockerignore to exclude unnecessary files from Docker context.
- Created nginx.conf for server configuration, including gzip compression and SPA routing.
- Implemented Gitea CI/CD workflow for building and pushing Docker images on version tags.
This commit is contained in:
typist
2025-10-27 22:32:54 +08:00
parent a1e2239458
commit 10bc8fe7cb
4 changed files with 220 additions and 0 deletions

36
Dockerfile Normal file
View File

@@ -0,0 +1,36 @@
# 第一阶段: 构建应用
FROM node:22-alpine AS builder
# 安装 pnpm
RUN npm install -g pnpm
# 设置工作目录
WORKDIR /app
# 复制依赖配置文件
COPY package.json pnpm-lock.yaml ./
# 安装依赖
RUN pnpm install --frozen-lockfile
# 复制源代码
COPY . .
# 构建应用
RUN pnpm build
# 第二阶段: 运行应用
FROM nginx:alpine
# 复制自定义 nginx 配置
COPY nginx.conf /etc/nginx/nginx.conf
# 从构建阶段复制构建产物
COPY --from=builder /app/dist /usr/share/nginx/html
# 暴露端口
EXPOSE 80
# 启动 nginx
CMD ["nginx", "-g", "daemon off;"]