ubuntu搭建Eclipse Theia

Eclipse Theia 是一个开源的、可扩展的基于Web的集成开发环境(IDE)。它由Eclipse Foundation支持,旨在提供一个通用的工具平台,可以用于构建各种类型的云端IDE、桌面IDE或者嵌入式IDE。

Ubuntu版本:Ubuntu 22.04.5 LTS


1、通过npm方式安装

1.1、基础环境配置

参考链接:https://juejin.cn/post/7215579793260511293

# 安装git
sudo apt-get install git unzip
# 安装nvm
下载地址:https://github.com/nvm-sh/nvm/tree/v0.40.1
unzip nvm-0.40.1.zip -d ~/.nvm
vi ~/.bashrc  # 添加一下三行
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm-0.40.1/nvm.sh" ] && \. "$NVM_DIR/nvm-0.40.1/nvm.sh"
[ -s "$NVM_DIR/nvm-0.40.1/bash_completion" ] && \. "$NVM_DIR/nvm-0.40.1/bash_completion"
source ~/.bashrc  # 生效
command -v nvm
# 安装npm并配置nmp镜像源
nvm install 18
npm config set registry https://registry.npmmirror.com
# 安装yarn,后面使用yarn安装依赖
npm i -g yarn
1.2、安装依赖
sudo apt update
sudo apt-get install build-essential libx11-dev libxkbfile-dev libsecret-1-dev

# 验证:
gcc --version
make --version
pkg-config --version
1.3、安装项目theia

官网:https://theia-ide.org/

# 下载: https://github.com/eclipse-theia/theia.git
unzip theia-master.zip
cd theia-master
yarn


# 在vmware上搭建的虚拟机网络老有问题,每次都提示“error Error: connect ECONNREFUSED 104.16.27.34:443”。在腾讯云轻量级服务器上搭建网络还是可以的,可以正常执行。

遇到问题:Expected version “>=18”. Got “16.20.2”

解决问题:sudo apt remove nodejs、sudo nvm install 18

下面是安装成功截图:

在这里插入图片描述

1.4、启动浏览器实例
yarn download:plugins \
  && yarn browser build \
  && yarn browser start  # 默认是127.0.0.1,只能本地访问

NODE_OPTIONS="--max-old-space-size=3096" yarn browser build && yarn browser start --hostname 0.0.0.0 --port 3000 

遇到问题:Mark-sweep (reduce) 1691.5 (1727.4) -> 1690.1 (1727.4) MB, 2946.8 / 0.0 ms (average mu = 0.111, current mu = 0.085) allocation failure; scavenge might not succeed,原因,由于内存不足导致的 JavaScript 堆内存溢出。

解决问题:使用指定的最大老生代空间大小

NODE_OPTIONS=“–max-old-space-size=3096” yarn browser build && yarn browser start

在这里插入图片描述

2、docker安装Theia

2.1、安装docker
1. 更新系统包列表
sudo apt update
# 更新时间:sudo date -s "2024-12-12 14:43:00"
2.安装一些允许apt使用https的软件包
sudo apt install apt-transport-https ca-certificates curl software-properties-common
3. 添加docker的gpg秘钥
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
4. 添加docker的仓库
sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
5. 再次更新系统包列表
sudo apt update
6. 安装docker
sudo apt install docker-ce
7. 验证
sudo docker --version
8. 允许非root用户运行Docker
sudo groupadd docker
sudo usermod -aG docker $USER
-- 然后,登出并重新登录,以便用户组更改生效。
9. 启动
sudo systemctl start docker
sudo systemctl enable docker
10. 若执行docker命令提示没有权限,只需要重启服务器即可。
2.2、安装theia
# 拉取镜像:
docker pull theiaide/theia:1.17.2
docker pull theiaide/theia:latest
# 运行theia镜像
# $(pwd)指当前目录,它会使用你当前目录作为工作目录;其中,–init参数是用来避免死进程问题的。
docker run -it -d --name theia --init -p 3000:3000 -v "$(pwd):/home/project:cached" theiaide/theia:1.17.2

1、遇到问题:拉取镜像时,提示“Error response from daemon: Get “https://registry-1.docker.io/v2/”: dial tcp: lookup registry-1.docker.io on 127.0.0.53:53: read udp 127.0.0.1:42025->127.0.0.53:53: i/o timeout”。

解决问题:解析失败了。

sudo vim /etc/resolv.conf
nameserver 8.8.8.8  # 修改nameserver行

sudo systemctl restart systemd-resolved
sudo systemctl restart docker

2、遇到问题:拉取镜像时,提示“Error response from daemon: Get “https://registry-1.docker.io/v2/”: context deadline exceeded”。

解决问题:系统时间不对

test@ubuntu-22-04:~$ date
Wed Dec 11 14:25:39 UTC 2024
test@ubuntu-22-04:~$ sudo date -s "2024-12-11 22:27:00"
Wed Dec 11 22:27:00 UTC 2024

3、遇到问题:拉取镜像时,提示“error response from daemon: Get “https://registry-1.docker.io/v2/”: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)"

解决问题:使用腾讯云镜像加速器

sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": [
        "https://docker.m.daocloud.io",
        "https://dockerproxy.com",
        "https://docker.mirrors.ustc.edu.cn",
        "https://docker.nju.edu.cn"
    ]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

4、重启systemd-resolved或者开机后, /etc/resolv.conf里面的nameserver就变回来了

解决问题:

# 禁用 systemd-resolved 的自动更新
sudo systemctl stop systemd-resolved
sudo systemctl disable systemd-resolved

实在不幸,Theia在hub.docker里面的相关信息都删除了。https://github.com/theia-ide/theia-apps?tab=readme-ov-file里面的容器链接都报404了。所以,docker pull不能使用了。

在这里插入图片描述

尝试下面的方式,发现也无法解析。可能docker的方式不能实现吧。

git clone https://github.com/theia-ide/theia-apps.git

cd theia-apps/theia-https-docker

docker build . --build-arg app=theia-full -t theiaide/theia-full-sec
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值