-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
46 lines (42 loc) · 1.19 KB
/
Dockerfile
File metadata and controls
46 lines (42 loc) · 1.19 KB
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
# docker run -it node:8.12-alpine /bin/bash
# ---- Base Node ----
FROM node:10-alpine AS base
# Preparing
RUN mkdir -p /var/app && chown -R node /var/app
# Set working directory
WORKDIR /var/app
# Copy project file
COPY package.json .
COPY package-lock.json .
#
# ---- Dependencies ----
FROM base AS dependencies
RUN apk add --update python build-base
# install node packages
RUN npm ci --only=prod --silent
# copy production node_modules aside
RUN cp -R node_modules prod_node_modules
# install ALL node_modules, including 'devDependencies'
RUN npm ci --silent
# Run in production mode
#
# ---- Test & Build ----
# run linters, setup and tests
FROM dependencies AS build
COPY . .
# Setup environment variables
RUN npm run build
#
# ---- Release ----
FROM base AS release
RUN apk add --update bash curl && rm -rf /var/cache/apk/*
# copy production node_modules
COPY --from=dependencies /var/app/prod_node_modules ./node_modules
COPY --from=build /var/app/build ./build
# COPY --from=build /var/app/source ./source
# Setup environment variables
ENV NODE_ENV=production
# expose port and define CMD
EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=5s CMD curl --fail http://0.0.0.0:3000 || exit 1
CMD npm run start