sumi部署
# 容器版本部署
官方提供基本容器使用;
# https://github.com/opensumi/ide-startup/blob/master/Dockerfile
#版本记录
# https://github.com/opensumi/ide-startup/pkgs/container/opensumi-web
https://github.com/opensumi/ide-startup/pkgs/container/opensumi-web
# 拉取镜像
docker pull ghcr.io/opensumi/opensumi-web:latest
# 运行
docker run --rm -d -p 8765:8000/tcp ghcr.io/opensumi/opensumi-web:latest
#浏览器打开 http://0.0.0.0:8080
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
# 源码版本部署
直接参考startup项目中Dockerfile
设置;还原本地环境部署;
参考:
FROM node:14 as builder
# 用户工作空间,用于打包到前端工作空间地址
ENV WORKSPACE_DIR workspace
ENV EXTENSION_DIR extensions
COPY . .
ENV ELECTRON_MIRROR http://npm.taobao.org/mirrors/electron/
RUN mkdir -p ${WORKSPACE_DIR} &&\
mkdir -p ${EXTENSION_DIR}
RUN yarn --ignore-scripts --network-timeout 1000000&& \
yarn run build && \
yarn run download:extensions && \
rm -rf ./node_modules
FROM node:14 as app
ENV WORKSPACE_DIR /workspace
ENV EXTENSION_DIR /root/.sumi/extensions
ENV EXT_MODE js
ENV NODE_ENV production
RUN mkdir -p ${WORKSPACE_DIR} &&\
mkdir -p ${EXTENSION_DIR}
WORKDIR /release
COPY ./configs/docker/productionDependencies.json package.json
RUN yarn --network-timeout 1000000
COPY --from=builder dist dist
COPY --from=builder dist-node dist-node
COPY --from=builder hosted hosted
COPY --from=builder extensions /root/.sumi/extensions
EXPOSE 8000
CMD [ "node", "./dist-node/server/index.js" ]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
还原到167上部署:
build部分
yarn方式启动,因跟服务器端的yarn组件冲突了;要特殊处理;
cd ..
npm i -g node-gyp
npm init -y
npm i -S yarn
cd ide-startup-1.16.0
mkdir -p workspace extensions
npm config set registry https://registry.npm.taobao.org -g
#yarn config set registry https://registry.npm.taobao.org
#yarn config set electron_mirror https://npm.taobao.org/mirrors/electron
../node_modules/.bin/yarn config set registry https://registry.npm.taobao.org -g
../node_modules/.bin/yarn config set electron_mirror https://npm.taobao.org/mirrors/electron -g
#开发模式启动测试
rm -rf dist dist-node/ hosted/ node_modules/
../node_modules/.bin/yarn
../node_modules/.bin/yarn start
#build模式
# yarn --ignore-scripts --network-timeout 1000000 && yarn run build && yarn run download:extensions && rm -rf ./node_modules
#修改插件源 vi src/node/start-server.ts 修改为国内源
#// export const DEFAULT_OPENVSX_REGISTRY = 'https://marketplace.smartide.cn'; // China Mirror
#//export const DEFAULT_OPENVSX_REGISTRY = 'https://open-vsx.org'; // Official Registry
rm -rf dist dist-node/ hosted/ node_modules/
../node_modules/.bin/yarn --ignore-scripts --network-timeout 1000000
../node_modules/.bin/yarn run build
../node_modules/.bin/yarn run download:extensions
rm -rf ./node_modules
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
app启动部分
mkdir -p /root/.sumi/extensions web-ide/workspace
cd web-ide
cp ../configs/docker/productionDependencies.json package.json
#../../node_modules/.bin/yarn --network-timeout 1000000 这个直接用npm 安装试下
npm i
cp -rf ../dist ../dist-node ../hosted .
cp -rf ../extensions /root/.sumi/extensions
# node ./dist-node/server/index.js 改成pm2 安装启动
npm i -g pm2
#pm2 start ./dist-node/server/index.js -n ide
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
pm2.json
注意这里的env设置,只针对node环境有用,前端的环境配置只能在构建webpack中制定参数;
{
"apps" : [{
"name": "web-ide",
"script": "dist-node/server/index.js",
"env": {
"NODE_ENV": "production",
"IDE_SERVER_PORT": 8765
},
"log_date_format": "YYYY-MM-DD_HH:mm Z",
"merge_logs": true
}]
}
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
最后启动方式:
pm2 startOrRestart pm2.json
1
主要事项
生产环境下部署,访问项目的话,一定要指定workspaceDir
;
http://localhsot:8765?workspaceDir=/srv/bdp/hsh-shell-pro
1
上次更新: 2023/11/17, 05:08:19