2023-09-01 09:45:19 +00:00
|
|
|
# sudo docker build -t guesswhoiams .
|
2023-09-11 07:32:42 +00:00
|
|
|
# # sudo docker exec -it 51bd6c84a7f2 /bin/bash
|
2023-09-01 09:45:19 +00:00
|
|
|
|
|
|
|
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後執行命令
|
2023-09-01 09:49:01 +00:00
|
|
|
CMD node index.js
|
|
|
|
# CMD [ "npm", "start" ]
|