-
Notifications
You must be signed in to change notification settings - Fork 113
/
Dockerfile
79 lines (53 loc) · 1.86 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# syntax=docker/dockerfile:1.4
FROM node:18.20.1-alpine3.18 AS base
ENV HUSKY 0
RUN apk update
RUN apk upgrade
RUN apk add --no-cache tini make g++ python3
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
FROM base AS development
ENV HUSKY 0
ARG version
ARG GIT_COMMIT_SHA
ENV transformer_build_version=$version
ENV git_commit_sha=$GIT_COMMIT_SHA
# Create app directory
WORKDIR /home/node/app
RUN chown -R node:node /home/node/app
USER node
COPY package*.json ./
COPY scripts/skipPrepareScript.js ./scripts/skipPrepareScript.js
RUN npm ci --no-audit --cache .npm
COPY --chown=node:node . .
RUN npm run build:ci -- --sourceMap false
RUN npm run copy
RUN npm run setup:swagger
ENTRYPOINT ["/sbin/tini", "--"]
HEALTHCHECK --interval=1s --timeout=30s --retries=30 \
CMD wget --no-verbose --tries=5 --spider http://localhost:9090/health || exit 1
CMD [ "npm", "start" ]
EXPOSE 9090/tcp
FROM base AS prodDepsBuilder
WORKDIR /home/node/app
USER node
COPY --chown=node:node --from=development /home/node/app/package*.json ./
COPY --chown=node:node --from=development /home/node/app/scripts/skipPrepareScript.js ./scripts/skipPrepareScript.js
ENV SKIP_PREPARE_SCRIPT='true'
RUN npm ci --omit=dev --no-audit --cache .npm
RUN npm run clean:node
FROM base as production
ENV HUSKY 0
ARG version
ARG GIT_COMMIT_SHA
ENV transformer_build_version=$version
ENV git_commit_sha=$GIT_COMMIT_SHA
WORKDIR /home/node/app
USER node
COPY --chown=node:node --from=prodDepsBuilder /home/node/app/package.json ./
COPY --chown=node:node --from=prodDepsBuilder /home/node/app/node_modules ./node_modules
COPY --chown=node:node --from=development /home/node/app/dist/ ./dist
ENTRYPOINT ["/sbin/tini", "--"]
HEALTHCHECK --interval=1s --timeout=30s --retries=30 \
CMD wget --no-verbose --tries=5 --spider http://localhost:9090/health || exit 1
CMD [ "npm", "start" ]
EXPOSE 9090/tcp