GuessWhoIAmS/Dockerfile

37 lines
699 B
Docker
Raw Normal View History

2023-09-01 09:45:19 +00:00
# sudo docker build -t guesswhoiams .
2023-09-11 07:48:54 +00:00
# sudo docker exec -it 5cac9af04256 /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
2023-09-11 07:48:54 +00:00
RUN npm prune --prod
2023-08-28 05:44:19 +00:00
2023-08-31 11:28:35 +00:00
# move
RUN rm -rf /app \
&& mv dist /app \
2023-09-11 08:16:25 +00:00
&& mv certificate /app \
2023-09-11 07:48:54 +00:00
&& mv .env /app \
2023-08-31 11:28:35 +00:00
&& mv node_modules /app/ \
&& rm -rf /src
2023-08-28 05:44:19 +00:00
2023-08-31 11:28:35 +00:00
# ENV
2023-09-11 07:48:54 +00:00
ENV NODE_ENV prod
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-11 08:17:34 +00:00
# CMD NODE_ENV=prod && node index.js
CMD [ "npm", "run", "prod" ]