Files
NeoBot/sandbox.Dockerfile
K2cr2O1 54f74d0e73 feat: 添加Docker沙箱代码执行功能
- 新增Docker沙箱执行环境,提供安全隔离的代码执行能力
- 重构code_py插件,使用Docker容器替代子进程执行
- 添加docker配置项和权限检查功能
- 实现代码执行队列和并发控制
- 新增广播插件,仅限管理员使用
2026-01-06 22:56:00 +08:00

20 lines
619 B
Docker
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 使用一个轻量级的 Python 官方镜像作为基础
FROM python:3.11-slim
# 创建一个低权限的用户来运行代码,增加安全性
# -S: 创建一个系统用户 (没有 home 目录)
# -u: 指定用户ID
# -g: 指定组ID
RUN groupadd -g 1001 sandbox && useradd -u 1001 -g sandbox -s /bin/sh -r sandbox
# 创建一个工作目录,用于存放和执行用户的代码
WORKDIR /sandbox
# 将目录所有权交给沙箱用户
RUN chown sandbox:sandbox /sandbox
# 切换到沙箱用户
USER sandbox
# 默认的启动命令是 python这样容器启动时可以直接执行 .py 文件
CMD ["python"]