-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
30 lines (26 loc) · 1006 Bytes
/
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
# Install dependencies only when needed
FROM node:16.13.1-alpine AS deps
WORKDIR /app
RUN apk add --no-cache libc6-compat
COPY package.json yarn.lock .yarnrc.yml .
COPY .yarn ./.yarn
COPY packages/api/package.json ./packages/api/package.json
COPY packages/shared/package.json ./packages/shared/package.json
COPY packages/types/package.json ./packages/types/package.json
COPY packages/web/package.json ./packages/web/package.json
RUN yarn --immutable
# Rebuild the source code only when needed
FROM node:16.13.1-alpine AS builder
WORKDIR /app
COPY . .
COPY --from=deps /app/node_modules ./node_modules
RUN yarn build && yarn workspaces focus --all --production
# Production image
FROM node:16.13.1-alpine AS runner
WORKDIR /app
ENV NODE_ENV production
COPY --from=builder /app/package.json /app/yarn.lock /app/.yarnrc.yml .
COPY --from=builder /app/.yarn ./.yarn
COPY --from=builder /app/packages ./packages
COPY --from=builder /app/node_modules ./node_modules
CMD ["yarn", "workspace", "api", "start"]