From 3b9422095c68c8ff2eb97c244f257771c1df419d Mon Sep 17 00:00:00 2001 From: VPhung24 Date: Tue, 9 Jul 2024 18:00:14 +0000 Subject: [PATCH] Add support for bun as a webapp package manager (#800) This is working off pull request "[Add support for pnpm as a webapp build tool. #767](https://git.vdb.to/cerc-io/stack-orchestrator/pulls/767/files)" that adds `pnpm` package manager support for `nextjs` & `webapps`. `bun` default build output directory (defined as `CERC_BUILD_OUTPUT_DIR`) is `dist` which should already be handled with `pnpm` support in the previously mentioned [pull request](https://git.vdb.to/cerc-io/stack-orchestrator/pulls/767/files) Installing `bun` using `npm` following our previous `pnpm` installation ```zsh npm install -g bun ``` We'll be using `bun` as a package manager that works with `Node.js` projects as defined in bun's [docs](https://bun.sh/docs/cli/install) > The bun CLI contains a Node.js-compatible package manager designed to be a dramatically faster replacement for npm, yarn, and pnpm. It's a standalone tool that will work in pre-existing Node.js projects; if your project has a package.json, bun install can help you speed up your workflow. To test `next.js` apps using `node.js` and compatibility with all four packager managers -- `npm`, `yarn`, `pnpm`, and `bun` -- use the branches of snowball's [nextjs-package-manager-example-app](https://git.vdb.to/snowball/nextjs-package-manager-example-app) repo: `nextjs-package-manager/npm`, `nextjs-package-manager/yarn`, `nextjs-package-manager/pnpm`, `nextjs-package-manager/bun`. Co-authored-by: Vivian Phung Co-authored-by: David Boreham Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/800 Reviewed-by: David Boreham Co-authored-by: VPhung24 Co-committed-by: VPhung24 --- .../data/container-build/cerc-nextjs-base/Dockerfile | 2 ++ .../cerc-nextjs-base/scripts/apply-runtime-env.sh | 2 ++ .../data/container-build/cerc-nextjs-base/scripts/build-app.sh | 2 ++ .../cerc-nextjs-base/scripts/start-serving-app.sh | 2 ++ .../data/container-build/cerc-webapp-base/Dockerfile | 2 ++ .../data/container-build/cerc-webapp-base/scripts/build-app.sh | 2 ++ 6 files changed, 12 insertions(+) diff --git a/stack_orchestrator/data/container-build/cerc-nextjs-base/Dockerfile b/stack_orchestrator/data/container-build/cerc-nextjs-base/Dockerfile index d3ae8237..1cc29945 100644 --- a/stack_orchestrator/data/container-build/cerc-nextjs-base/Dockerfile +++ b/stack_orchestrator/data/container-build/cerc-nextjs-base/Dockerfile @@ -28,6 +28,8 @@ RUN \ && su ${USERNAME} -c "umask 0002 && npm install -g semver" \ # Install pnpm && su ${USERNAME} -c "umask 0002 && npm install -g pnpm" \ + # Install bun + && su ${USERNAME} -c "umask 0002 && npm install -g bun@1.1.x" \ && npm cache clean --force > /dev/null 2>&1 # [Optional] Uncomment this section to install additional OS packages. diff --git a/stack_orchestrator/data/container-build/cerc-nextjs-base/scripts/apply-runtime-env.sh b/stack_orchestrator/data/container-build/cerc-nextjs-base/scripts/apply-runtime-env.sh index ba0f725f..79aa0c02 100755 --- a/stack_orchestrator/data/container-build/cerc-nextjs-base/scripts/apply-runtime-env.sh +++ b/stack_orchestrator/data/container-build/cerc-nextjs-base/scripts/apply-runtime-env.sh @@ -14,6 +14,8 @@ if [ -z "$CERC_BUILD_TOOL" ]; then CERC_BUILD_TOOL=pnpm elif [ -f "yarn.lock" ]; then CERC_BUILD_TOOL=yarn + elif [ -f "bun.lockb" ]; then + CERC_BUILD_TOOL=bun else CERC_BUILD_TOOL=npm fi diff --git a/stack_orchestrator/data/container-build/cerc-nextjs-base/scripts/build-app.sh b/stack_orchestrator/data/container-build/cerc-nextjs-base/scripts/build-app.sh index 882ae05d..4e769224 100755 --- a/stack_orchestrator/data/container-build/cerc-nextjs-base/scripts/build-app.sh +++ b/stack_orchestrator/data/container-build/cerc-nextjs-base/scripts/build-app.sh @@ -13,6 +13,8 @@ if [ -z "$CERC_BUILD_TOOL" ]; then CERC_BUILD_TOOL=pnpm elif [ -f "yarn.lock" ]; then CERC_BUILD_TOOL=yarn + elif [ -f "bun.lockb" ]; then + CERC_BUILD_TOOL=bun else CERC_BUILD_TOOL=npm fi diff --git a/stack_orchestrator/data/container-build/cerc-nextjs-base/scripts/start-serving-app.sh b/stack_orchestrator/data/container-build/cerc-nextjs-base/scripts/start-serving-app.sh index 4b69d935..54cdf237 100755 --- a/stack_orchestrator/data/container-build/cerc-nextjs-base/scripts/start-serving-app.sh +++ b/stack_orchestrator/data/container-build/cerc-nextjs-base/scripts/start-serving-app.sh @@ -20,6 +20,8 @@ if [ -z "$CERC_BUILD_TOOL" ]; then CERC_BUILD_TOOL=pnpm elif [ -f "yarn.lock" ]; then CERC_BUILD_TOOL=yarn + elif [ -f "bun.lockb" ]; then + CERC_BUILD_TOOL=bun else CERC_BUILD_TOOL=npm fi diff --git a/stack_orchestrator/data/container-build/cerc-webapp-base/Dockerfile b/stack_orchestrator/data/container-build/cerc-webapp-base/Dockerfile index cfd461c9..856cc778 100644 --- a/stack_orchestrator/data/container-build/cerc-webapp-base/Dockerfile +++ b/stack_orchestrator/data/container-build/cerc-webapp-base/Dockerfile @@ -28,6 +28,8 @@ RUN \ && su ${USERNAME} -c "umask 0002 && npm install -g semver" \ # Install pnpm && su ${USERNAME} -c "umask 0002 && npm install -g pnpm" \ + # Install bun + && su ${USERNAME} -c "umask 0002 && npm install -g bun@1.1.x" \ && npm cache clean --force > /dev/null 2>&1 # [Optional] Uncomment this section to install additional OS packages. diff --git a/stack_orchestrator/data/container-build/cerc-webapp-base/scripts/build-app.sh b/stack_orchestrator/data/container-build/cerc-webapp-base/scripts/build-app.sh index 30358bbd..ce6be2f9 100755 --- a/stack_orchestrator/data/container-build/cerc-webapp-base/scripts/build-app.sh +++ b/stack_orchestrator/data/container-build/cerc-webapp-base/scripts/build-app.sh @@ -27,6 +27,8 @@ elif [ -f "${WORK_DIR}/package.json" ]; then CERC_BUILD_TOOL=pnpm elif [ -f "yarn.lock" ]; then CERC_BUILD_TOOL=yarn + elif [ -f "bun.lockb" ]; then + CERC_BUILD_TOOL=bun else CERC_BUILD_TOOL=npm fi