Skip to content

Commit

Permalink
Reorganize Dockerfile to reduce image size
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinab25 committed Jun 15, 2021
1 parent 2c8729f commit bfaaf6e
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
USER root

0 comments on commit bfaaf6e

Please sign in to comment.