Skip to content

Commit 4241313

Browse files
committed
WIP
1 parent 2b9b9cb commit 4241313

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
builder/
2323
npm-debug.log*
2424
.yarn/
25+
.yarn_type
2526
yarn-debug.log*
2627
yarn-error.log*
2728
yarn-serve-error.log

Dockerfile.node

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ FROM node:${NODE_VER}
1111
# with a Ctrl+c
1212
ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0
1313
RUN corepack enable
14+
15+
ARG UID=1000
16+
RUN usermod -u $UID node

Makefile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ NODE_VER=22
3838
YARN=yarn
3939
YARN_ACTION_SUFFIX=
4040
ifeq ($(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
4242
YARN_ACTION_SUFFIX=-container
4343
endif
4444

@@ -70,6 +70,13 @@ test: init
7070
clear 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
7481
init:
7582
ifeq ($(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
8294
endif
8395
$(YARN) install
8496

0 commit comments

Comments
 (0)