@@ -38,7 +38,7 @@ NODE_VER=22
3838YARN =yarn
3939YARN_ACTION_SUFFIX =
4040ifeq ($(CONTAINERIZED ) ,true)
41- YARN=docker run --name docs-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
41+ 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
4242YARN_ACTION_SUFFIX =-container
4343endif
4444
@@ -70,6 +70,13 @@ test: init
7070clear clean :
7171 $(YARN ) clear
7272
73+ # manual-clean is for when switching between local yarn commands and containerized
74+ # This is because the new yarn type might not be functional to run the regular clear/clean
75+ # but we need the environment clean to attempt the new yarn type.
76+ .PHONY : manual-clean
77+ manual-clean :
78+ rm -rf node_modules .yarn .docusaurus build
79+
7380.PHONY : init
7481init :
7582ifeq ($(CONTAINERIZED ) ,true)
@@ -78,7 +85,12 @@ ifeq ($(CONTAINERIZED),true)
7885 echo "globalFolder: /docs/.yarn" >> container.yarnrc.yml
7986 # Build our custom node image that has corepack enabled
8087 # repeated calls to this will be quick as the layers will be cached
81- docker buildx build --build-arg "NODE_VER=$(NODE_VER)" -t node_with_corepack:$(NODE_VER) --load -f Dockerfile.node .
88+ 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 .
89+ if [ -f .yarn_type ] && [ "$$(cat .yarn_type)" != "containerized" ]; then $(MAKE) manual-clean; fi
90+ echo containerized > .yarn_type
91+ else
92+ if [ -f .yarn_type ] && [ "$$(cat .yarn_type)" != "local" ]; then $(MAKE) manual-clean; fi
93+ echo local > .yarn_type
8294endif
8395 $(YARN) install
8496
0 commit comments