2023-03-24 09:34:44 +08:00
|
|
|
FROM node:18 AS build
|
|
|
|
|
2023-03-20 10:10:17 +08:00
|
|
|
# 创建一个项目文件夹,可自定义
|
|
|
|
WORKDIR /app
|
|
|
|
# 将本地文件复制到项目文件夹下
|
2023-03-20 17:23:47 +08:00
|
|
|
COPY ./apps/server/ .
|
2023-03-20 17:17:07 +08:00
|
|
|
|
|
|
|
RUN ls -a
|
2023-03-20 10:10:17 +08:00
|
|
|
RUN npm set registry https://registry.npm.taobao.org
|
2023-03-24 09:34:44 +08:00
|
|
|
RUN npm install
|
|
|
|
RUN npm run build
|
|
|
|
|
|
|
|
|
2023-03-20 10:10:17 +08:00
|
|
|
|
|
|
|
# 切换镜像文件, alpine镜像打包后更小
|
2023-03-24 09:34:44 +08:00
|
|
|
FROM node:18-alpine
|
2023-03-20 10:10:17 +08:00
|
|
|
# 切换工作目录
|
|
|
|
WORKDIR /app
|
|
|
|
# 将打包后的的文件复制到docker镜像里
|
2023-03-20 17:21:49 +08:00
|
|
|
COPY --from=build /app/dist ./dist
|
|
|
|
|
2023-03-20 17:23:47 +08:00
|
|
|
RUN ls -a
|
|
|
|
|
2023-03-20 17:21:49 +08:00
|
|
|
# 把源代码复制过去, 以便报错能报对行
|
2023-03-20 10:10:17 +08:00
|
|
|
COPY --from=build /app/src ./src
|
|
|
|
COPY --from=build /app/bootstrap.js ./
|
|
|
|
COPY --from=build /app/package.json ./
|
2023-03-20 17:34:48 +08:00
|
|
|
COPY --from=build /app/public ./public
|
2023-03-20 21:42:43 +08:00
|
|
|
COPY --from=build /app/.env ./
|
2023-03-20 10:10:17 +08:00
|
|
|
|
|
|
|
ENV TZ="Asia/Shanghai"
|
|
|
|
|
|
|
|
RUN npm set registry https://registry.npm.taobao.org
|
|
|
|
|
|
|
|
# 安装工程依赖
|
|
|
|
RUN npm install --production
|
|
|
|
# 设置暴露端口
|
|
|
|
EXPOSE 7001
|
|
|
|
# 启动
|
|
|
|
CMD ["npm", "run", "start"]
|