Skip to content
This repository has been archived by the owner on Nov 29, 2021. It is now read-only.

Commit

Permalink
feat: update Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
YanceyOfficial committed Mar 23, 2020
1 parent 44f3659 commit 061fc5f
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,19 @@
FROM node:12-alpine
FROM node:12-alpine as builder

LABEL maintainer="Yancey Leo <[email protected]>" \
version="0.1"
WORKDIR /usr/src/app

WORKDIR /home/blog
COPY package.json ./

COPY package.json yarn.lock ./
RUN npm install --production -d --registry=https://registry.npm.taobao.org

RUN npm ci --production -d --registry=https://registry.npm.taobao.org

COPY . /home/blog

CMD ["pm2-runtime", "deploy"]
COPY . .

# 第一阶段,拉取 node 基础镜像并安装依赖,执行构建
FROM node:11-alpine as builder
RUN npm run build

WORKDIR /tmp
COPY . .
RUN npm config set registry https://registry.npm.taobao.org \
&& npm i -g yarn
RUN yarn && yarn build
FROM keymetrics/pm2:latest-alpine

# 第二阶段,将构建完的产物 build 文件夹 COPY 到实际 release 的镜像中,会丢弃第一阶段中其他的文件
FROM nginx:alpine
WORKDIR /usr/src/app

COPY .docker/conf/default.conf /etc/nginx/conf.d/
COPY --from=builder /tmp/build /usr/share/nginx/html
COPY --from=development /usr/src/app/dist ./dist

EXPOSE 80
CMD ["pm2-runtime", "dist/main.js"]

0 comments on commit 061fc5f

Please sign in to comment.