-
Notifications
You must be signed in to change notification settings - Fork 7
/
Dockerfile
40 lines (37 loc) · 1002 Bytes
/
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
#
# ---- Base Node ----
FROM node:8-alpine AS base
# set working directory
WORKDIR /shortener
# install git
RUN apk add --no-cache git
# copy project file
COPY package.json package-lock.json ./
#
# ---- Dependencies ----
FROM base AS dependencies
# install node packages
RUN npm set progress=false && npm config set depth 0 && npm cache clean --force
RUN npm install --only=production
# copy production node_modules aside
RUN cp -R node_modules prod_node_modules
# install ALL node_modules, including 'devDependencies'
RUN npm install
# ---- Build ----
# build up docs
FROM dependencies AS build
COPY . .
RUN npm run build:docs
#
# ---- Release ----
FROM base AS release
# copy production node_modules
COPY --from=dependencies /shortener/prod_node_modules ./node_modules
# prune for good measure
RUN npm prune --production
RUN rm -rf .git .gitignore *.sh docker-compose* Dockerfile* *.md nginx.conf
# copy in built docs
COPY --from=build /shortener/docs ./
# copy app sources
COPY . .
CMD npm start