Spaces:
Running
Running
File size: 717 Bytes
e3bbdaf 7897a78 e3bbdaf | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | # 使用Node.js作为基础镜像进行构建
FROM node:18-alpine AS build-stage
# 设置工作目录
WORKDIR /app
# 安装pnpm
RUN npm install -g pnpm
# 复制依赖文件并安装
COPY package.json pnpm-lock.yaml ./
RUN pnpm install
# 复制源代码并构建 H5 版本
COPY . .
RUN pnpm run build:h5
# 使用Nginx作为基础镜像进行部署
FROM nginx:stable-alpine AS production-stage
# 复制构建好的静态文件到Nginx目录
# UniApp H5 默认构建目录是 dist/build/h5
COPY --from=build-stage /app/dist/build/h5 /usr/share/nginx/html
# 复制自定义Nginx配置
COPY nginx.conf /etc/nginx/conf.d/default.conf
# 暴露7860端口
EXPOSE 7860
# 启动Nginx
CMD ["nginx", "-g", "daemon off;"]
|