未提供项目描述
项目描述
r-shepard
一个简单的、自托管的、用于协作(非实时)R计算的自托管解决方案,利用podman、RStudio和Tailscale。
使用Django和HTMX构建。
开发
首先使用devenv启动开发环境
devenv up # starts redis-server, celery worker (doing the task) and celery beat (scheduling the task)
run-tests # runs the tests
然后启动Django开发服务器
python manage.py runserver # This could also be done from your IDE / debugging environment
安装说明(Ubuntu 22.04)。
需求
- 安装podman(用于运行RStudio容器)、git(用于自动提交功能)和redis-server(用于celery,用于安排重复任务)。
sudo apt install podman git redis-server
准备环境
首先,建议为运行应用程序创建一个新的用户并设置一个强密码
sudo useradd r-shepard
此用户需要能够无需sudo运行podman
。为此,为用户分配子组ID和用户ID范围
echo "r-shepard:100000:65536" | sudo tee -a /etc/subuid
echo "r-shepard:100000:65536" | sudo tee -a /etc/subgid
但既然r-shepard
想要与Podman套接字通信,这就稍微复杂一些。要真正使用podman而不需要超级用户权限,您需要确保为用户运行了一个podman套接字。首先需要安装systemd-container
包,然后为正确的用户启用podman套接字。
sudo apt install systemd-container # This gives us machinectl
sudo loginctl enable-linger r-shepard # This ensures that the user's systemd instance is running after the user logs out or a reboot
sudo machinectl shell r-shepard@ /bin/systemctl --user enable --now podman.socket # This enables the podman.socket for the user
然后,切换到您的新系统用户并安装应用程序
sudo su -l r-shepard # Switch to the new user
pip install r-shepard # Install the application via PyPi
此时,您应该有r-shepard
命令可用。您可以通过运行
r-shepard --help
现在您可以使用此命令来管理应用程序。此命令是Django应用程序的manage.py
命令的包装器。为了正常工作,需要设置一些环境变量。最简单的方法是在用户的家目录中创建一个文件
# /home/r-shepard/.env
DEBUG=False
DB_PATH=/home/r-shepard/db.sqlite
SECRET_KEY=<your secret key>
ALLOWED_HOSTS=klips28.osi.uni-mannheim.de # This should be the hostname of the server
CSRF_TRUSTED_ORIGINS=https://klips28.osi.uni-mannheim.de # This should be the hostname of the server including the protocol
PODMAN_HOST_ADDRESS=klips28.osi.uni-mannheim.de # This should be the hostname of the server
PODMAN_SOCKET=unix:/run/user/1019/podman/podman.sock # This should be the path to the podman socket, which can be found by running `systemctl --machine r-shepard@ --user show podman.socket | grep Listen`
DATA_DIR=/home/r-shepard/data
WORKSPACE_DIR=/home/r-shepard/workspaces
STATIC_ROOT=/var/www/r-shepard/
确保文件中提到的所有位置都存在且用户可写。
现在,您可以通过应用迁移和收集静态文件来创建数据库。
r-shepard migrate
r-shepard collectstatic
然后,原则上您可以运行应用程序。
daphne -b 0.0.0.0 -p 8000 r_shepard.asgi:application
由于您可能在崩溃的情况下想要重新启动它,因此使用像 systemd
这样的进程管理器来管理应用程序是个好主意。总共需要三个文件:
一个用于应用程序本身。
# /etc/systemd/system/r-shepard.daphne.service
[Unit]
Description=Daphne ASGI server
After=network.target
[Service]
EnvironmentFile=/home/r-shepard/.env
ExecStart=/home/r-shepard/.local/bin/daphne -b 127.0.0.1 -p 8000 r_shepard.asgi:application
WorkingDirectory=/home/r-shepard
User=r-shepard
Group=r-shepard
Restart=always
SyslogIdentifier=daphne
[Install]
WantedBy=multi-user.target
一个用于celery工作进程。
# /etc/systemd/system/r-shepard.celery.service
[Unit]
Description=Celery Service
After=network.target
[Service]
EnvironmentFile=/home/r-shepard/.env
WorkingDirectory=/home/r-shepard
ExecStart=/home/r-shepard/.local/bin/celery -A r_shepard worker --loglevel=info
User=r-shepard
Group=r-shepard
Restart=always
SyslogIdentifier=celery
[Install]
WantedBy=multi-user.target
还有一个用于celery beat调度器。
# /etc/systemd/system/r-shepard.celery-beat.service
[Unit]
Description=Celery Beat Service
After=network.target
[Service]
EnvironmentFile=/home/r-shepard/.env
WorkingDirectory=/home/r-shepard
ExecStart=/home/r-shepard/.local/bin/celery -A r_shepard beat --loglevel=info
User=r-shepard
Group=r-shepard
Restart=always
SyslogIdentifier=celery-beat
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable r-shepard.*
sudo systemctl start r-shepard.*
现在,如果您想使由R-Shepard管理的容器在重启后自动启动,则需要为用户启用 podman-restart
服务。
cp /lib/systemd/system/podman-restart.service /lib/systemd/user/
machinectl shell r-shepard@ /bin/systemctl --user enable podman-restart
machinectl shell r-shepard@ /bin/systemctl --user start podman-restart
打开端口
如果您想从您的网络内部访问应用程序,您可能需要打开40000到41000端口。如果您使用 ufw
,可以通过以下命令来完成:
sudo ufw allow 40000:41000/tcp # This could be improved by allowing traffic only from the OSI network (or using something like Nebula)
最小可行性产品
- 为Ubuntu 22.04添加安装说明
-
gitwatch集成自己开发的解决方案。需要记录并将其集成到UI中。 - 移除tailscale,因为
tailscale serve/funnel
不工作(见此问题)。 - 在PyPi上发布
-
为项目创建添加视图目前Django管理器就足够了。 - 在容器内测试R项目/包管理(例如
renv
) - 添加卷管理
- 设置前端框架(例如
Bootstrap,PicoCSS) - 设置双因素认证
- 添加Tailscale Serve集成
- 通过podman添加基本的容器管理
- 为项目和容器管理添加基本视图
-
添加Tailscale Funnel集成目前不需要 -
使其能够将用户分配给项目(只有超级用户应该能够创建项目并将用户分配给它们)目前不需要
潜在的未来功能
- LDAP集成
- 容器特定和用户特定的自动提交
code-server
集成
项目详情
下载文件
下载适合您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。
源分发
构建分发
r_shepard-0.3.24.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | b1e67e510697c1bbabd2133b28016fb86e3ea99f7a1b349a015ca83360bbad4d |
|
MD5 | 1af960f996ca397a0edec6074499043b |
|
BLAKE2b-256 | 1050dbe454412f74d80454ada978b55672bd542d7da321bab09892b035c21869 |
r_shepard-0.3.24-py3-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 7fb773ff230dbc0d63baf9d7fa58f195717b107c80d221aec0b675f49e545c49 |
|
MD5 | 8cbbd3da6c5a10b350916d1dfd5538a1 |
|
BLAKE2b-256 | 4f3794c7ad0c82dd3266a7cee6b58f10051a254e79a2833e331fc77c55df6404 |