# 使用官方的Python运行时作为父镜像 FROM python:3.10-slim # 设置工作目录 WORKDIR /app # 更新系统包并安装wget RUN apt-get update && apt-get install -y git wget && rm -rf /var/lib/apt/lists/* # 安装 Conda RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh \ && bash miniconda.sh -b -p /opt/conda \ && rm miniconda.sh \ && /opt/conda/bin/conda update conda -y # 将 Conda 添加到 PATH ENV PATH="/opt/conda/bin:${PATH}" # 创建 Conda 环境 RUN conda create -n lagent python=3.10 -y # 激活 Conda 环境 SHELL ["conda", "run", "-n", "lagent", "/bin/bash", "-c"] # 安装 PyTorch 和其他依赖项 RUN conda install pytorch==2.1.2 torchvision==0.16.2 torchaudio==2.1.2 pytorch-cuda=12.1 -c pytorch -c nvidia -y RUN pip install termcolor==2.4.0 streamlit==1.39.0 class_registry==2.1.2 datasets==3.1.0 # 克隆代码仓库 RUN git clone https://github.com/InternLM/lagent.git WORKDIR /app/lagent RUN git checkout e304e5d RUN pip install -e . WORKDIR /app # 安装 griffe RUN pip install griffe==0.48.0 # 拷贝应用代码到工作目录 COPY . /app # 暴露端口 EXPOSE 8501 RUN which streamlit # 运行命令 ENV PATH="/opt/conda/envs/lagent/bin:$PATH" CMD ["streamlit", "run", "app.py", "--server.address", "0.0.0.0", "--server.port", "8501"] # CMD ["streamlit", "run", "app.py"] # CMD ["/bin/bash", "-c", "conda activate lagent && streamlit run app.py"]