Skip to content

Commit 6bdd66d

Browse files
heiskrchiedo
andauthored
Speed up docker build (#17659)
Co-authored-by: Chiedo John <2156688+chiedo@users.noreply.github.com>
1 parent 314a8ac commit 6bdd66d

1 file changed

Lines changed: 6 additions & 21 deletions

File tree

Dockerfile

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,20 @@
11
# This Dockerfile can be used for docker-based deployments to platforms
22
# like Now or Moda, but it is currently _not_ used by our Heroku deployments
3-
# It uses three multi-stage builds: `installation`, `bundles`, and the main build.
3+
# It uses two multi-stage builds: `install` and the main build to keep the image size down.
44

55
# --------------------------------------------------------------------------------
6-
# INSTALLATION IMAGE
7-
# A temporary image that installs production-only dependencies
6+
# INSTALL IMAGE
7+
# A temporary image that installs production-only dependencies and builds the production-ready front-end bundles.
88

9-
FROM node:14-alpine as installation
9+
FROM node:14-alpine as install
1010
RUN apk add --no-cache python make g++
1111
ENV NODE_ENV production
1212
WORKDIR /usr/src/docs
1313
COPY package*.json ./
14-
15-
# Install the project's dependencies
16-
RUN npm ci --production
17-
18-
# --------------------------------------------------------------------------------
19-
# BUNDLE IMAGE
20-
# A temporary image that installs dependencies and builds the production-ready front-end bundles.
21-
22-
FROM node:14-alpine as bundles
23-
RUN apk add --no-cache python make g++
24-
ENV NODE_ENV production
25-
WORKDIR /usr/src/docs
26-
# Install the files used to create the bundles
27-
COPY package*.json ./
2814
COPY javascripts ./javascripts
2915
COPY stylesheets ./stylesheets
3016
COPY lib ./lib
3117
COPY webpack.config.js ./webpack.config.js
32-
# Install the project's dependencies and build the bundles
3318
RUN npm ci --production
3419
RUN npm run build
3520

@@ -48,10 +33,10 @@ RUN chown node:node /usr/src/docs -R
4833
USER node
4934

5035
# Copy our dependencies
51-
COPY --chown=node:node --from=installation /usr/src/docs/node_modules /usr/src/docs/node_modules
36+
COPY --chown=node:node --from=install /usr/src/docs/node_modules /usr/src/docs/node_modules
5237

5338
# Copy our front-end code
54-
COPY --chown=node:node --from=bundles /usr/src/docs/dist /usr/src/docs/dist
39+
COPY --chown=node:node --from=install /usr/src/docs/dist /usr/src/docs/dist
5540

5641
# We should always be running in production mode
5742
ENV NODE_ENV production

0 commit comments

Comments
 (0)