cool-admin-midway/Dockerfile

33 lines
976 B
Docker
Raw Permalink Normal View History

2022-06-27 16:33:14 +08:00
2022-03-28 18:04:44 +08:00
FROM node:lts-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地址,如使用官方源注释下一行
2024-03-28 13:52:37 +08:00
RUN npm config set registry https://registry.npmmirror.com
2022-03-28 18:04:44 +08:00
2024-07-13 09:36:23 +08:00
# 复制package.json
2022-03-28 18:04:44 +08:00
COPY package.json ./package.json
2024-07-13 09:36:23 +08:00
# 安装依赖
2022-03-28 18:04:44 +08:00
RUN npm install
# 构建项目
COPY . .
RUN npm run build
# 删除开发期依赖
RUN rm -rf node_modules && rm package-lock.json
# 安装生产环境依赖
2024-07-13 09:36:23 +08:00
RUN npm install
2022-03-28 18:04:44 +08:00
# 如果端口更换,这边可以更新一下
EXPOSE 8001
2022-06-27 16:33:14 +08:00
CMD ["npm", "run", "start"]