MAgent / Dockerfile
javaeeduke's picture
Create Dockerfile
3cbf058 verified
# 1. 基础镜像:Python 3.13 官方镜像
FROM docker.io/library/python:3.13@sha256:a922e65d7cd72025d709fe78f3847c4cf89cc69c6fe1b6902f1c4d39fe9af82e
# 2. 设置工作目录
WORKDIR /app
# 3. 环境变量设置
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
GRADIO_SERVER_NAME="0.0.0.0" \
GRADIO_SERVER_PORT=7860
# 4. 瘦身后的系统依赖安装(加上 --no-install-recommends,防止之前日志中的 OOM 卡死)
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
git-lfs \
ffmpeg \
cmake \
rsync \
libgl1 \
libsm6 \
libxext6 \
&& rm -rf /var/lib/apt/lists/* \
&& git lfs install
# 5. 复制依赖文件并安装
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# 6. 将当前目录下的所有代码复制到容器中
COPY . .
# 7. 暴露 Gradio 的 7860 端口(Hugging Face Spaces 等平台默认识别此端口)
EXPOSE 7860
# 8. 启动命令(假设你的 Gradio 入口文件名是 app.py)
CMD ["python", "app.py"]