# 使用官方的 Python 镜像作为基础镜像 FROM python:3.12-slim # 设置工作目录 WORKDIR /app # 复制当前目录的内容到容器中的 /app 目录 COPY . /app # 安装所需的 Python 包 RUN pip install -r requirements.txt # 公开 Gradio 默认的端口 7860 EXPOSE 7860 # Set up a new user named "user" with user ID 1000 RUN useradd -m -u 1000 user # Switch to the "user" user USER user # Set home to the user's home directory ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH # Set the working directory to the user's home directory WORKDIR $HOME/app # Copy the current directory contents into the container at $HOME/app setting the owner to the user COPY --chown=user . $HOME/app CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]