-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
30 lines (25 loc) · 1.01 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
FROM node:8.11.3
# Install latest npm
RUN npm i -g npm
# Set home directory env variable and switch to node user, so we don't
# run as root
ENV HOME=/home/node
USER node
# Create app directory and copy package.json and package-lock.json to it
# Using --chown flag so that the new files are not owned by root
RUN mkdir $HOME/app
COPY --chown=node:node package.json package-lock.json $HOME/app/
# Switch working directory and install dependencies using npm ci,
# which drastically lowers install time
WORKDIR $HOME/app
RUN npm ci
# Copies the rest of the app to the folder. Note a few things:
#
# In .dockerignore, node_modules/ is ignored and will not be copied,
# thus the local node_modules will not overwrite the container directory.
#
# In development mode, we mount the host directory to the container anyway,
# so this instruction is not needed. However, in staging/production, copying
# the source code to the container lets us deploy the application without
# checking out the source code, saving space and time.
COPY . .