Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand All @@ -43,4 +45,4 @@ test-build
.netlify

/__screenshot-tests__/screenshot.spec.ts-snapshots
/__screenshot-tests__/pathnames.json
/__screenshot-tests__/pathnames.json
16 changes: 16 additions & 0 deletions Dockerfile.node
Original file line number Diff line number Diff line change
@@ -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
26 changes: 25 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -70,14 +70,38 @@ 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
serve: build
$(YARN) serve$(YARN_ACTION_SUFFIX)

.PHONY: serve-next
serve-next: build-next
$(YARN) serve$(YARN_ACTION_SUFFIX)

.PHONY: full
full: clean build

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down