-
Notifications
You must be signed in to change notification settings - Fork 8
/
Dockerfile
58 lines (44 loc) · 1.29 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
# --------------- Dev stage for developers to override sources
FROM node:18.20.4-alpine as dev
ARG NPM_TOKEN
RUN test -n "$NPM_TOKEN"
RUN apk --no-cache add make gcc g++ python3 git jq
ENV NODE_ENV=development
ENV BLUEBIRD_DEBUG=0
RUN mkdir /app
WORKDIR /app
COPY package*.json ./
COPY .npmrc ./
RUN echo "//npm.pkg.github.com/:_authToken=${NPM_TOKEN}" >> .npmrc
RUN npm ci
# --------------- ci stage for CI runner
FROM dev as ci
COPY . .eslintrc.yml ./
ARG SKIP_TESTS='false'
ARG CI=true
ENV NODE_ENV=test
RUN if [ "$SKIP_TESTS" = 'false' ]; then npm run lint && npm run test; fi
RUN npm run build
# --------------- Cleanup
FROM dev as clean
# below command removes the packages specified in devDependencies and set NODE_ENV to production
RUN npm prune --production
# --------------- Production stage
FROM node:18.20.4-alpine AS prod
COPY --from=dev /usr/local/bin/node /usr/bin/
COPY --from=dev /usr/lib/libgcc* /usr/lib/
COPY --from=dev /usr/lib/libstdc* /usr/lib/
# Install dependencies
RUN apk add --no-cache git
# Install app
RUN mkdir /app
WORKDIR /app
COPY --from=clean /app/node_modules node_modules
COPY --from=ci /app/dist dist
COPY package.json .
USER node
ENV NODE_ENV=production
# suppress npm update check
ENV npm_config_update_notifier=false
# suppress npm warnings
ENV NODE_NO_WARNINGS='1'