Skip to content

Commit

Permalink
docker,新增 plugins,并使用 nodejs 运行。
Browse files Browse the repository at this point in the history
  • Loading branch information
hotlong committed Dec 11, 2024
1 parent 775b8df commit dec34c0
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 8 deletions.
28 changes: 22 additions & 6 deletions deploy/enterprise/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion deploy/enterprise/app/platform/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 9 additions & 0 deletions deploy/enterprise/app/plugins/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "steedos-plugins",
"version": "0.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"@builder6/mongodb-api": "^0.0.9"
}
}
19 changes: 19 additions & 0 deletions deploy/enterprise/app/plugins/startup.sh
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit dec34c0

Please sign in to comment.