Closed k631583871 closed 1 year ago
我添加了一个dockerfile,你可以试试用它来打包,打出来的镜像100多M
我尝试了dockerfile. 打包了 113MB, 这个大小还可以.
我觉得给dockerfile里面可以添加下面的内容
EXPOSE 9527
ENV PORT 9527
ENV BIND_IP '127.0.0.1'
ENV CONNECT_PWD ''
ENV CONFIG_PATH 'config.js'
ENV LOG_PATH '/server/logs'
ENV DATA_PATH '/server/data'
添加后的样子
FROM node:16-alpine AS builder
WORKDIR /server
COPY . .
# RUN npm install
RUN npm ci
RUN npm run build
FROM node:16-alpine AS final
WORKDIR /server
EXPOSE 9527
ENV PORT 9527
ENV BIND_IP '127.0.0.1'
ENV CONNECT_PWD ''
ENV CONFIG_PATH 'config.js'
ENV LOG_PATH '/server/logs'
ENV DATA_PATH '/server/data'
COPY --from=builder ./server/server ./server
COPY package.json package-lock.json config.js index.js ./
RUN npm ci --omit=dev
CMD [ "npm", "start" ]
我尝试直接使用源码的方式打包成docker镜像,打包之后超过 300M, 使用很不方便。 能否提供一个打包成二进制的命令,支持生成更小的镜像,方便大家在服务器上部署