This repository has been archived by the owner on Nov 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
44f3659
commit 061fc5f
Showing
1 changed file
with
10 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |