├── .gitignore
├── .idea
├── .gitignore
├── inspectionProfiles
│ ├── Project_Default.xml
│ └── profiles_settings.xml
├── kasm-rpa-desktop.iml
├── misc.xml
├── modules.xml
├── vcs.xml
└── workspace.xml
├── Dockerfile
├── README.md
├── SwitchyOmega_Chromium.crx
├── demo
├── __init__.py
└── main.py
├── imgs
├── chrome1.png
├── chrome2.png
├── img.png
├── img_1.png
└── wechat.png
└── requirements.txt
/.gitignore:
--------------------------------------------------------------------------------
1 | ### Python template
2 | # Byte-compiled / optimized / DLL files
3 | __pycache__/
4 | *.py[cod]
5 | *$py.class
6 |
7 | # C extensions
8 | *.so
9 |
10 | # Distribution / packaging
11 | .Python
12 | build/
13 | develop-eggs/
14 | dist/
15 | downloads/
16 | eggs/
17 | .eggs/
18 | lib/
19 | lib64/
20 | parts/
21 | sdist/
22 | var/
23 | wheels/
24 | share/python-wheels/
25 | *.egg-info/
26 | .installed.cfg
27 | *.egg
28 | MANIFEST
29 |
30 | # PyInstaller
31 | # Usually these files are written by a python script from a template
32 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
33 | *.manifest
34 | *.spec
35 |
36 | # Installer logs
37 | pip-log.txt
38 | pip-delete-this-directory.txt
39 |
40 | # Unit test / coverage reports
41 | htmlcov/
42 | .tox/
43 | .nox/
44 | .coverage
45 | .coverage.*
46 | .cache
47 | nosetests.xml
48 | coverage.xml
49 | *.cover
50 | *.py,cover
51 | .hypothesis/
52 | .pytest_cache/
53 | cover/
54 |
55 | # Translations
56 | *.mo
57 | *.pot
58 |
59 | # Django stuff:
60 | *.log
61 | local_settings.py
62 | db.sqlite3
63 | db.sqlite3-journal
64 |
65 | # Flask stuff:
66 | instance/
67 | .webassets-cache
68 |
69 | # Scrapy stuff:
70 | .scrapy
71 |
72 | # Sphinx documentation
73 | docs/_build/
74 |
75 | # PyBuilder
76 | .pybuilder/
77 | target/
78 |
79 | # Jupyter Notebook
80 | .ipynb_checkpoints
81 |
82 | # IPython
83 | profile_default/
84 | ipython_config.py
85 |
86 | # pyenv
87 | # For a library or package, you might want to ignore these files since the code is
88 | # intended to run in multiple environments; otherwise, check them in:
89 | # .python-version
90 |
91 | # pipenv
92 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
94 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
95 | # install all needed dependencies.
96 | #Pipfile.lock
97 |
98 | # poetry
99 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
100 | # This is especially recommended for binary packages to ensure reproducibility, and is more
101 | # commonly ignored for libraries.
102 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
103 | #poetry.lock
104 |
105 | # pdm
106 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
107 | #pdm.lock
108 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
109 | # in version control.
110 | # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
111 | .pdm.toml
112 | .pdm-python
113 | .pdm-build/
114 |
115 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
116 | __pypackages__/
117 |
118 | # Celery stuff
119 | celerybeat-schedule
120 | celerybeat.pid
121 |
122 | # SageMath parsed files
123 | *.sage.py
124 |
125 | # Environments
126 | .env
127 | .venv
128 | env/
129 | venv/
130 | ENV/
131 | env.bak/
132 | venv.bak/
133 |
134 | # Spyder project settings
135 | .spyderproject
136 | .spyproject
137 |
138 | # Rope project settings
139 | .ropeproject
140 |
141 | # mkdocs documentation
142 | /site
143 |
144 | # mypy
145 | .mypy_cache/
146 | .dmypy.json
147 | dmypy.json
148 |
149 | # Pyre type checker
150 | .pyre/
151 |
152 | # pytype static type analyzer
153 | .pytype/
154 |
155 | # Cython debug symbols
156 | cython_debug/
157 |
158 | # PyCharm
159 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
160 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
161 | # and can be added to the global gitignore or merged into this file. For a more nuclear
162 | # option (not recommended) you can uncomment the following to ignore the entire idea folder.
163 | #.idea/
164 |
165 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luzihang123/kasm-rpa-desktop/cab1199d62400ab1d2d2343ca0d70af5236e4b41/.idea/.gitignore
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
145 |
146 |
147 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/kasm-rpa-desktop.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
22 |
23 |
24 |
25 |
26 |
27 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | 1740550048153
74 |
75 |
76 | 1740550048153
77 |
78 |
79 |
80 |
81 | 1740551980234
82 |
83 |
84 |
85 | 1740551980234
86 |
87 |
88 |
89 | 1740558353767
90 |
91 |
92 |
93 | 1740558353767
94 |
95 |
96 |
97 | 1740558456251
98 |
99 |
100 |
101 | 1740558456251
102 |
103 |
104 |
105 | 1740558997843
106 |
107 |
108 |
109 | 1740558997843
110 |
111 |
112 |
113 | 1740559732399
114 |
115 |
116 |
117 | 1740559732399
118 |
119 |
120 |
121 | 1740560622809
122 |
123 |
124 |
125 | 1740560622809
126 |
127 |
128 |
129 | 1740560948853
130 |
131 |
132 |
133 | 1740560948853
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM kasmweb/core-ubuntu-jammy:1.15.0
2 | USER root
3 |
4 | ADD ./ /data
5 |
6 | WORKDIR /data
7 |
8 | # 解压缩 .deb 文件
9 | RUN gzip -d google-chrome-stable_current_amd64.deb.gz \
10 | && gzip -d vscode_1.84.2-1699528352_amd64.deb.gz
11 |
12 | RUN apt -y update && mkdir -p /home/kasm-user/Desktop \
13 | # Chrome \
14 | && wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
15 | && apt-get install -y -f ./google-chrome-stable_current_amd64.deb \
16 | && sed -e '/chrome/ s/^#*/#/' -i /opt/google/chrome/google-chrome \
17 | && echo 'exec -a "$0" "$HERE/chrome" "$@" --user-data-dir="$HOME/.config/chrome" --no-sandbox --disable-dev-shm-usage --no-first-run --disable-infobars --no-default-browser-check' >> /opt/google/chrome/google-chrome \
18 | && rm -f google-chrome-stable_current_amd64.deb \
19 | # Visual Studio Code \
20 | && wget https://az764295.vo.msecnd.net/stable/1a5daa3a0231a0fbba4f14db7ec463cf99d7768e/code_1.84.2-1699528352_amd64.deb \
21 | && dpkg -i vscode_1.84.2-1699528352_amd64.deb \
22 | && sed -i 's/Exec=\/usr\/share\/code\/code/Exec=\/usr\/share\/code\/code --no-sandbox/g' /usr/share/applications/code.desktop \
23 | && sed -i 's/Icon=com.visualstudio.code/Icon=\/usr\/share\/code\/resources\/app\/resources\/linux\/code.png/g' /usr/share/applications/code.desktop \
24 | && ln -s /usr/share/applications/code.desktop /home/kasm-user/Desktop/code.desktop \
25 | # 使用阿里云的PyPI镜像源安装requirements.txt中列出的所有Python依赖
26 | && apt-get install -y sudo python3 python3-pip python3-tk python3-dev telnet vim git tmux cron curl gnome-screenshot unzip \
27 | && pip3 install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple \
28 | && apt autoremove -y \
29 | && apt clean \
30 | && rm -rf *.deb
31 |
32 | # 创建chrome策略文件目录
33 | RUN mkdir -p /etc/opt/chrome/policies/managed/
34 |
35 | # 添加chrome策略文件
36 | RUN echo '{"CommandLineFlagSecurityWarningsEnabled": false}' > /etc/opt/chrome/policies/managed/default_managed_policy.json
37 |
38 | # 配置系统时间和本地时间同步
39 | RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
40 |
41 | # 环境变量配置
42 | ENV TZ=Asia/Shanghai \
43 | LANG=zh_CN.UTF-8 \
44 | LANGUAGE=zh_CN:zh \
45 | DISPLAY=:0 \
46 | VNC_PW=123456
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # kasm-rpa-desktop
2 |
3 | 基于 Kasmweb 的 Docker RPA 开发环境,提供完整的 Ubuntu 桌面界面。预装 Chrome、DrissionPage、VSCode 等工具,专为 Web 自动化和 RPA 开发打造。
4 |
5 | # 背景
6 |
7 | 在我们当前的项目中,面临着一个有趣的挑战:如何通过自动化手段高效地查询网站信息并截图结果。这个需求不仅要求我们截取整个网页,还需要能够灵活地截取系统中的特定窗口。
8 |
9 | 在企业环境中,服务器大多运行在无图形界面的 CentOS 或 Ubuntu 系统上。随着技术的发展,项目部署逐渐转向 Kubernetes 集群,传统的虚拟机环境变得越来越少见。这种转变促使我们寻找新的解决方案,以便在无图形界面的环境中实现图形化的自动化操作。
10 |
11 | 因此,我们开发了这个基于 Kasmweb 的 Docker RPA 开发环境,旨在为开发者提供一个完整的 Ubuntu 桌面界面,预装了 Chrome、DrissionPage、VSCode 等工具,专为 Web 自动化和 RPA 开发而设计。
12 |
13 | # 优点
14 |
15 | - 基于docker虚拟化,方便部署,有界面。基于Kasmweb,提供完整的 Ubuntu 桌面界面。
16 | - 预装 Chrome、DrissionPage、VSCode 等工具,方便开发,适合 Web 自动化和 RPA 开发
17 | - 预装了python, DrissionPage, VSCode, Chrome
18 |
19 | # 使用方法
20 |
21 | ## 1、运行容器
22 |
23 | ```
24 | docker run -d \
25 | --name kasm-rpa-desktop \
26 | --shm-size=512m \
27 | -p 443:6901 \
28 | -e VNC_PW=123456 \
29 | -u root \
30 | --restart always \
31 | registry.cn-hangzhou.aliyuncs.com/luzihang/kasm-rpa-desktop
32 | ```
33 |
34 | ## 2、浏览器访问
35 |
36 | 浏览器访问访问 https://127.0.0.1 (注意是https)
37 |
38 | 点击忽略证书错误,依然访问。
39 |
40 | 
41 |
42 | ```
43 | 账号:kasm_web
44 | 密码:123456
45 | ```
46 |
47 | 
48 |
49 | ## 3、进入ubuntu桌面,打开终端,执行以下命令
50 |
51 | 
52 |
53 | ```
54 | tmux new -s 1
55 | python3 demo/main.py
56 | ```
57 |
58 | ## 4、成功界面
59 |
60 | 
61 |
62 | # 目前环境
63 |
64 | - Ubuntu 22.04.3 LTS
65 | - Python3.10.12
66 | - DrissionPage 4.1.0.17
67 | - VSCode 1.84.2
68 | - google-chrome-stable_current_amd64.deb 默认最新版本
69 |
70 | # 参考项目
71 |
72 | 1、https://github.com/gotoeasy/docker-ubuntu-desktop
73 |
74 | 相比于上述项目,通过VNC远程连接。本项目通过web访问系统,更加方便。python版本,ubuntu新一些。
75 |
76 | 提的issue:https://github.com/gotoeasy/docker-ubuntu-desktop/issues/16
77 |
78 | 2、https://github.com/colin-chang/ubuntu-desktop
79 |
80 | 相比于上述项目,本项目对Chrome做了一些配置优化。对于非开发软件,做了精简。
81 |
82 | # 微信交流
83 |
84 | wechat: lzh526154064
85 |
86 |
87 |
--------------------------------------------------------------------------------
/SwitchyOmega_Chromium.crx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luzihang123/kasm-rpa-desktop/cab1199d62400ab1d2d2343ca0d70af5236e4b41/SwitchyOmega_Chromium.crx
--------------------------------------------------------------------------------
/demo/__init__.py:
--------------------------------------------------------------------------------
1 | """
2 | Created on 2025/2/26 13:46
3 | @File: __init__.py.py
4 | ---------
5 | @summary:
6 | ---------
7 | @Author: luzihang
8 | """
9 |
--------------------------------------------------------------------------------
/demo/main.py:
--------------------------------------------------------------------------------
1 | """
2 | Created on 2025/2/26 13:53
3 | @File: main.py
4 | ---------
5 | @summary:
6 | ---------
7 | @Author: luzihang
8 | """
9 | from DrissionPage import Chromium
10 |
11 | tab = Chromium().latest_tab
12 | tab.get('https://DrissionPage.cn')
13 |
--------------------------------------------------------------------------------
/imgs/chrome1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luzihang123/kasm-rpa-desktop/cab1199d62400ab1d2d2343ca0d70af5236e4b41/imgs/chrome1.png
--------------------------------------------------------------------------------
/imgs/chrome2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luzihang123/kasm-rpa-desktop/cab1199d62400ab1d2d2343ca0d70af5236e4b41/imgs/chrome2.png
--------------------------------------------------------------------------------
/imgs/img.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luzihang123/kasm-rpa-desktop/cab1199d62400ab1d2d2343ca0d70af5236e4b41/imgs/img.png
--------------------------------------------------------------------------------
/imgs/img_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luzihang123/kasm-rpa-desktop/cab1199d62400ab1d2d2343ca0d70af5236e4b41/imgs/img_1.png
--------------------------------------------------------------------------------
/imgs/wechat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/luzihang123/kasm-rpa-desktop/cab1199d62400ab1d2d2343ca0d70af5236e4b41/imgs/wechat.png
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | DrissionPage==4.1.0.17
2 |
--------------------------------------------------------------------------------