From 6efade5ae2fcc1cc350dd6d7e7d592a886475f29 Mon Sep 17 00:00:00 2001 From: Charlie Lye Date: Tue, 26 Sep 2023 09:57:22 +0000 Subject: [PATCH] Revert "Shift pnpify into final artefact, separate formatting again. [ci rebuild]" This reverts commit a1b3cccd812d50e67d6402216d0fd13a282d0f19. --- .circleci/config.yml | 17 +---------------- yarn-project/Dockerfile | 14 +++++++++++++- yarn-project/aztec-sandbox/Dockerfile | 7 ++----- yarn-project/canary/Dockerfile.build | 7 ++----- yarn-project/end-to-end/Dockerfile | 7 ++----- yarn-project/yarn-project-base/Dockerfile | 9 +++------ 6 files changed, 23 insertions(+), 38 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ba8f4dc6f994..09b66fef55d8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -395,17 +395,6 @@ jobs: name: Build command: build yarn-project | add_timestamps - yarn-project-formatting: - machine: - image: ubuntu-2204:2023.07.2 - resource_class: large - steps: - - *checkout - - *setup_env - - run: - name: Check Formatting - command: cond_run_container yarn-project formatting | add_timestamps - yarn-project-tests: docker: - image: aztecprotocol/alpine-build-image @@ -414,7 +403,7 @@ jobs: - *checkout - *setup_env - run: - name: Test + name: Build command: cond_spot_run_container yarn-project 64 test | add_timestamps aztec-sandbox-base: @@ -1102,10 +1091,6 @@ workflows: - yarn-project-base - noir-contracts-build <<: *defaults - - yarn-project-formatting: - requires: - - yarn-project - <<: *defaults - yarn-project-tests: requires: - yarn-project diff --git a/yarn-project/Dockerfile b/yarn-project/Dockerfile index a718711f0cae..4516c7c2722f 100644 --- a/yarn-project/Dockerfile +++ b/yarn-project/Dockerfile @@ -14,7 +14,19 @@ RUN cd /usr/src/yarn-project/noir-contracts && yarn build && ./scripts/types_all # Cleanup to reduce final image size. RUN rm -rf noir-contracts/target -# Build the entire project. +# Build the entire project and check formatting. RUN yarn tsc -b +RUN yarn formatting +# We're happy. We now now enable pnp and create a slimmed down final image. +# This improves build times and results in smaller final containers for users to download. +# This effectively removes all the node_modules folders, just leaving the zipped packages in the global/local caches. +# Don't sacrifice this unless you've really hit some kind of wall caused by pnp, but if so, you can just comment out. +RUN mv .yarnrc.prod.yml .yarnrc.yml && yarn + +# Create final slim image. +FROM node:18-alpine +RUN apk update && apk add --no-cache bash jq +COPY --from=builder /usr/src /usr/src +WORKDIR /usr/src/yarn-project ENTRYPOINT ["yarn"] diff --git a/yarn-project/aztec-sandbox/Dockerfile b/yarn-project/aztec-sandbox/Dockerfile index 332409e6dc07..ce81c5f43d2b 100644 --- a/yarn-project/aztec-sandbox/Dockerfile +++ b/yarn-project/aztec-sandbox/Dockerfile @@ -14,11 +14,8 @@ RUN if [[ -n "${COMMIT_TAG}" ]]; then \ jq --arg v ${COMMIT_TAG} '.version = $v' package.json > _temp && mv _temp package.json; \ fi -# Productionify. See comment in yarn-project-base/Dockerfile. -RUN yarn cache clean && \ - mv ../.yarnrc.prod.yml ../.yarnrc.yml && \ - yarn workspaces focus --production > /dev/null && \ - rm -rf /usr/src/.yarn +# Prune dev dependencies. See comment in yarn-project-base/Dockerfile. +RUN yarn cache clean && yarn workspaces focus --production > /dev/null && rm -rf /usr/src/.yarn # Create final, minimal size image. FROM node:18-alpine diff --git a/yarn-project/canary/Dockerfile.build b/yarn-project/canary/Dockerfile.build index b3c5078d9131..32adb275019e 100644 --- a/yarn-project/canary/Dockerfile.build +++ b/yarn-project/canary/Dockerfile.build @@ -1,10 +1,7 @@ FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/yarn-project AS builder WORKDIR /usr/src/yarn-project/canary -# Productionify. See comment in yarn-project-base/Dockerfile. -RUN yarn cache clean && \ - mv ../.yarnrc.prod.yml ../.yarnrc.yml && \ - yarn workspaces focus --production > /dev/null && \ - rm -rf /usr/src/.yarn +# Prune dev dependencies. See comment in yarn-project-base/Dockerfile. +RUN yarn cache clean && yarn workspaces focus --production > /dev/null && rm -rf /usr/src/.yarn FROM node:18-alpine COPY --from=builder /usr/src /usr/src diff --git a/yarn-project/end-to-end/Dockerfile b/yarn-project/end-to-end/Dockerfile index 9d88b23ff32e..ead02df9bc7d 100644 --- a/yarn-project/end-to-end/Dockerfile +++ b/yarn-project/end-to-end/Dockerfile @@ -5,11 +5,8 @@ WORKDIR /usr/src/yarn-project/aztec.js RUN yarn build:web WORKDIR /usr/src/yarn-project/end-to-end -# Productionify. See comment in yarn-project-base/Dockerfile. -RUN yarn cache clean && \ - mv ../.yarnrc.prod.yml ../.yarnrc.yml && \ - yarn workspaces focus --production > /dev/null && \ - rm -rf /usr/src/.yarn +# Prune dev dependencies. See comment in yarn-project-base/Dockerfile. +RUN yarn cache clean && yarn workspaces focus --production > /dev/null && rm -rf /usr/src/.yarn # Create final, minimal size image. # TODO: Not very minimal as chromium adds about 500MB of bloat :/ Separate or install at test runtime? diff --git a/yarn-project/yarn-project-base/Dockerfile b/yarn-project/yarn-project-base/Dockerfile index fcb279563c8a..3c9850a07a07 100644 --- a/yarn-project/yarn-project-base/Dockerfile +++ b/yarn-project/yarn-project-base/Dockerfile @@ -38,19 +38,16 @@ # - Perform any code generation steps that require the workspace code (generate L2 contract wrappers). # - Build all the code, and runs formatting checks. # - Enable yarn pnp by replacing .yarnrc.yml with .yarnrc.prod.yml. +# - Perform a final yarn install to remove all node_modules folders and generate .pnp.cjs etc. +# - Create the final slim yarn-project image by copying /usr/src into a fresh image. # # When we build a downstream docker image, we: # - Do any project specific work in a "builder" stage. # - Erase the local cache with a `yarn cache clean`. Files will remain in global cache due to hard link. -# - Copy ../.yarnrc.prod.yml to ../.yarnrc.yml to enable pnp. # - Do a `yarn workspaces focus --production` to install production dependencies from the global to local cache. -# This will also strip away the node_modules folders due to pnp being enabled. # - Remove the global cache from /usr/src/.yarn. # - The above can be done with: -# RUN yarn cache clean && \ -# mv ../.yarnrc.prod.yml ../.yarnrc.yml && \ -# yarn workspaces focus --production > /dev/null && \ -# rm -rf /usr/src/.yarn +# RUN yarn cache clean && yarn workspaces focus --production > /dev/null && rm -rf /usr/src/.yarn # - Create final slim image by copying /usr/src into a fresh image. # # At the time of writing the following 3 images have the following sizes: