-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
34 lines (27 loc) · 953 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
FROM node:16-slim@sha256:e41a70d089deb43717a834c5c966842dab760e56257bfe391f3f161ce5b28c52 AS base
WORKDIR /app
FROM base AS pruner
COPY ./package.json .
COPY ./package-lock.json .
FROM base AS dev-deps
COPY --from=pruner /app/ .
RUN npm ci
FROM base AS prod-deps
COPY --from=pruner /app/ ./prod-deps/
RUN cd ./prod-deps/ && npm ci --only=production
FROM base AS builder
COPY --from=pruner /app/ .
COPY --from=dev-deps /app/node_modules/ ./node_modules/
COPY ./src/ ./src
COPY ./tsconfig.json ./tsconfig.json
RUN npm run build
FROM node:16-slim@sha256:e41a70d089deb43717a834c5c966842dab760e56257bfe391f3f161ce5b28c52 as release
WORKDIR /home/node
COPY --chown=node:node --from=builder /app/dist ./
COPY --chown=node:node --from=builder /app/package.json ./package.json
COPY --chown=node:node --from=prod-deps /app/prod-deps/node_modules ./node_modules
RUN ["rm", "-rf", "/app"]
USER node
ENV API_PORT=8080
EXPOSE 8080
CMD [ "node", "./index.js" ]