From 6884fe83f35d759f68ca69ed93f860f4749e3548 Mon Sep 17 00:00:00 2001 From: Erik Stidham Date: Tue, 12 Aug 2025 15:17:59 -0500 Subject: [PATCH 1/2] Fix containerized option on Makefile --- .gitignore | 4 +++- Dockerfile.node | 16 ++++++++++++++++ Makefile | 22 +++++++++++++++++++++- 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 Dockerfile.node diff --git a/.gitignore b/.gitignore index f92e6e066c..62b7d51a48 100644 --- a/.gitignore +++ b/.gitignore @@ -22,9 +22,11 @@ builder/ npm-debug.log* .yarn/ +.yarn_type yarn-debug.log* yarn-error.log* yarn-serve-error.log +container.yarnrc.yml # VS Code / Jetbrains .vscode/ @@ -43,4 +45,4 @@ test-build .netlify /__screenshot-tests__/screenshot.spec.ts-snapshots -/__screenshot-tests__/pathnames.json \ No newline at end of file +/__screenshot-tests__/pathnames.json diff --git a/Dockerfile.node b/Dockerfile.node new file mode 100644 index 0000000000..4e4d7f6276 --- /dev/null +++ b/Dockerfile.node @@ -0,0 +1,16 @@ +# This Dockerfile is for use with the containerized versions of the docs Make commands +# To avoid needing to call `corepack enable` as part of all our commands, the Dockerfile +# runs the corepack enable command so the running of the command is cached in the docker +# image we use. + +ARG NODE_VER=latest +FROM node:${NODE_VER} + +# Make sure we're not prompted when corepack is going to download packages. +# This is needed because we're running docker with a pseudo-TTY so that we can kill yarn +# with a Ctrl+c +ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0 +RUN corepack enable + +ARG UID=1000 +RUN usermod -u $UID node diff --git a/Makefile b/Makefile index d513cfe1b6..fef4a9994a 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ NODE_VER=22 YARN=yarn YARN_ACTION_SUFFIX= ifeq ($(CONTAINERIZED),true) -YARN=docker run -i --rm -v "$(shell pwd):/docs" -p 127.0.0.1:3000:3000 -w /docs node:$(NODE_VER) corepack enable && yarn + YARN=docker run --name docs-node -u node -it --rm -v "$(shell pwd):/docs" -v "$(shell pwd)/container.yarnrc.yml:/docs/.yarnrc.yml" -p 127.0.0.1:3000:3000 -w /docs node_with_corepack:$(NODE_VER) yarn YARN_ACTION_SUFFIX=-container endif @@ -70,8 +70,28 @@ test: init clear clean: $(YARN) clear +# manual-clean is for when switching between local yarn commands and containerized +# This is because the new yarn type might not be functional to run the regular clear/clean +# but we need the environment clean to attempt the new yarn type. +.PHONY: manual-clean +manual-clean: + rm -rf node_modules .yarn .docusaurus build + .PHONY: init init: +ifeq ($(CONTAINERIZED),true) + # Create a modified yarnrc for use in the container environment + cp .yarnrc.yml container.yarnrc.yml + echo "globalFolder: /docs/.yarn" >> container.yarnrc.yml + # Build our custom node image that has corepack enabled + # repeated calls to this will be quick as the layers will be cached + docker buildx build --build-arg "NODE_VER=$(NODE_VER)" --build-arg "UID=$(shell id -u)" -t node_with_corepack:$(NODE_VER) --load -f Dockerfile.node . + if [ -f .yarn_type ] && [ "$$(cat .yarn_type)" != "containerized" ]; then $(MAKE) manual-clean; fi + echo containerized > .yarn_type +else + if [ -f .yarn_type ] && [ "$$(cat .yarn_type)" != "local" ]; then $(MAKE) manual-clean; fi + echo local > .yarn_type +endif $(YARN) install .PHONY: serve From 0652cfdb118c0858708ce318a54f19f2923ffa75 Mon Sep 17 00:00:00 2001 From: Erik Stidham Date: Thu, 14 Aug 2025 07:53:51 -0500 Subject: [PATCH 2/2] Tooling: Add start-next make target --- Makefile | 4 ++++ package.json | 1 + 2 files changed, 5 insertions(+) diff --git a/Makefile b/Makefile index fef4a9994a..b3cb4329b7 100644 --- a/Makefile +++ b/Makefile @@ -98,6 +98,10 @@ endif serve: build $(YARN) serve$(YARN_ACTION_SUFFIX) +.PHONY: serve-next +serve-next: build-next + $(YARN) serve$(YARN_ACTION_SUFFIX) + .PHONY: full full: clean build diff --git a/package.json b/package.json index 2ca6a07039..9d25e51427 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "start": "docusaurus start", "start-container": "docusaurus start -h 0.0.0.0", "start-next": "BUILD_NEXT=true docusaurus start", + "start-next-container": "BUILD_NEXT=true docusaurus start -h 0.0.0.0", "build": "DOCUSAURUS_IGNORE_SSG_WARNINGS=true docusaurus build", "build-next": "BUILD_NEXT=true yarn build", "swizzle": "docusaurus swizzle",