TOPVERSE_Official/Dockerfile

38 lines
783 B
Docker
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

FROM node:21 AS build
# 容器内的目录通常我们会使用 app 目录
WORKDIR /app
# 拷贝项目文件到容器/app下
COPY . .
# ARG env_file
RUN npm config set registry https://registry.npmmirror.com
RUN npm install -g pnpm
RUN pnpm config set registry https://registry.npmmirror.com
# 下载编译
RUN pnpm i
RUN pnpm build
RUN pnpm generate
# RUN yarn config set registry https://registry.npmmirror.com
# RUN yarn
# RUN yarn build
# RUN yarn generate
# nginx默认暴露80端口
FROM nginx
# 更换工作目录到nginx服务目录下
WORKDIR /usr/share/nginx/html
# 删除服务下可能存在的无用项目
RUN rm -rf ./*
# 复制自定义的 Nginx 配置文件
COPY nginx.conf /etc/nginx/nginx.conf
# 拷贝打包的文件
COPY --from=build /app/dist .