FROM ubuntu:latest # 使用阿里云的Ubuntu源替换默认源 # RUN echo "deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse" > /etc/apt/sources.list && \ # echo "deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse" >> /etc/apt/sources.list && \ # echo "deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse" >> /etc/apt/sources.list && \ # echo "deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse" >> /etc/apt/sources.list && \ # echo "deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse" >> /etc/apt/sources.list # 更新软件包列表并安装依赖项 RUN apt-get update && apt-get install -y \ software-properties-common \ libgl1-mesa-glx \ libxi6 \ libxxf86vm1 \ libxfixes3 \ libxrender1 \ libx11-6 \ libsdl2-2.0-0 \ libopenal1 \ libxrandr2 \ libfreetype6 \ libtiff5 \ libjpeg8 \ libpng16-16 \ zlib1g \ wget \ python3 \ python3-pip \ libxi6 \ libglu1-mesa \ libxext6 # 下载并安装Blender RUN wget https://mirrors.tuna.tsinghua.edu.cn/blender/release/Blender2.93/blender-2.93.1-linux-x64.tar.xz && \ tar xf blender-2.93.1-linux-x64.tar.xz && \ mv blender-2.93.1-linux-x64 /opt/blender && \ rm blender-2.93.1-linux-x64.tar.xz # 将Blender的可执行文件路径添加到PATH中 ENV PATH="$PATH:/opt/blender" # 安装Python依赖项 RUN pip3 install fastapi[all] uvicorn # 工作目录 WORKDIR /workspace RUN mkdir /workspace/temp # 将你的API代码和Blender Python脚本复制到工作目录中 COPY ./api_script.py /workspace/ COPY ./add_thickness.py /workspace/ # 暴露API使用的端口 EXPOSE 8000 # 启动API CMD ["uvicorn", "api_script:app", "--host", "0.0.0.0", "--port", "8000"]