26 lines
689 B
Docker
26 lines
689 B
Docker
FROM registry.cn-shanghai.aliyuncs.com/server1024/node:16.17.1 AS build-stage
|
|
|
|
WORKDIR /mht/
|
|
COPY . .
|
|
|
|
# 设置国内源并调试网络问题
|
|
RUN npm config set registry https://registry.npmmirror.com
|
|
RUN npm config set network-timeout 600000
|
|
|
|
RUN npm install --legacy-peer-deps
|
|
# 确保 vite 已经全局安装
|
|
RUN npm install -g vite
|
|
|
|
# 检查 vite 是否安装成功
|
|
RUN vite --version
|
|
|
|
ARG ENV=prod
|
|
|
|
# 运行构建命令
|
|
RUN npm run build:${ENV}
|
|
|
|
FROM registry.cn-shanghai.aliyuncs.com/server1024/nginx:base AS production-stage
|
|
|
|
COPY .docker-compose/nginx/conf.d/my.conf /etc/nginx/conf.d/my.conf
|
|
COPY --from=build-stage /mht/dist /usr/share/nginx/html
|
|
RUN ls -al /usr/share/nginx/html |