Files
litek/Dockerfile
typist c11bb6d637 feat: add Docker support with multi-stage build and CI/CD workflow
- Introduced Dockerfile for multi-stage application build and deployment using Nginx.
- Added .dockerignore to exclude unnecessary files from the 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.
2025-10-27 20:16:22 +08:00

37 lines
632 B
Docker

# 第一阶段: 构建应用
FROM node:22-alpine AS builder
# 安装 pnpm
RUN corepack enable && corepack prepare pnpm@latest --activate
# 设置工作目录
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;"]