Surge是一个开源的容器化工具,旨在提供轻量级、跨平台和跨系统环境,适用于开发、测试和部署。以下是对Surge的详细配置指南

hhn5588347 2026-09-19 科学上网 26 0

安装Surge

Linux 系统

  • 安装依赖:
    sudo apt-get install -y flask numpy pandas
  • 安装Surge并编译:
    sudo apt-get install -y surge-surge-dev
    sudo make -j$(nproc) -f $(pwd) --version
    # 编译Surge
    ./sage -j

Windows 系统

  • 安装依赖:
    maven -Dfl -p C:\Python38\bin  https://github.com/surge-dev/surge/releases/download/v2.12/surge-base-2.11-py3-none-any.whl

macOS 系统

  • 安装依赖:
    brew install -y flask numpy pandas
  • 安装Surge并编译:
    brew install -y surge-surge-dev
    ./sage -j

配置Surge

1 设置配置

  • root权限:
    chmod 755 surge
  • 配置文件位置:
    • 如果使用Jupyter Notebook:
      jupyter notebook --NotebookDir=/home/user/.jupyter notebook/ --py surge
    • 如果使用命令行:
      surge -c --root=/path/to/your/path/to/your/path/ --config=/path/to/your/path/your/surge_config.json

创建容器

1 创建容器

surge -c --root=/path/to/your/path/ --container=/path/to/your/path/your/surge_Containers/your_container_name

2 添加文件

  • 本地存储:
    surge -c --root=/path/to/your/path/ --file=/path/to/your/path/your/surge_Containers/your_container_name/your_file
  • S3存储:
    surge -c --root=/path/to/your/path/ --s3=/path/to/your/path/s3 --file=/path/to/your/path/your/surge_Containers/your_container_name/s3_path

运行容器

1 运行容器

surge -n --root=/path/to/your/path/ --container=/path/to/your/path/your/surge_Containers/your_container_name

2 在Jupyter Notebook运行

surge -n --root=/path/to/your/path/ --container=/path/to/your/path/your/surge_Containers/your_container_name

监控和监控工具

1 监控

surge -c --root=/path/to/your/path/ --surge --monitor --container=/path/to/your/path/your/surge_Containers/your_container_name

2 监控日志

surge --surge --log --container=/path/to/your/path/your/surge_Containers/your_container_name

文档管理

1 使用Surge处理S3存储

surge --surge --file=/path/to/your/path/s3_path --root=/path/to/your/path

容器管理和部署

1 创建容器

surge -c --root=/path/to/your/path/ --container=/path/to/your/path/your/surge_Containers/your_container_name

2 部署到目标系统

surge -d --root=/path/to/your/path/ --container=/path/to/your/path/your/surge_Containers/your_container_name

3 处理错误和故障日志

surge --failed --error --output=/path/to/your/path/your/surge_Containers/your_container_name

模块化设计

1 定义命令

from surge import Command
class MyCommand(Command):
    description = " 创建容器"
    options = [
        Command.option(name="root", help="指定根目录")
    ]
    def run(self, **kwargs):
        root = kwargs.get("root")
        self.stdout.write("创建容器在{}目录中的命令。".format(root))
        surge -n --root={root} --container=your_container_name

项目管理

1 注册项目

surge --project --root=/path/to/your/path

2 使用Git

git clone https://github.com/surge-dev/surge

进一步学习

Surge是一个开源的容器化工具,旨在提供轻量级、跨平台和跨系统环境,适用于开发、测试和部署。以下是对Surge的详细配置指南

扫码下载快连加速器

扫码下载快连加速器

0571-8826-7349
扫码下载快连加速器

扫码下载快连加速器

网站地图