-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
34 lines (27 loc) · 873 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
31
32
33
34
# Install dependencies only when needed
FROM node:16-alpine AS deps
LABEL Dmitry Neverovski <dmitryneverovski@gmail.com>
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package*.json ./
RUN npm ci
# Rebuild the source code only when needed
FROM node:16-alpine AS builder
LABEL Dmitry Neverovski <dmitryneverovski@gmail.com>
ARG NODE_ENV
ENV NODE_ENV ${NODE_ENV:-development}
WORKDIR /app
COPY . .
COPY --from=deps /app/node_modules ./node_modules
RUN NODE_ENV=${NODE_ENV} npm run build
# Production image, copy all the files and run next
FROM node:16-alpine AS runner
LABEL Dmitry Neverovski <dmitryneverovski@gmail.com>
ARG RUNTIME
ENV RUNTIME ${RUNTIME:-dev}
WORKDIR /app
COPY --from=builder /app/build ./build
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
EXPOSE 5757
CMD npm run start:${RUNTIME}