-
Notifications
You must be signed in to change notification settings - Fork 17
/
Dockerfile
71 lines (57 loc) · 1.77 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
### Dependency Cacher
### -------------------------
FROM endeveit/docker-jq:latest as deps
# To prevent cache invalidation from changes in fields other than dependencies
# https://stackoverflow.com/a/59606373
COPY package.json /tmp
RUN jq '{ dependencies, devDependencies, resolutions }' < /tmp/package.json > /tmp/deps.json
### Fat Build
### -------------------------
FROM node:16.14.0 AS builder
WORKDIR /usr/Spoke
# Cache dependencies
COPY --from=deps /tmp/deps.json ./package.json
COPY yarn.lock ./
RUN yarn install
# Configure build environment
ARG PHONE_NUMBER_COUNTRY=US
ENV NODE_ENV="production" \
NODE_OPTIONS=--max_old_space_size=2048 \
PORT=3000 \
OUTPUT_DIR="./build" \
PUBLIC_DIR="./build/client" \
ASSETS_DIR="./build/client/assets" \
ASSETS_MAP_FILE="assets.json" \
PHONE_NUMBER_COUNTRY=$PHONE_NUMBER_COUNTRY
# Copy application codebase
COPY . .
RUN yarn run build
### Slim Deploy
### -------------------------
FROM node:16.14.0
WORKDIR /usr/Spoke
# Install and cache production dependencies
COPY --from=deps /tmp/deps.json ./package.json
COPY yarn.lock ./
RUN yarn install --production
# Copy only the built source
COPY --from=builder /usr/Spoke/build ./build
ARG SPOKE_VERSION="no-version"
ARG PHONE_NUMBER_COUNTRY=US
ENV NODE_ENV="production" \
NODE_OPTIONS=--max_old_space_size=2048 \
PORT=3000 \
OUTPUT_DIR="./build" \
PUBLIC_DIR="./build/client" \
ASSETS_DIR="./build/client/assets" \
ASSETS_MAP_FILE="assets.json" \
VAN_BASE_URL="https://api.securevan.com/v4" \
VAN_EXPORT_TYPE="8" \
PHONE_NUMBER_COUNTRY=$PHONE_NUMBER_COUNTRY \
SPOKE_VERSION=$SPOKE_VERSION
COPY package.json knexfile.env.js ./
COPY migrations ./migrations
COPY seeds ./seeds
# Run the production compiled code
EXPOSE 3000
CMD [ "node", "--no-deprecation", "./build/src/server" ]