twn39 / code

:memo: 代码笔记,通过 issue 的方式记录日常遇到的问题和学习笔记
13 stars 1 forks source link

Dockerfile nodejs 示例 #393

Open twn39 opened 2 years ago

twn39 commented 2 years ago

Dockerfile 配置文件:

FROM node:16-alpine
COPY fastify-demo-*.tgz /home/
RUN npm config set registry http://mirrors.cloud.tencent.com/npm/
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
RUN tar -xzvf /home/fastify-demo-1.0.0.tgz -C /home
RUN npm i -g pm2
EXPOSE 3000
ENV NODE_ENV development
WORKDIR /home/package
CMD ["pm2-runtime", "src/server.js", "-i", "5"]