34 lines
614 B
Docker
34 lines
614 B
Docker
# sudo docker build -t guesswhoiams .
|
|
# sudo docker exec -it 2e8e3995aa52 /bin/bash
|
|
|
|
FROM node:19.4.0
|
|
|
|
# 使用淘宝 NPM 镜像(国内机器构建推荐启用)
|
|
# RUN npm config set registry https://registry.npm.taobao.org/
|
|
|
|
# npm install
|
|
ADD package*.json /src/
|
|
WORKDIR /src
|
|
RUN npm i
|
|
|
|
# build
|
|
ADD . /src
|
|
RUN npm run build
|
|
|
|
# clean
|
|
RUN npm prune --production
|
|
|
|
# move
|
|
RUN rm -rf /app \
|
|
&& mv dist /app \
|
|
&& mv node_modules /app/ \
|
|
&& rm -rf /src
|
|
|
|
# ENV
|
|
ENV NODE_ENV production
|
|
|
|
EXPOSE 3003
|
|
|
|
WORKDIR /app
|
|
# 指定啟動container後執行命令
|
|
CMD [ "npm", "start" ] |