From 19777c056de34df784cae1db1da4dab0749f5277 Mon Sep 17 00:00:00 2001 From: zhengkunwang223 Date: Tue, 31 Oct 2023 15:38:28 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20Node.JS=20=E6=96=B0=E5=A2=9E=2020.9.0?= =?UTF-8?q?=20(LTS)=20=E5=92=8C=2021.1.0=20(Current)=20=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/node/20.9.0/data.yml | 1 + apps/node/20.9.0/docker-compose.yml | 24 ++++++++++++++++++++ apps/node/20.9.0/run.sh | 35 +++++++++++++++++++++++++++++ apps/node/21.1.0/data.yml | 1 + apps/node/21.1.0/docker-compose.yml | 24 ++++++++++++++++++++ apps/node/21.1.0/run.sh | 35 +++++++++++++++++++++++++++++ 6 files changed, 120 insertions(+) create mode 100644 apps/node/20.9.0/data.yml create mode 100644 apps/node/20.9.0/docker-compose.yml create mode 100644 apps/node/20.9.0/run.sh create mode 100644 apps/node/21.1.0/data.yml create mode 100644 apps/node/21.1.0/docker-compose.yml create mode 100644 apps/node/21.1.0/run.sh diff --git a/apps/node/20.9.0/data.yml b/apps/node/20.9.0/data.yml new file mode 100644 index 00000000..fcc6ed69 --- /dev/null +++ b/apps/node/20.9.0/data.yml @@ -0,0 +1 @@ +additionalProperties: \ No newline at end of file diff --git a/apps/node/20.9.0/docker-compose.yml b/apps/node/20.9.0/docker-compose.yml new file mode 100644 index 00000000..3a2102f2 --- /dev/null +++ b/apps/node/20.9.0/docker-compose.yml @@ -0,0 +1,24 @@ +version: '3' +services: + node: + image: 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} + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:${NODE_APP_PORT} || exit 1"] + interval: 30s + timeout: 5s + retries: 20 + restart: always +networks: + 1panel-network: + external: true diff --git a/apps/node/20.9.0/run.sh b/apps/node/20.9.0/run.sh new file mode 100644 index 00000000..e7228d42 --- /dev/null +++ b/apps/node/20.9.0/run.sh @@ -0,0 +1,35 @@ +#!/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 +fi + +if [[ "$RUN_INSTALL" -eq "1" ]]; then + if [[ "$PACKAGE_MANAGER" == "npm" ]]; then + npm install + elif [[ "$PACKAGE_MANAGER" == "yarn" ]]; then + yarn 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 + fi +fi + + + + diff --git a/apps/node/21.1.0/data.yml b/apps/node/21.1.0/data.yml new file mode 100644 index 00000000..fcc6ed69 --- /dev/null +++ b/apps/node/21.1.0/data.yml @@ -0,0 +1 @@ +additionalProperties: \ No newline at end of file diff --git a/apps/node/21.1.0/docker-compose.yml b/apps/node/21.1.0/docker-compose.yml new file mode 100644 index 00000000..3a2102f2 --- /dev/null +++ b/apps/node/21.1.0/docker-compose.yml @@ -0,0 +1,24 @@ +version: '3' +services: + node: + image: 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} + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:${NODE_APP_PORT} || exit 1"] + interval: 30s + timeout: 5s + retries: 20 + restart: always +networks: + 1panel-network: + external: true diff --git a/apps/node/21.1.0/run.sh b/apps/node/21.1.0/run.sh new file mode 100644 index 00000000..e7228d42 --- /dev/null +++ b/apps/node/21.1.0/run.sh @@ -0,0 +1,35 @@ +#!/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 +fi + +if [[ "$RUN_INSTALL" -eq "1" ]]; then + if [[ "$PACKAGE_MANAGER" == "npm" ]]; then + npm install + elif [[ "$PACKAGE_MANAGER" == "yarn" ]]; then + yarn 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 + fi +fi + + + +