forked from rudderlabs/rudder-transformer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-ut-func
82 lines (58 loc) · 2.13 KB
/
Dockerfile-ut-func
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
80
81
82
# syntax=docker/dockerfile:1.4
FROM ubuntu:20.04 AS base
ENV HUSKY 0
RUN apt-get update \
&& apt-get install -y curl make g++ \
&& apt-get install -y cpio \
&& curl -sL https://deb.nodesource.com/setup_18.x | bash \
&& apt-get install -y nodejs \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /var/lib/apt/lists.d/* \
&& apt-get autoremove \
&& apt-get clean \
&& apt-get autoclean
RUN adduser --disabled-password --gecos "" --uid 1000 node
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app && mkdir -p /home/node/.npm && chown -R node:node /home/node/.npm
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
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
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