添加docker文件
Some checks failed
CI Pipeline / build (push) Failing after 4m22s

This commit is contained in:
2025-08-24 13:58:31 +08:00
parent aeacbab06c
commit e0ec4bd324
5 changed files with 122 additions and 11 deletions

View File

@@ -1,12 +1,21 @@
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install --production
# 第一阶段node镜像打包
FROM node:20-alpine AS frontend-builder
WORKDIR /build-app
COPY . .
RUN npm install
RUN npm add -D vitepress
RUN npm run docs:build
EXPOSE 3000
# 第二阶段nginx打包
FROM nginx:1.25-alpine
EXPOSE 80
WORKDIR /app
# 替换nginx配置
COPY nginx.conf /etc/nginx/conf.d/default.conf
# 将第一阶段的静态文件复制到nginx中
RUN rm -rf /usr/share/nginx/html
RUN mkdir /usr/share/nginx/html
COPY --from=frontend-builder /build-app/docs/.vitepress/dist /usr/share/nginx/html
CMD ["node", "index.js"]
# 运行
CMD ["nginx", "-g", "daemon off;"]