-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
47 lines (31 loc) · 974 Bytes
/
Dockerfile
File metadata and controls
47 lines (31 loc) · 974 Bytes
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
FROM node:10-alpine as base
ENV PATH /opt/node_app/node_modules/.bin/:$PATH
RUN apk update && apk add --no-cache docker-cli
ARG PORT=3000
ENV PORT $PORT
EXPOSE $PORT 9229 9230
# This application needs to interact with the Docker engine
# which complicates running node as an unprivileged account.
# TODO: figure out if there's a secure way to run this
# under the node account while still interacting with the Docker API
RUN mkdir /opt/node_app/app -p
# && chown -R node:node /opt/node_app
WORKDIR /opt/node_app
# USER node
COPY package*.json ./
RUN npm install --only=production \
&& npm cache clean --force
WORKDIR /opt/node_app/app
# DEV IMAGE
FROM base as dev
ENV NODE_ENV=development
RUN npm install --only=development
CMD ["nodemon", "--ignore", "uploads/", "--exec", "babel-node", "./src/start"]
# BUILD IMAGE
FROM dev as builder
COPY . .
RUN npm run build
# PROD Image
FROM builder as prod
ENV NODE_ENV=production
CMD ["node", "./dist/start.js"]