website/Dockerfile

42 lines
830 B
Docker
Raw Normal View History

2024-05-25 15:21:34 +08:00
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
2024-05-25 22:15:59 +08:00
# RUN pnpm build
2024-05-25 23:12:37 +08:00
RUN pnpm build
2024-05-25 15:21:34 +08:00
# RUN yarn config set registry https://registry.npmmirror.com
# RUN yarn
# RUN yarn build
# RUN yarn generate
2024-05-25 23:12:37 +08:00
EXPOSE 3000
CMD [ "pnpm", "preview"]
2024-05-25 15:21:34 +08:00
# nginx默认暴露80端口
2024-05-25 23:12:37 +08:00
# FROM nginx
2024-05-25 15:21:34 +08:00
# 更换工作目录到nginx服务目录下
2024-05-25 23:12:37 +08:00
# WORKDIR /usr/share/nginx/html
2024-05-25 15:21:34 +08:00
# 删除服务下可能存在的无用项目
2024-05-25 23:12:37 +08:00
# RUN rm -rf ./*
2024-05-25 15:21:34 +08:00
# 复制自定义的 Nginx 配置文件
2024-05-25 23:12:37 +08:00
# COPY nginx.conf /etc/nginx/nginx.conf
2024-05-25 15:21:34 +08:00
# 拷贝打包的文件
2024-05-25 23:12:37 +08:00
# COPY --from=build /app/dist .