automated_api/Dockerfile
lixin a469e0f595
All checks were successful
continuous-integration/drone/push Build is passing
build(Dockerfile): 注释掉删除开发依赖和安装生产依赖的命令
- 注释掉了删除开发期依赖的命令: RUN rm -rf node_modules && rm package-lock.json
- 注释掉了安装生产环境依赖的命令: RUN pnpm install --production
- 这些命令可能在构建生产环境镜像时被重新启用
2025-01-10 15:53:23 +08:00

37 lines
1.1 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters

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:22-alpine
WORKDIR /app
# # 配置alpine国内镜像加速
# RUN sed -i "s@http://dl-cdn.alpinelinux.org/@https://repo.huaweicloud.com/@g" /etc/apk/repositories
# 安装tzdata,默认的alpine基础镜像不包含时区组件安装后可通过TZ环境变量配置时区
RUN apk add --no-cache tzdata
# 设置时区为中国东八区这里的配置可以被docker-compose.yml或docker run时指定的时区覆盖
ENV TZ="Asia/Shanghai"
# 如果各公司有自己的私有源可以替换registry地址,如使用官方源注释下一行
RUN npm config set registry https://registry.npmmirror.com
# 安装开发期依赖
COPY package.json ./package.json
RUN npm install -g pnpm
RUN pnpm config set registry https://registry.npmmirror.com
RUN pnpm install
# 构建项目
COPY . .
RUN pnpm run build
# 删除开发期依赖
# RUN rm -rf node_modules && rm package-lock.json
# # 安装生产环境依赖
# RUN pnpm install --production
# 如果端口更换,这边可以更新一下
EXPOSE 8001
CMD ["npm", "run", "start"]