Skip to content
This repository was archived by the owner on Apr 17, 2025. It is now read-only.

Commit 4ad5bea

Browse files
RI-5036: Make Dockerfile 2-stage instead of 3-stage; reduce...
the number of node_module restorations
1 parent 5ad822c commit 4ad5bea

File tree

1 file changed

+11
-20
lines changed

1 file changed

+11
-20
lines changed

Dockerfile

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
FROM node:18.15.0-alpine as front
1+
FROM node:18.15.0-alpine as build
22
RUN apk update
33
RUN apk add --no-cache --virtual .gyp \
44
python3 \
55
make \
6-
g++
6+
g++ \
7+
net-tools
78
WORKDIR /usr/src/app
89
COPY package.json yarn.lock babel.config.cjs tsconfig.json ./
910
RUN SKIP_POSTINSTALL=1 yarn install
1011
COPY configs ./configs
1112
COPY scripts ./scripts
1213
COPY redisinsight ./redisinsight
13-
RUN yarn --cwd redisinsight/api
14+
RUN yarn --cwd redisinsight/api install
1415
ARG SERVER_TLS_CERT
1516
ARG SERVER_TLS_KEY
1617
ARG SEGMENT_WRITE_KEY
@@ -19,15 +20,10 @@ ENV SERVER_TLS_KEY=${SERVER_TLS_KEY}
1920
ENV SEGMENT_WRITE_KEY=${SEGMENT_WRITE_KEY}
2021
RUN yarn build:web
2122
RUN yarn build:statics
22-
23-
FROM node:18.15.0-alpine as back
24-
WORKDIR /usr/src/app
25-
COPY redisinsight/api/package.json redisinsight/api/yarn.lock ./
26-
RUN yarn install
27-
COPY redisinsight/api ./
28-
COPY --from=front /usr/src/app/redisinsight/api/static ./static
29-
COPY --from=front /usr/src/app/redisinsight/api/defaults ./defaults
30-
RUN yarn run build:prod
23+
RUN yarn build:prod
24+
RUN yarn --cwd ./redisinsight/api install --production
25+
COPY ./redisinsight/api/.yarnclean.prod ./redisinsight/api/.yarnclean
26+
RUN yarn --cwd ./redisinsight/api autoclean --force
3127

3228
FROM node:18.15.0-alpine
3329

@@ -42,14 +38,9 @@ ENV NODE_ENV=${NODE_ENV}
4238
ENV SERVER_STATIC_CONTENT=true
4339
ENV BUILD_TYPE='DOCKER_ON_PREMISE'
4440
WORKDIR /usr/src/app
45-
COPY --from=back /usr/src/app/dist ./redisinsight/api/dist
46-
COPY --from=front /usr/src/app/redisinsight/ui/dist ./redisinsight/ui/dist
47-
48-
# Build BE prod dependencies here to build native modules
49-
COPY redisinsight/api/package.json redisinsight/api/yarn.lock ./redisinsight/api/
50-
RUN yarn --cwd ./redisinsight/api install --production
51-
COPY redisinsight/api/.yarnclean.prod ./redisinsight/api/.yarnclean
52-
RUN yarn --cwd ./redisinsight/api autoclean --force
41+
COPY --from=build /usr/src/app/redisinsight/api/dist ./redisinsight/api/dist
42+
COPY --from=build /usr/src/app/redisinsight/api/node_modules ./redisinsight/api/node_modules
43+
COPY --from=build /usr/src/app/redisinsight/ui/dist ./redisinsight/ui/dist
5344

5445
COPY ./docker-entry.sh ./
5546
RUN chmod +x docker-entry.sh

0 commit comments

Comments
 (0)