From 354a5832e483db2ffd8d67a47e78854d603e583d Mon Sep 17 00:00:00 2001 From: Brandon Fryslie <530235+brandon-fryslie@users.noreply.github.com> Date: Sun, 15 Mar 2020 16:40:56 -0600 Subject: [PATCH] Adjust Dockerfile to improve caching --- Dockerfile | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 02fcf01a5..091ed9f75 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,19 @@ FROM node:8 +ENV NODE_ENV=docker + # Create app directory WORKDIR /usr/src/app -# Bundle app source +# Copy package.json into the image, then run yarn install +# This improves caching so we don't have to download the dependencies every time the code changes +COPY package.json ./ +# --ignore-scripts tells yarn not to run postbuild. We run it explicitly later +RUN yarn install --ignore-scripts + +# Bundle app source and build application COPY . . - -ENV NODE_ENV=docker - -RUN yarn +RUN yarn build EXPOSE 8000 -CMD [ "yarn", "start" ] \ No newline at end of file +CMD [ "yarn", "start" ]