This repository has been archived by the owner on Jul 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
83 lines (65 loc) · 2.54 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# -----------------------------------------
# Multi build file
# One for building our app and one for production
# -----------------------------------------
# -----------------------------------------
# Build container
# -----------------------------------------
# The build container is from the full node image for dependency installation
FROM node AS builder
# Create the app working directory
WORKDIR /usr/src/app
# Set the node environment to development
ENV NODE_ENV development
# Copy all files required for the build container to run
# Do not copy the source files here, every change will require a new npm install
# NOTE: The .dockerignore needs to explicitly allow files to be 'visible' or this will fail
COPY package.json package-lock.json tsconfig.json gulpfile.js global.d.ts /usr/src/app/
# You have to specify "--unsafe-perm" with npm install
# when running as root. Failing to do this can cause
# install to appear to succeed even if a preinstall
# script fails, and may have other adverse consequences
# as well.
# This command will also cat the npm-debug.log file after the
# build, if it exists.
# Also disable the MongoMemoryServer Post Install
ENV MONGOMS_DISABLE_POSTINSTALL=1
RUN npm install --only=dev --unsafe-perm || \
((if [ -f npm-debug.log ]; then \
cat npm-debug.log; \
fi) && false)
# Gulp does not currently install from npm install because of v4
# It needs to be installed it mannualy (issues with v4)
RUN npm install gulp --no-save
# Copy the src files accross
COPY src src/
# Run the production build task
RUN npm run build:prod
# -----------------------------------------
# Production container
# -----------------------------------------
# Production image from the alpine image
FROM node:alpine AS production
# -----------------------------------------
# Install requirements for tesseract and image magick
# -----------------------------------------
# Create the app working directory
WORKDIR /usr/src/app
# Set the node environment to production
# This also means only prodcution npm's are installaed
ENV NODE_ENV production
# Copy accross all reqired files
COPY package.json package-lock.json ./
# Install all dependencies
RUN npm install --only=prod --unsafe-perm || \
((if [ -f npm-debug.log ]; then \
cat npm-debug.log; \
fi) && false)
# Copy the distribution folder from the builder file
COPY --from=builder /usr/src/app/dist dist/
# Expost port 3000
# This port must match the port for the K8's continer health probe
# It must be exposed else the probe will fail
EXPOSE 3000
# Run the start command
CMD npm start