From 8e00afd5eb1a1991a3bbd81250d4364e518f6602 Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Wed, 16 Nov 2022 13:34:48 +0000 Subject: [PATCH] build(docker): reorder instructions for build caching --- Dockerfile | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 562683661..cd6f47a04 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,14 +3,21 @@ FROM node:lts-bullseye-slim # Workdir WORKDIR /usr/app -# Copy and install packages -COPY . . +# Create temp folder for files to be stored whilst being converted +RUN mkdir -p ./src/temp/ && \ + ## Allow for temp folder to be manipulated + chown -R node ./src/ + +# Install OS dependencies # Curl needed for healthcheck command -RUN apt-get -q update && \ +RUN apt-get -q update &&\ apt-get -y --no-install-recommends install curl poppler-data poppler-utils unrtf && \ apt-get clean && \ - rm -rf /var/lib/apt/lists/* && \ - npm ci --ignore-scripts --omit=dev && \ + rm -rf /var/lib/apt/lists/* + +# Copy and install node dependencies +COPY package.json package-lock.json ./ +RUN npm ci --ignore-scripts --omit=dev && \ npm cache clean --force && \ chown node ./node_modules/htmltidy2/bin/linux64/tidy && \ chmod 100 ./node_modules/htmltidy2/bin/linux64/tidy && \ @@ -18,10 +25,8 @@ RUN apt-get -q update && \ rm -rf ./node_modules/node-poppler/src/lib/* && \ rm -rf ./node_modules/node-unrtf/src/lib/* -# Create temp folder for files to be stored whilst being converted -RUN mkdir ./src/temp/ && \ - ## Allow for temp folder to be manipulated - chown -R node ./src/ +# Copy source +COPY . . # Node images provide 'node' unprivileged user to run apps and prevent # privilege escalation attacks