-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
55 lines (33 loc) · 1.29 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
FROM alpine:3.10 AS builder
RUN mkdir -p /nuxt-blog
WORKDIR /nuxt-blog
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
RUN apk add --no-cache --update nodejs nodejs-npm
COPY package.json package-lock.json ./
RUN npm config set registry=https://registry.npm.taobao.org
RUN npm install --production
FROM alpine:3.10
# MAINTAINER
LABEL name="nuxt-blog"
LABEL version="1.0.1"
LABEL author="bigfool <[email protected]>"
LABEL maintainer="bigfool <[email protected]>"
LABEL description="nuxt-blog application"
RUN mkdir -p /nuxt-blog \
&& mkdir -p /nuxt-blog/logs
# 新建一个用户www 并设置项目目录用户组
RUN adduser -D -H www \
&& chown -R www /nuxt-blog
WORKDIR /nuxt-blog
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
RUN apk add --no-cache --update nodejs nodejs-npm
COPY --from=builder /nuxt-blog/node_modules ./node_modules
COPY . .
RUN npm config set registry=https://registry.npm.taobao.org \
&& npm install node-sass --sass_binary_site=https://npm.taobao.org/mirrors/node-sass/ \
&& npm install -g pm2
RUN npm run build
RUN rm -rf `ls | egrep -v '(.nuxt|node_modules|static|pm2.json|nuxt.config.js|package.json|package-lock.json)'`
ENV NODE_ENV=production
EXPOSE 8081
CMD ["pm2-docker", "pm2.json"]