-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
49 lines (35 loc) · 1.07 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
### 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-alpine AS builder
WORKDIR /usr/numbers
# Cache dependencies
COPY --from=deps /tmp/deps.json ./package.json
COPY yarn.lock ./
RUN yarn install
# Copy application codebase
COPY . .
RUN yarn run build
### Slim Deploy
### -------------------------
FROM node:16.14.0-alpine
WORKDIR /usr/numbers
# 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/numbers/dist ./dist
ENV NODE_ENV="production"
COPY package.json database.json ./
COPY migrations ./migrations
COPY lua ./lua
# Run production compiled code
EXPOSE 3000
CMD [ "node", "./dist/src/server.js" ]