-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
43 lines (32 loc) · 1 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
### 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:14.18.1-alpine AS builder
WORKDIR /usr/pg-amqp-bridge
# 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:14.18.1-alpine
WORKDIR /usr/pg-amqp-bridge
# 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/pg-amqp-bridge/dist ./dist
COPY package.json ./
# Run the production compiled code
EXPOSE 3000
CMD [ "node", "./dist/index.js" ]