diff --git a/Dockerfile b/Dockerfile index 6e5205f763..8235b56591 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,35 +1,20 @@ # This Dockerfile can be used for docker-based deployments to platforms # like Now or Moda, but it is currently _not_ used by our Heroku deployments -# It uses three multi-stage builds: `installation`, `bundles`, and the main build. +# It uses two multi-stage builds: `install` and the main build to keep the image size down. # -------------------------------------------------------------------------------- -# INSTALLATION IMAGE -# A temporary image that installs production-only dependencies +# INSTALL IMAGE +# A temporary image that installs production-only dependencies and builds the production-ready front-end bundles. -FROM node:14-alpine as installation +FROM node:14-alpine as install RUN apk add --no-cache python make g++ ENV NODE_ENV production WORKDIR /usr/src/docs COPY package*.json ./ - -# Install the project's dependencies -RUN npm ci --production - -# -------------------------------------------------------------------------------- -# BUNDLE IMAGE -# A temporary image that installs dependencies and builds the production-ready front-end bundles. - -FROM node:14-alpine as bundles -RUN apk add --no-cache python make g++ -ENV NODE_ENV production -WORKDIR /usr/src/docs -# Install the files used to create the bundles -COPY package*.json ./ COPY javascripts ./javascripts COPY stylesheets ./stylesheets COPY lib ./lib COPY webpack.config.js ./webpack.config.js -# Install the project's dependencies and build the bundles RUN npm ci --production RUN npm run build @@ -48,10 +33,10 @@ RUN chown node:node /usr/src/docs -R USER node # Copy our dependencies -COPY --chown=node:node --from=installation /usr/src/docs/node_modules /usr/src/docs/node_modules +COPY --chown=node:node --from=install /usr/src/docs/node_modules /usr/src/docs/node_modules # Copy our front-end code -COPY --chown=node:node --from=bundles /usr/src/docs/dist /usr/src/docs/dist +COPY --chown=node:node --from=install /usr/src/docs/dist /usr/src/docs/dist # We should always be running in production mode ENV NODE_ENV production