diff --git a/deploy/enterprise/Dockerfile b/deploy/enterprise/Dockerfile index 7c5e3d81df..e8f3dbb115 100644 --- a/deploy/enterprise/Dockerfile +++ b/deploy/enterprise/Dockerfile @@ -11,11 +11,6 @@ RUN apt-get update || : && apt-get install -y \ curl \ build-essential -RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - - -RUN apt-get update \ - && apt-get install -y gnupg curl nodejs - # Install MongoDB 4.4.25 # https://www.mongodb.com/docs/v4.4/tutorial/install-mongodb-on-ubuntu/ # https://github.com/docker-library/mongo/blob/66197d92be6eafc0a36b2570172de0a5f7a905e1/4.4/Dockerfile @@ -47,8 +42,21 @@ RUN apt-get update \ && apt-get remove -y git python3-pip python3-venv \ && apt-get clean -y -# yarn +# 安装 nvm 并安装 Node.js +ENV NVM_DIR=/root/.nvm + +RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash \ + && chmod +x "$NVM_DIR/nvm.sh" \ + && bash -c ". $NVM_DIR/nvm.sh && nvm install 14.21.3 && nvm install 20.18.1 && nvm alias default 14.21.3" + +# 确保在构建过程中可用 +ENV PATH=$NVM_DIR/versions/node/v14.21.3/bin:$PATH + +RUN apt-get update \ + && apt-get install -y gnupg curl nodejs + +# yarn RUN npm install --global yarn # platform @@ -81,6 +89,14 @@ WORKDIR /opt/steedos/nodered RUN yarn && yarn cache clean +# plugins +COPY ./app/plugins /opt/steedos/plugins +WORKDIR /opt/steedos/plugins + +RUN bash -c ". $NVM_DIR/nvm.sh && nvm use 20 && npm i --production" + +RUN bash -c ". $NVM_DIR/nvm.sh && nvm use 14" + COPY ./fs / # Remove cached files diff --git a/deploy/enterprise/app/platform/package.json b/deploy/enterprise/app/platform/package.json index c1eaec29e3..9df6bbcfce 100644 --- a/deploy/enterprise/app/platform/package.json +++ b/deploy/enterprise/app/platform/package.json @@ -10,7 +10,6 @@ }, "dependencies": { "lerna": "^4.0.0", - "@builder6/mongodb-api": "^0.0.8", "@steedos-labs/analytics": "^0.1.32", "@steedos/service-community": "~2.7", "@steedos/service-enterprise": "^2.5" diff --git a/deploy/enterprise/app/plugins/package.json b/deploy/enterprise/app/plugins/package.json new file mode 100644 index 0000000000..63f1ed81cd --- /dev/null +++ b/deploy/enterprise/app/plugins/package.json @@ -0,0 +1,9 @@ +{ + "name": "steedos-plugins", + "version": "0.0.0", + "main": "index.js", + "license": "MIT", + "dependencies": { + "@builder6/mongodb-api": "^0.0.9" + } +} diff --git a/deploy/enterprise/app/plugins/startup.sh b/deploy/enterprise/app/plugins/startup.sh new file mode 100755 index 0000000000..9c1b131621 --- /dev/null +++ b/deploy/enterprise/app/plugins/startup.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# 加载 nvm 环境 +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + +# 获取 Node.js 20 的实际路径 +NODE_PATH=$(nvm which 20) + +if [ -z "$NODE_PATH" ]; then + echo "Error: Node.js 14 is not installed. Please install it with nvm." + exit 1 +fi + +# 切换到工作目录 +cd /opt/steedos/plugins || exit + +# 使用 Node.js 14 运行应用 +exec "$NODE_PATH" ./node_modules/@builder6/mongodb-api/dist/main.js \ No newline at end of file diff --git a/deploy/enterprise/fs/opt/steedos/templates/supervisord/api.conf b/deploy/enterprise/fs/opt/steedos/templates/supervisord/api.conf index 2cfa45d7f6..d22105de78 100644 --- a/deploy/enterprise/fs/opt/steedos/templates/supervisord/api.conf +++ b/deploy/enterprise/fs/opt/steedos/templates/supervisord/api.conf @@ -1,6 +1,6 @@ [program:api] directory=/app/ -command=/opt/steedos/run-with-env.sh node ./node_modules/@builder6/mongodb-api/dist/main.js +command=/opt/steedos/run-with-env.sh /opt/steedos/plugins/startup.sh priority=15 autostart=true autorestart=true