47 lines
780 B
Docker
47 lines
780 B
Docker
# cd guesswhoiams
|
|
# git pull
|
|
# cd src/shared/protocols
|
|
# git pull
|
|
# cd ../../..
|
|
# sudo docker build -t guesswhoiams .
|
|
|
|
# 後續查看容器
|
|
# sudo docker ps
|
|
# sudo docker exec -it [Container ID] /bin/bash
|
|
|
|
FROM node:19.4.0
|
|
|
|
# npm install
|
|
ADD package*.json /src/
|
|
WORKDIR /src
|
|
RUN npm i
|
|
|
|
# build
|
|
ADD . /src
|
|
RUN npm run build
|
|
|
|
# clean
|
|
RUN npm prune --prod
|
|
|
|
# move
|
|
RUN rm -rf /app \
|
|
&& mv dist /app \
|
|
&& mv node_modules /app/ \
|
|
&& rm -rf /src
|
|
|
|
# ENV
|
|
ENV NODE_ENV prod
|
|
|
|
EXPOSE 3003
|
|
|
|
WORKDIR /app
|
|
|
|
# copy static
|
|
ADD .env /app/
|
|
ADD certificate /app/certificate/
|
|
# COPY [".env", "./"]
|
|
# COPY ["certificate", "./certificate"]
|
|
|
|
# 指定啟動container後執行命令
|
|
# CMD NODE_ENV=prod && node index.js
|
|
CMD [ "npm", "run", "prod" ] |