|
|
@@ -1,35 +1,131 @@
|
|
|
+# 代码开发
|
|
|
+```shell
|
|
|
+version: '3.8'
|
|
|
+
|
|
|
+services:
|
|
|
+ openhands-app:
|
|
|
+ image: docker.all-hands.dev/all-hands-ai/openhands:0.17
|
|
|
+ container_name: openhands-app-u1
|
|
|
+ volumes:
|
|
|
+ - /etc/localtime:/etc/localtime:ro
|
|
|
+ - ./config.toml:/app/config.toml
|
|
|
+ - .env:/app/.env
|
|
|
+ - ${WORKSPACE_MOUNT_PATH}:${WORKSPACE_MOUNT_PATH}
|
|
|
+ - /var/run/docker.sock:/var/run/docker.sock
|
|
|
+ - ./app/logs:/app/logs
|
|
|
+ - /home/mrh/program/openhands/OpenHands/openhands:/app/openhands
|
|
|
+ # - /home/mrh/program/openhands/OpenHands/openhands/runtime/impl/eventstream/eventstream_runtime.py:/app/openhands/runtime/impl/eventstream/eventstream_runtime.py
|
|
|
+ # - /home/mrh/program/openhands/OpenHands/openhands/server/listen_socket.py:/app/openhands/server/listen_socket.py
|
|
|
+ - /home/mrh/program/busybox-x86_64:/usr/local/bin/busybox
|
|
|
+ extra_hosts:
|
|
|
+ # 记得关闭防火墙,或者 sudo ufw allow from 172.0.0.0/8
|
|
|
+ - "host.docker.internal:host-gateway"
|
|
|
+ # network_mode: "bridge"
|
|
|
+ ports:
|
|
|
+ - "3001:3000"
|
|
|
+ # command: python
|
|
|
+ stdin_open: true
|
|
|
+ tty: true
|
|
|
+
|
|
|
+```
|
|
|
+
|
|
|
+# git 仓库分支
|
|
|
+
|
|
|
+## 合并官方仓库
|
|
|
+```shell
|
|
|
+cd OpenHands
|
|
|
+git pull
|
|
|
+git push gogs --tags
|
|
|
+git push gogs --all
|
|
|
+git reset --hard tags/0.17.0
|
|
|
+git branch
|
|
|
+# 切换到我的分支
|
|
|
+git checkout my-change
|
|
|
+# 拉取最新代码
|
|
|
+# 合入官方版本到我的分支
|
|
|
+git merge 0.18.0
|
|
|
+```
|
|
|
+
|
|
|
+## 提交主仓库和子仓库
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
# Runtime
|
|
|
|
|
|
## 命令行
|
|
|
```shell
|
|
|
# 创建环境
|
|
|
/openhands/micromamba/bin/micromamba create --prefix ./myenv python=3.12
|
|
|
+
|
|
|
+# 激活环境前需要先初始化
|
|
|
+/openhands/micromamba/bin/micromamba activate ./myenv
|
|
|
+
|
|
|
+'micromamba' is running as a subprocess and can't modify the parent shell.
|
|
|
+Thus you must initialize your shell before using activate and deactivate.
|
|
|
+
|
|
|
+To initialize the current bash shell, run:
|
|
|
+ $ eval "$(micromamba shell hook --shell bash)"
|
|
|
+and then activate or deactivate with:
|
|
|
+ $ micromamba activate
|
|
|
+To automatically initialize all future (bash) shells, run:
|
|
|
+ $ micromamba shell init --shell bash --root-prefix=~/.local/share/mamba
|
|
|
+If your shell was already initialized, reinitialize your shell with:
|
|
|
+ $ micromamba shell reinit --shell bash
|
|
|
+Otherwise, this may be an issue. In the meantime you can run commands. See:
|
|
|
+ $ micromamba run --help
|
|
|
+
|
|
|
+Supported shells are {bash, zsh, csh, posix, xonsh, cmd.exe, powershell, fish, nu}.
|
|
|
+critical libmamba Shell not initialized
|
|
|
```
|
|
|
|
|
|
## 构建自己的 Runtime 镜像
|
|
|
```shell
|
|
|
sudo docker build -t all-hands-code-server:0.16-nikolaik .
|
|
|
-
|
|
|
+sudo docker build -t all-hands-code-server:0.17-nikolaik .
|
|
|
```
|
|
|
|
|
|
## 修改自己的 Runtime 镜像
|
|
|
|
|
|
|
|
|
|
|
|
-### 修改源文件
|
|
|
+### dockerfile 修改源文件
|
|
|
```shell
|
|
|
MOUNT_REPO=/home/mrh/program/openhands/OpenHands;APP_REPO=/openhands/code;dk rm -f csruntime;
|
|
|
-dk run --name csruntime -it -v ${MOUNT_REPO}:${MOUNT_REPO} -e MOUNT_REPO=${MOUNT_REPO} -e APP_REPO=${APP_REPO} all-hands-code-server:0.16-nikolaik bash
|
|
|
+dk run --name csruntime -it -v ${MOUNT_REPO}:${MOUNT_REPO} -e MOUNT_REPO=${MOUNT_REPO} -e APP_REPO=${APP_REPO} -p 9806:9806 all-hands-code-server:0.16-nikolaik bash
|
|
|
cp ${MOUNT_REPO}/openhands/runtime/plugins/vscode/__init__.py ${APP_REPO}/openhands/runtime/plugins/vscode/__init__.py
|
|
|
exit
|
|
|
+docker start csruntime
|
|
|
docker exec -it csruntime bash
|
|
|
+code-server --bind-addr 0.0.0.0:9806 --auth none
|
|
|
+# 在浏览器中安装插件
|
|
|
# 提交并覆盖
|
|
|
docker commit csruntime all-hands-code-server:0.16-nikolaik
|
|
|
```
|
|
|
|
|
|
## code-server
|
|
|
+```shell
|
|
|
+MOUNT_REPO=/home/mrh/program/openhands/testm;EXTENSIONS_DIR=/home/mrh/program/openhands/testm/extensions;dk rm -f csruntime;
|
|
|
+dk run --name csruntime -it -v ${MOUNT_REPO}:${MOUNT_REPO} -v ${EXTENSIONS_DIR}:/root/.local/share/code-server/extensions/ -e MOUNT_REPO=${MOUNT_REPO} -p 9806:9806 all-hands-code-server:0.16-nikolaik bash
|
|
|
+# exit
|
|
|
+# docker start csruntime
|
|
|
+# docker exec -it csruntime bash
|
|
|
+# 不需要指定插件路径,已经默认挂载到 /root/.local/share/code-server/
|
|
|
+code-server --bind-addr 0.0.0.0:9806 --auth none
|
|
|
+# code-server --bind-addr 0.0.0.0:9806 --auth none --extensions-dir ${EXTENSIONS_DIR}
|
|
|
+
|
|
|
+# 访问浏览器code-server,手动安装 python 、 Chinese 、 vue 等插件。
|
|
|
+# 显示中文: https://code.visualstudio.com/docs/getstarted/locales
|
|
|
+中文插件配置文件路径 /root/.local/share/code-server/User/argv.json
|
|
|
+
|
|
|
+docker cp csruntime:/root /home/mrh/program/openhands/testm/runtime-code-server/
|
|
|
+# code-server --bind-addr 0.0.0.0:9806 --auth none --extensions-dir /root/.local/share/code-server/extensions/ --user-data-dir /root/.local/share/code-server/
|
|
|
+code-server --bind-addr 0.0.0.0:9806 --auth none --user-data-dir /root/.local/share/code-server/
|
|
|
+```
|
|
|
|
|
|
```shell
|
|
|
# 插件路径
|
|
|
file:///home/openhands/.local/share/code-server/extensions
|
|
|
+
|
|
|
+# ssl 路径 caddy
|
|
|
+/home/mrh/program/caddy/data/caddy/certificates/acme-v02.api.letsencrypt.org-directory/sv-v2.magong.site
|
|
|
```
|