Skip to content

Commit

Permalink
Revert "Shift pnpify into final artefact, separate formatting again. …
Browse files Browse the repository at this point in the history
…[ci rebuild]"

This reverts commit a1b3ccc.
  • Loading branch information
charlielye committed Sep 26, 2023
1 parent d400647 commit 6efade5
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 38 deletions.
17 changes: 1 addition & 16 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down
14 changes: 13 additions & 1 deletion yarn-project/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
7 changes: 2 additions & 5 deletions yarn-project/aztec-sandbox/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 2 additions & 5 deletions yarn-project/canary/Dockerfile.build
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 2 additions & 5 deletions yarn-project/end-to-end/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
9 changes: 3 additions & 6 deletions yarn-project/yarn-project-base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 6efade5

Please sign in to comment.