GuessWhoIAmS/Dockerfile
2023-09-11 17:06:32 +08:00

40 lines
671 B
Docker

# 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" ]