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