GuessWhoIAmS/Dockerfile

47 lines
780 B
Docker
Raw Normal View History

2024-01-12 04:02:02 +00:00
# cd guesswhoiams
# git pull
# cd src/shared/protocols
# git pull
# cd ../../..
2023-09-01 09:45:19 +00:00
# sudo docker build -t guesswhoiams .
2024-01-12 04:02:02 +00:00
# 後續查看容器
2023-09-11 09:06:32 +00:00
# sudo docker ps
# sudo docker exec -it [Container ID] /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 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 \
&& 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-11 09:06:32 +00:00
# copy static
ADD .env /app/
ADD certificate /app/certificate/
# COPY [".env", "./"]
# COPY ["certificate", "./certificate"]
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" ]