Skip to content

Jupyter 镜像构建文件

代码地址:04-jupyterhub-ai-enhanced/jupyter at main · prevailna/project-1-jupyter

目录结构

bash
jupyter/
├── README.md                          # 本文件
├── Dockerfile.jupyterhub              # JupyterHub 主服务镜像
├── Dockerfile.user-base               # 基础用户镜像
├── Dockerfile.user-scipy              # 科学计算用户镜像
├── Dockerfile.user-datascience        # 数据科学用户镜像
├── requirements.jupyterhub.txt        # JupyterHub 依赖
├── requirements.base.txt              # 基础镜像依赖
├── requirements.scipy.txt             # 科学计算镜像依赖
└── requirements.datascience.txt       # 数据科学镜像依赖

Dockerfile

JupyterHub

  • Dockerfile.jupyterhub: 构建 JupyterHub 主服务容器
  • requirements.jupyterhub.txt: JupyterHub 服务依赖

用户镜像

  • Dockerfile.user-base: 基础用户镜像 (最小化)
  • Dockerfile.user-scipy: 科学计算用户镜像 (平衡)
  • Dockerfile.user-datascience: 数据科学用户镜像 (完整)

使用方法

构建特定镜像

bash
make user-image-base        # 构建基础镜像
make user-image-scipy       # 构建科学计算镜像
make user-image-datascience # 构建数据科学镜像

通过环境变量选择

bash
# 在 .env 文件中设置
USER_IMAGE_TYPE=base        # 或 scipy 或 datascience

# 然后构建
make user-image

系统会自动根据 USER_IMAGE_TYPE 选择对应的镜像:

  • basejupyter-ai-user-image-base
  • scipyjupyter-ai-user-image-scipy
  • datasciencejupyter-ai-user-image-datascience

自定义镜像

如果需要自定义镜像:

  1. 复制对应的文件:

    bash
    cp jupyter/Dockerfile.user-base jupyter/Dockerfile.user-custom
    cp jupyter/requirements.base.txt jupyter/requirements.custom.txt
  2. 修改依赖: 编辑 requirements.custom.txt

  3. 更新 Dockerfile: 修改 COPY 路径

    dockerfile
    COPY jupyter/requirements.custom.txt /tmp/requirements.txt
  4. 构建镜像:

    bash
    docker build -f jupyter/Dockerfile.user-custom -t my-custom-image .