From acc7301c069daeff68a8ad495e4f66bc2e61a137 Mon Sep 17 00:00:00 2001 From: Oliver Lazoroski Date: Mon, 2 Oct 2023 12:27:17 +0200 Subject: [PATCH] perf: multi-stage docker build --- .dockerignore | 4 +++- Dockerfile | 26 ++++++++++++++++++++------ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/.dockerignore b/.dockerignore index d7dd42f7f0..8db7cec227 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,6 +1,7 @@ **/node_modules/ **/dist/ **/.env* +**/.DS_Store .yarn/* !.yarn/patches !.yarn/plugins @@ -9,7 +10,8 @@ !.yarn/versions .github/ .readme-assets/ -sample-apps/react-native/ +sample-apps/** +!sample-apps/react/egress-composite/ packages/react-native-sdk/ sample-apps/react/egress-composite/tests/ .styles/ diff --git a/Dockerfile b/Dockerfile index 0c77ec31b0..b27fc28585 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,27 @@ -FROM node:20-bullseye - +FROM node:20-alpine as packager WORKDIR /e2e -COPY ./ ./ +COPY sample-apps/ sample-apps/ +RUN find sample-apps \! -name "package.json" -mindepth 3 -maxdepth 3 -print | xargs rm -rf -RUN ls && yarn install --inline-builds +COPY packages/ packages/ +RUN find packages \! -name "package.json" -mindepth 2 -maxdepth 2 -print | xargs rm -rf -RUN yarn build:react:deps +FROM node:20-bullseye as runner +WORKDIR /e2e -RUN npx playwright install chromium +COPY .yarn/ ./.yarn/ +COPY yarn.lock package.json .yarnrc.yml tsconfig.json ./ +COPY --from=packager /e2e/packages ./packages +COPY --from=packager /e2e/sample-apps ./sample-apps + +RUN yarn install +RUN npx playwright install chromium RUN npx playwright install-deps + +# Copy all sources next +COPY ./packages ./packages +RUN yarn build:react:deps + +COPY ./sample-apps/ ./sample-apps/