web-backset.cn/Dockerfile.release
2023-03-20 21:42:43 +08:00

42 lines
1.0 KiB
Docker

# 拉取的原镜像
FROM node:16.19-alpine AS build
# 创建一个项目文件夹,可自定义
WORKDIR /app
# 将本地文件复制到项目文件夹下
COPY ./apps/server/ .
RUN ls -a
# 切换到淘宝镜像,安装依赖比较快
RUN npm set registry https://registry.npm.taobao.org
# 安装依赖
RUN npm install -g pnpm
RUN pnpm i
# 打包项目
RUN pnpm build
# 切换镜像文件, alpine镜像打包后更小
FROM node:16.19-alpine
# 切换工作目录
WORKDIR /app
# 将打包后的的文件复制到docker镜像里
COPY --from=build /app/dist ./dist
RUN ls -a
# 把源代码复制过去, 以便报错能报对行
COPY --from=build /app/src ./src
COPY --from=build /app/bootstrap.js ./
COPY --from=build /app/package.json ./
COPY --from=build /app/public ./public
COPY --from=build /app/.env ./
ENV TZ="Asia/Shanghai"
RUN npm set registry https://registry.npm.taobao.org
# 安装工程依赖
RUN npm install --production
# 设置暴露端口
EXPOSE 7001
# 启动
CMD ["npm", "run", "start"]