99AI/Dockerfile

36 lines
921 B
Docker
Raw Normal View History

# 编译阶段
2024-07-07 13:09:08 +08:00
FROM node:20.14.0-alpine AS build
2024-07-07 13:09:08 +08:00
WORKDIR /app
2024-04-20 22:15:08 +08:00
2024-07-07 13:09:08 +08:00
COPY package*.json ./
2024-07-07 13:09:08 +08:00
# 设置环境变量来忽略一些警告
ENV NPM_CONFIG_LOGLEVEL=error
ENV NODE_OPTIONS=--max-old-space-size=4096
2024-04-22 13:55:54 +08:00
2024-07-07 13:09:08 +08:00
# 合并RUN命令更新依赖设置镜像源安装依赖然后清理
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \
npm config set registry https://registry.npmmirror.com && \
apk add --no-cache --virtual .build-deps git && \
npm install -g npm@latest && \
npm install --production --no-optional --legacy-peer-deps && \
npm cache clean --force && \
apk del .build-deps && \
rm -rf /var/cache/apk/* /tmp/*
# 运行阶段
2024-07-07 13:09:08 +08:00
FROM node:20.14.0-alpine AS runner
ENV TZ="Asia/Shanghai" \
NODE_ENV=production
WORKDIR /app
2024-04-22 13:55:54 +08:00
COPY --from=build /app/node_modules ./node_modules
COPY . .
EXPOSE 9520
2024-07-07 13:09:08 +08:00
CMD ["node", "--max-old-space-size=4096", "./dist/main.js"]