update
This commit is contained in:
69
docker/Dockerfile
Normal file
69
docker/Dockerfile
Normal file
@@ -0,0 +1,69 @@
|
||||
# 使用 Ubuntu 22.04 作为基础镜像(使用腾讯云镜像源)
|
||||
FROM ccr.ccs.tencentyun.com/library/ubuntu:22.04
|
||||
|
||||
# 设置环境变量
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
ENV PATH="/root/.pixi/bin:$PATH"
|
||||
|
||||
# 配置 APT 镜像源(使用阿里云镜像)
|
||||
RUN sed -i 's@//.*archive.ubuntu.com@//mirrors.aliyun.com@g' /etc/apt/sources.list && \
|
||||
sed -i 's@//.*security.ubuntu.com@//mirrors.aliyun.com@g' /etc/apt/sources.list
|
||||
|
||||
# 安装系统依赖
|
||||
RUN apt-get update && apt-get install -y \
|
||||
curl \
|
||||
wget \
|
||||
git \
|
||||
build-essential \
|
||||
ca-certificates \
|
||||
gnupg \
|
||||
lsb-release \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 配置 pip 镜像源
|
||||
RUN mkdir -p /root/.pip && \
|
||||
echo "[global]" > /root/.pip/pip.conf && \
|
||||
echo "index-url = https://pypi.tuna.tsinghua.edu.cn/simple" >> /root/.pip/pip.conf && \
|
||||
echo "trusted-host = pypi.tuna.tsinghua.edu.cn" >> /root/.pip/pip.conf
|
||||
|
||||
# 安装 pixi
|
||||
RUN curl -fsSL https://pixi.sh/install.sh | bash
|
||||
|
||||
# 设置工作目录
|
||||
WORKDIR /app
|
||||
|
||||
# 复制项目文件
|
||||
COPY . .
|
||||
|
||||
# 创建 bin 目录
|
||||
RUN mkdir -p bin
|
||||
|
||||
# 下载 AutoDock Vina 二进制文件
|
||||
ARG VINA_VERSION=1.2.7
|
||||
ARG VINA_PLATFORM=mac_aarch64
|
||||
ARG DOWNLOAD_VINA=true
|
||||
|
||||
RUN if [ "$DOWNLOAD_VINA" = "true" ]; then \
|
||||
curl -L -o ./bin/vina_${VINA_VERSION}_${VINA_PLATFORM} https://github.com/ccsb-scripps/AutoDock-Vina/releases/download/v${VINA_VERSION}/vina_${VINA_VERSION}_${VINA_PLATFORM} && \
|
||||
curl -L -o ./bin/vina_split_${VINA_VERSION}_${VINA_PLATFORM} https://github.com/ccsb-scripps/AutoDock-Vina/releases/download/v${VINA_VERSION}/vina_split_${VINA_VERSION}_${VINA_PLATFORM} && \
|
||||
chmod +x ./bin/vina_*; \
|
||||
fi
|
||||
|
||||
# 添加平台支持并安装 pixi 包
|
||||
RUN /root/.pixi/bin/pixi workspace platform add linux-aarch64 && \
|
||||
/root/.pixi/bin/pixi add rdkit openbabel meeko
|
||||
|
||||
# 设置环境变量
|
||||
ENV PATH="/root/.pixi/bin:/app/bin:$PATH"
|
||||
|
||||
# 创建启动脚本
|
||||
RUN echo '#!/bin/bash\n\
|
||||
source /root/.bashrc\n\
|
||||
exec "$@"' > /entrypoint.sh && \
|
||||
chmod +x /entrypoint.sh
|
||||
|
||||
# 设置入口点
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
||||
# 默认命令
|
||||
CMD ["/root/.pixi/bin/pixi", "shell"]
|
||||
201
docker/README.md
Normal file
201
docker/README.md
Normal file
@@ -0,0 +1,201 @@
|
||||
# Docker 环境使用说明
|
||||
|
||||
## 快速开始
|
||||
|
||||
### 1. 环境变量配置
|
||||
|
||||
```bash
|
||||
# 复制环境变量模板
|
||||
cp docker/docker.env.example docker/.env
|
||||
|
||||
# 编辑环境变量
|
||||
vim docker/.env
|
||||
```
|
||||
|
||||
### 2. 构建镜像
|
||||
|
||||
```bash
|
||||
# 使用默认配置构建
|
||||
docker-compose -f docker/docker-compose.yml build
|
||||
|
||||
# 使用环境变量构建
|
||||
docker-compose -f docker/docker-compose.yml --env-file docker/.env build
|
||||
|
||||
# 或者直接使用 docker build
|
||||
docker build -f docker/Dockerfile -t vinatools:latest .
|
||||
```
|
||||
|
||||
### 3. 环境变量说明
|
||||
|
||||
| 变量名 | 默认值 | 说明 |
|
||||
|--------|--------|------|
|
||||
| `VINA_VERSION` | `1.2.7` | AutoDock Vina 版本 |
|
||||
| `VINA_PLATFORM` | `mac_aarch64` | 平台架构 |
|
||||
| `DOWNLOAD_VINA` | `true` | 是否下载 AutoDock Vina |
|
||||
|
||||
**支持的平台:**
|
||||
- `mac_aarch64` - Apple Silicon Mac
|
||||
- `mac_x86_64` - Intel Mac
|
||||
- `linux_x86_64` - Linux x86_64
|
||||
- `windows_x86_64` - Windows x86_64
|
||||
|
||||
### 4. 运行容器
|
||||
|
||||
```bash
|
||||
# 启动主服务
|
||||
docker-compose -f docker/docker-compose.yml up -d vinatools
|
||||
|
||||
# 进入容器
|
||||
docker-compose -f docker/docker-compose.yml exec vinatools bash
|
||||
|
||||
# 或者直接运行
|
||||
docker run -it --rm -v $(pwd):/app vinatools:latest bash
|
||||
```
|
||||
|
||||
## 使用示例
|
||||
|
||||
### 不同平台构建
|
||||
|
||||
```bash
|
||||
# Linux x86_64 平台
|
||||
VINA_PLATFORM=linux_x86_64 docker-compose -f docker/docker-compose.yml build
|
||||
VINA_PLATFORM=linux_aarch64 docker-compose -f docker/docker-compose.yml build
|
||||
|
||||
# Intel Mac 平台
|
||||
VINA_PLATFORM=mac_x86_64 docker-compose -f docker/docker-compose.yml build
|
||||
|
||||
# 不下载 AutoDock Vina
|
||||
DOWNLOAD_VINA=false docker-compose -f docker/docker-compose.yml build
|
||||
```
|
||||
|
||||
### 使用环境文件
|
||||
|
||||
```bash
|
||||
# 创建自定义环境文件
|
||||
cat > docker/my.env << EOF
|
||||
VINA_VERSION=1.2.6
|
||||
VINA_PLATFORM=linux_x86_64
|
||||
DOWNLOAD_VINA=true
|
||||
EOF
|
||||
|
||||
# 使用自定义环境文件构建
|
||||
docker-compose -f docker/docker-compose.yml --env-file docker/my.env build
|
||||
```
|
||||
|
||||
### 3. 使用 Jupyter Notebook
|
||||
|
||||
```bash
|
||||
# 启动 Jupyter 服务
|
||||
docker-compose -f docker/docker-compose.yml up -d jupyter
|
||||
|
||||
# 访问 http://localhost:8888
|
||||
```
|
||||
|
||||
## 环境说明
|
||||
|
||||
### 镜像源配置
|
||||
为了加速构建过程,Dockerfile 中配置了以下镜像源:
|
||||
|
||||
- **APT 源**: 阿里云镜像 (mirrors.aliyun.com)
|
||||
- **pip 源**: 清华大学镜像 (pypi.tuna.tsinghua.edu.cn)
|
||||
- **conda 源**: 清华大学镜像 (mirrors.tuna.tsinghua.edu.cn)
|
||||
|
||||
### 包含的包
|
||||
- **rdkit**: 化学信息学工具包
|
||||
- **openbabel**: 分子格式转换工具
|
||||
- **meeko**: 分子准备工具
|
||||
- **AutoDock Vina**: 分子对接工具
|
||||
|
||||
### 目录结构
|
||||
```
|
||||
/app/
|
||||
├── bin/ # AutoDock Vina 二进制文件
|
||||
├── scripts/ # Python 脚本
|
||||
├── data/ # 输入数据(挂载)
|
||||
└── results/ # 输出结果(挂载)
|
||||
```
|
||||
|
||||
## 常用命令
|
||||
|
||||
### 运行脚本
|
||||
```bash
|
||||
# 在容器中运行 Python 脚本
|
||||
pixi run python scripts/calculate_qed_values.py
|
||||
|
||||
# 运行批处理脚本
|
||||
pixi run bash scripts/batch_docking.sh
|
||||
```
|
||||
|
||||
### 数据管理
|
||||
```bash
|
||||
# 挂载数据目录
|
||||
docker run -it --rm \
|
||||
-v $(pwd)/data:/app/data \
|
||||
-v $(pwd)/results:/app/results \
|
||||
vinatools:latest bash
|
||||
```
|
||||
|
||||
### 清理
|
||||
```bash
|
||||
# 停止所有服务
|
||||
docker-compose -f docker/docker-compose.yml down
|
||||
|
||||
# 删除镜像
|
||||
docker rmi vinatools:latest
|
||||
|
||||
# 清理未使用的资源
|
||||
docker system prune -a
|
||||
```
|
||||
|
||||
## 故障排除
|
||||
|
||||
### 网络连接问题
|
||||
如果遇到网络连接问题,可以尝试以下解决方案:
|
||||
|
||||
```bash
|
||||
# 1. 使用代理构建
|
||||
docker build --build-arg HTTP_PROXY=http://proxy:port \
|
||||
--build-arg HTTPS_PROXY=http://proxy:port \
|
||||
-f docker/Dockerfile -t vinatools:latest .
|
||||
|
||||
# 2. 使用不同的镜像源
|
||||
# 编辑 Dockerfile,替换镜像源:
|
||||
# - APT: mirrors.ustc.edu.cn (中科大)
|
||||
# - pip: pypi.douban.com (豆瓣)
|
||||
# - conda: mirrors.ustc.edu.cn/anaconda/cloud/
|
||||
|
||||
# 3. 离线构建(如果网络完全不可用)
|
||||
# 预先下载所有依赖包,然后使用本地构建
|
||||
```
|
||||
|
||||
### 权限问题
|
||||
```bash
|
||||
# 修复文件权限
|
||||
sudo chown -R $USER:$USER data/ results/
|
||||
```
|
||||
|
||||
### 内存不足
|
||||
```bash
|
||||
# 增加 Docker 内存限制
|
||||
docker run -it --rm --memory=8g vinatools:latest bash
|
||||
```
|
||||
|
||||
### 网络问题
|
||||
```bash
|
||||
# 使用主机网络
|
||||
docker run -it --rm --network=host vinatools:latest bash
|
||||
```
|
||||
|
||||
### 镜像源切换
|
||||
如果需要使用其他镜像源,可以修改 Dockerfile 中的配置:
|
||||
|
||||
```dockerfile
|
||||
# APT 源切换
|
||||
RUN sed -i 's@//.*archive.ubuntu.com@//mirrors.ustc.edu.cn@g' /etc/apt/sources.list
|
||||
|
||||
# pip 源切换
|
||||
RUN echo "index-url = https://pypi.douban.com/simple" > /root/.pip/pip.conf
|
||||
|
||||
# conda 源切换
|
||||
RUN /root/.pixi/bin/pixi config set channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
|
||||
```
|
||||
70
docker/docker-compose.yml
Normal file
70
docker/docker-compose.yml
Normal file
@@ -0,0 +1,70 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
vinatools:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: docker/Dockerfile
|
||||
args:
|
||||
VINA_VERSION: ${VINA_VERSION:-1.2.7}
|
||||
VINA_PLATFORM: ${VINA_PLATFORM:-linux}
|
||||
DOWNLOAD_VINA: ${DOWNLOAD_VINA:-true}
|
||||
image: vinatools:latest
|
||||
container_name: vinatools-container
|
||||
volumes:
|
||||
# 挂载项目目录到容器
|
||||
- ..:/app
|
||||
# 挂载数据目录(用于输入输出文件)
|
||||
- ./data:/app/data
|
||||
- ./results:/app/results
|
||||
working_dir: /app
|
||||
environment:
|
||||
- PIXI_ROOT=/root/.pixi
|
||||
- PATH=/root/.pixi/bin:/app/bin:$PATH
|
||||
# 保持容器运行
|
||||
tty: true
|
||||
stdin_open: true
|
||||
# 网络模式
|
||||
network_mode: host
|
||||
# 重启策略
|
||||
restart: unless-stopped
|
||||
# 资源限制
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
memory: 4G
|
||||
cpus: '2.0'
|
||||
reservations:
|
||||
memory: 2G
|
||||
cpus: '1.0'
|
||||
|
||||
# 可选:用于 Jupyter Notebook 服务
|
||||
jupyter:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: docker/Dockerfile
|
||||
args:
|
||||
VINA_VERSION: ${VINA_VERSION:-1.2.7}
|
||||
VINA_PLATFORM: ${VINA_PLATFORM:-linux_x86_64}
|
||||
DOWNLOAD_VINA: ${DOWNLOAD_VINA:-true}
|
||||
image: vinatools:latest
|
||||
container_name: vinatools-jupyter
|
||||
ports:
|
||||
- "8888:8888"
|
||||
volumes:
|
||||
- ..:/app
|
||||
- ./data:/app/data
|
||||
- ./results:/app/results
|
||||
working_dir: /app
|
||||
environment:
|
||||
- PIXI_ROOT=/root/.pixi
|
||||
- PATH=/root/.pixi/bin:/app/bin:$PATH
|
||||
command: >
|
||||
bash -c "
|
||||
/root/.pixi/bin/pixi workspace platform add linux-aarch64 &&
|
||||
/root/.pixi/bin/pixi add jupyter notebook &&
|
||||
/root/.pixi/bin/pixi run jupyter notebook --ip=0.0.0.0 --port=8888 --no-browser --allow-root --NotebookApp.token='' --NotebookApp.password=''
|
||||
"
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- vinatools
|
||||
12
docker/docker.env.example
Normal file
12
docker/docker.env.example
Normal file
@@ -0,0 +1,12 @@
|
||||
# AutoDock Vina 配置
|
||||
VINA_VERSION=1.2.7
|
||||
VINA_PLATFORM=mac_aarch64
|
||||
DOWNLOAD_VINA=true
|
||||
|
||||
# 其他平台选项:
|
||||
# VINA_PLATFORM=linux_x86_64
|
||||
# VINA_PLATFORM=mac_x86_64
|
||||
# VINA_PLATFORM=windows_x86_64
|
||||
|
||||
# 禁用 AutoDock Vina 下载
|
||||
# DOWNLOAD_VINA=false
|
||||
Reference in New Issue
Block a user