-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
37 lines (28 loc) · 964 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
35
36
37
ARG NODE_IMAGE=node:18.12.1-alpine3.16
# --------------> The base image
FROM $NODE_IMAGE AS base
RUN apk add --update-cache dumb-init
WORKDIR /usr/src/app
# --------------> The builder image
FROM base AS builder
RUN apk add --no-cache git python3 py3-pip curl libc6-compat
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
# --------------> The production dependencies image
FROM base AS production_dependecies
ENV NODE_ENV production
RUN apk add --no-cache git python3 py3-pip curl libc6-compat
COPY package*.json ./
RUN npm ci --only=production
# --------------> The production image [SHOULD BE THE LAST STAGE]
FROM base as production
ENV NODE_ENV production
ENV MY_API_TOKEN = "super-secret-token"
USER node
COPY --chown=node:node --from=production_dependecies /usr/src/app/node_modules ./node_modules
COPY --chown=node:node --from=builder /usr/src/app/dist ./dist
COPY package*.json ./
EXPOSE 5001
CMD ["dumb-init", "node", "dist/index.js" ]