GuessWhoIAmS/Dockerfile

34 lines
614 B
Docker
Raw Normal View History

2023-09-01 09:45:19 +00:00
# sudo docker build -t guesswhoiams .
# sudo docker exec -it 2e8e3995aa52 /bin/bash
FROM node:19.4.0
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-09-01 09:45:19 +00:00
EXPOSE 3003
2023-08-28 05:44:19 +00:00
2023-08-31 11:28:35 +00:00
WORKDIR /app
2023-09-01 09:45:19 +00:00
# 指定啟動container後執行命令
CMD [ "npm", "start" ]