feat: Node.js 增加 pnpm 支持 (#1503)

This commit is contained in:
zhengkunwang 2024-05-30 17:39:17 +08:00 committed by GitHub
parent 630097a4e0
commit efe865b334
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 87 additions and 13 deletions

View File

@ -1,6 +1,6 @@
services:
node:
image: node:${NODE_VERSION}
image: 1panel/node:${NODE_VERSION}
container_name: ${CONTAINER_NAME}
working_dir: /app
volumes:

View File

@ -6,6 +6,8 @@ if [[ "$PACKAGE_MANAGER" == "npm" ]]; then
npm config set registry $CONTAINER_PACKAGE_URL
elif [[ "$PACKAGE_MANAGER" == "yarn" ]]; then
yarn config set registry $CONTAINER_PACKAGE_URL
elif [[ "$PACKAGE_MANAGER" == "pnpm" ]]; then
pnpm config set registry $CONTAINER_PACKAGE_URL
fi
if [[ "$RUN_INSTALL" -eq "1" ]]; then
@ -13,6 +15,8 @@ if [[ "$RUN_INSTALL" -eq "1" ]]; then
npm install
elif [[ "$PACKAGE_MANAGER" == "yarn" ]]; then
yarn install
elif [[ "$PACKAGE_MANAGER" == "pnpm" ]]; then
pnpm install
else
echo "未知的 PACKAGE_MANAGER: $PACKAGE_MANAGER"
exit 1
@ -27,9 +31,8 @@ else
npm run $EXEC_SCRIPT
elif [[ "$PACKAGE_MANAGER" == "yarn" ]]; then
yarn run $EXEC_SCRIPT
elif [[ "$PACKAGE_MANAGER" == "pnpm" ]]; then
pnpm run $EXEC_SCRIPT
fi
fi

View File

@ -1,6 +1,6 @@
services:
node:
image: node:${NODE_VERSION}
image: 1panel/node:${NODE_VERSION}
container_name: ${CONTAINER_NAME}
working_dir: /app
volumes:

View File

@ -6,6 +6,8 @@ if [[ "$PACKAGE_MANAGER" == "npm" ]]; then
npm config set registry $CONTAINER_PACKAGE_URL
elif [[ "$PACKAGE_MANAGER" == "yarn" ]]; then
yarn config set registry $CONTAINER_PACKAGE_URL
elif [[ "$PACKAGE_MANAGER" == "pnpm" ]]; then
pnpm config set registry $CONTAINER_PACKAGE_URL
fi
if [[ "$RUN_INSTALL" -eq "1" ]]; then
@ -13,6 +15,8 @@ if [[ "$RUN_INSTALL" -eq "1" ]]; then
npm install
elif [[ "$PACKAGE_MANAGER" == "yarn" ]]; then
yarn install
elif [[ "$PACKAGE_MANAGER" == "pnpm" ]]; then
pnpm install
else
echo "未知的 PACKAGE_MANAGER: $PACKAGE_MANAGER"
exit 1
@ -27,9 +31,8 @@ else
npm run $EXEC_SCRIPT
elif [[ "$PACKAGE_MANAGER" == "yarn" ]]; then
yarn run $EXEC_SCRIPT
elif [[ "$PACKAGE_MANAGER" == "pnpm" ]]; then
pnpm run $EXEC_SCRIPT
fi
fi

View File

@ -1,6 +1,6 @@
services:
node:
image: node:${NODE_VERSION}
image: 1panel/node:${NODE_VERSION}
container_name: ${CONTAINER_NAME}
working_dir: /app
volumes:

View File

@ -6,6 +6,8 @@ if [[ "$PACKAGE_MANAGER" == "npm" ]]; then
npm config set registry $CONTAINER_PACKAGE_URL
elif [[ "$PACKAGE_MANAGER" == "yarn" ]]; then
yarn config set registry $CONTAINER_PACKAGE_URL
elif [[ "$PACKAGE_MANAGER" == "pnpm" ]]; then
pnpm config set registry $CONTAINER_PACKAGE_URL
fi
if [[ "$RUN_INSTALL" -eq "1" ]]; then
@ -13,6 +15,8 @@ if [[ "$RUN_INSTALL" -eq "1" ]]; then
npm install
elif [[ "$PACKAGE_MANAGER" == "yarn" ]]; then
yarn install
elif [[ "$PACKAGE_MANAGER" == "pnpm" ]]; then
pnpm install
else
echo "未知的 PACKAGE_MANAGER: $PACKAGE_MANAGER"
exit 1
@ -20,8 +24,15 @@ if [[ "$RUN_INSTALL" -eq "1" ]]; then
fi
if [[ "$PACKAGE_MANAGER" == "npm" ]]; then
npm run $EXEC_SCRIPT
elif [[ "$PACKAGE_MANAGER" == "yarn" ]]; then
yarn run $EXEC_SCRIPT
if [[ "$CUSTOM_SCRIPT" -eq "1" ]]; then
$EXEC_SCRIPT
else
if [[ "$PACKAGE_MANAGER" == "npm" ]]; then
npm run $EXEC_SCRIPT
elif [[ "$PACKAGE_MANAGER" == "yarn" ]]; then
yarn run $EXEC_SCRIPT
elif [[ "$PACKAGE_MANAGER" == "pnpm" ]]; then
pnpm run $EXEC_SCRIPT
fi
fi

View File

@ -0,0 +1 @@
additionalProperties:

View File

@ -0,0 +1,18 @@
services:
node:
image: 1panel/node:${NODE_VERSION}
container_name: ${CONTAINER_NAME}
working_dir: /app
volumes:
- ${CODE_DIR}:/app
- ./run.sh:/run.sh
- ./.env:/.env
command: bash /run.sh
networks:
- 1panel-network
ports:
- ${HOST_IP}:${PANEL_APP_PORT_HTTP}:${NODE_APP_PORT}
restart: always
networks:
1panel-network:
external: true

38
apps/node/22.2.0/run.sh Normal file
View File

@ -0,0 +1,38 @@
#!/bin/bash
source /.env
if [[ "$PACKAGE_MANAGER" == "npm" ]]; then
npm config set registry $CONTAINER_PACKAGE_URL
elif [[ "$PACKAGE_MANAGER" == "yarn" ]]; then
yarn config set registry $CONTAINER_PACKAGE_URL
elif [[ "$PACKAGE_MANAGER" == "pnpm" ]]; then
pnpm config set registry $CONTAINER_PACKAGE_URL
fi
if [[ "$RUN_INSTALL" -eq "1" ]]; then
if [[ "$PACKAGE_MANAGER" == "npm" ]]; then
npm install
elif [[ "$PACKAGE_MANAGER" == "yarn" ]]; then
yarn install
elif [[ "$PACKAGE_MANAGER" == "pnpm" ]]; then
pnpm install
else
echo "未知的 PACKAGE_MANAGER: $PACKAGE_MANAGER"
exit 1
fi
fi
if [[ "$CUSTOM_SCRIPT" -eq "1" ]]; then
$EXEC_SCRIPT
else
if [[ "$PACKAGE_MANAGER" == "npm" ]]; then
npm run $EXEC_SCRIPT
elif [[ "$PACKAGE_MANAGER" == "yarn" ]]; then
yarn run $EXEC_SCRIPT
elif [[ "$PACKAGE_MANAGER" == "pnpm" ]]; then
pnpm run $EXEC_SCRIPT
fi
fi