From d2a5060ad2227ffdef9a9e844b7337e6bf3f3a77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Fri, 18 Sep 2020 18:00:03 +0200 Subject: [PATCH] Using multistage builds with protocol buffers --- back/Dockerfile | 8 ++++++-- front/Dockerfile | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/back/Dockerfile b/back/Dockerfile index 80c02529..f0c565f9 100644 --- a/back/Dockerfile +++ b/back/Dockerfile @@ -1,9 +1,13 @@ +FROM thecodingmachine/workadventure-back-base:latest as builder +WORKDIR /var/www/messages +COPY --chown=docker:docker messages . +RUN yarn install && yarn proto + FROM thecodingmachine/nodejs:12 COPY --chown=docker:docker back . -COPY --chown=docker:docker messages ../messages +COPY --from=builder --chown=docker:docker /var/www/messages /var/www/messages RUN yarn install -RUN cd /usr/src/messages && yarn install && yarn proto ENV NODE_ENV=production diff --git a/front/Dockerfile b/front/Dockerfile index 4a6a2e6a..98e29a52 100644 --- a/front/Dockerfile +++ b/front/Dockerfile @@ -1,10 +1,14 @@ +FROM thecodingmachine/workadventure-back-base:latest as builder +WORKDIR /var/www/messages +COPY --chown=docker:docker messages . +RUN yarn install && yarn proto + # we are rebuilding on each deploy to cope with the API_URL environment URL FROM thecodingmachine/nodejs:14-apache COPY --chown=docker:docker front . -COPY --chown=docker:docker messages /var/www/messages +COPY --from=builder --chown=docker:docker /var/www/messages /var/www/messages RUN yarn install -RUN cd /var/www/messages && yarn install && yarn proto ENV NODE_ENV=production ENV STARTUP_COMMAND_1="yarn run build"