From bfaaf6e16d7b4fd7c80a8e8128111afba1a0445a Mon Sep 17 00:00:00 2001 From: valentinab25 <30239069+valentinab25@users.noreply.github.com> Date: Tue, 15 Jun 2021 16:51:21 +0300 Subject: [PATCH] Reorganize Dockerfile to reduce image size --- Dockerfile | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1ac04e79..57f4cb22 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,28 +1,35 @@ +# Based on https://github.com/plone/volto/blob/master/entrypoint.sh FROM node:12-stretch-slim -RUN apt-get update && apt-get install -y git - COPY . /opt/frontend/ -RUN chown -R node /opt/frontend/ -RUN rm -rf /opt/frontend/src/addons/* + + +# Update apt packages +RUN runDeps="openssl ca-certificates patch git" \ + && apt-get update \ + && apt-get install -y --no-install-recommends $runDeps \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* \ + && chown -R node /opt/frontend/ \ + && rm -rf /opt/frontend/src/addons/* \ + && cd /opt/frontend \ + && npm install -g mrs-developer WORKDIR /opt/frontend/ -RUN npm install -g mrs-developer + USER node ARG MAX_OLD_SPACE_SIZE=8192 ENV NODE_OPTIONS=--max_old_space_size=$MAX_OLD_SPACE_SIZE -RUN cd /opt/frontend - -RUN yarn develop -RUN RAZZLE_API_PATH=VOLTO_API_PATH RAZZLE_INTERNAL_API_PATH=VOLTO_INTERNAL_API_PATH yarn - -RUN RAZZLE_API_PATH=VOLTO_API_PATH RAZZLE_INTERNAL_API_PATH=VOLTO_INTERNAL_API_PATH yarn build \ +RUN cd /opt/frontend \ + && yarn develop \ + && RAZZLE_API_PATH=VOLTO_API_PATH RAZZLE_INTERNAL_API_PATH=VOLTO_INTERNAL_API_PATH yarn \ + && RAZZLE_API_PATH=VOLTO_API_PATH RAZZLE_INTERNAL_API_PATH=VOLTO_INTERNAL_API_PATH yarn build \ && rm -rf /home/node/.cache EXPOSE 3000 3001 4000 4001 ENTRYPOINT ["/opt/frontend/entrypoint-prod.sh"] CMD ["yarn", "start:prod"] -USER root \ No newline at end of file +USER root