GuessWhoIAmS/Dockerfile

30 lines
474 B
Docker
Raw Normal View History

2023-08-31 11:28:35 +00:00
FROM node
2023-08-28 05:44:19 +00:00
2023-08-31 11:28:35 +00:00
# 使用淘宝 NPM 镜像(国内机器构建推荐启用)
# RUN npm config set registry https://registry.npm.taobao.org/
2023-08-28 05:44:19 +00:00
2023-08-31 11:28:35 +00:00
# npm install
ADD package*.json /src/
WORKDIR /src
RUN npm i
2023-08-28 05:44:19 +00:00
2023-08-31 11:28:35 +00:00
# build
ADD . /src
RUN npm run build
# clean
RUN npm prune --production
2023-08-28 05:44:19 +00:00
2023-08-31 11:28:35 +00:00
# move
RUN rm -rf /app \
&& mv dist /app \
&& mv node_modules /app/ \
&& rm -rf /src
2023-08-28 05:44:19 +00:00
2023-08-31 11:28:35 +00:00
# ENV
ENV NODE_ENV production
2023-08-28 05:44:19 +00:00
2023-08-31 11:28:35 +00:00
EXPOSE 3000
2023-08-28 05:44:19 +00:00
2023-08-31 11:28:35 +00:00
WORKDIR /app
CMD node index.js