BuckLakeAI / Dockerfile
parkerjj's picture
更新 Dockerfile,安装 Spacy 及其模型;在 preprocess.py 中添加模型下载处理
8bf0955
# 使用官方的 Python 镜像作为基础镜像
FROM python:3.12
# 设置工作目录
WORKDIR /app
# 复制当前目录的内容到容器中的 /app 目录
COPY . /app
# 安装所需的 Python 包
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
# 安装必要依赖
RUN pip install --no-cache-dir spacy
# 公开 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
# 下载 Spacy 模型
RUN python -m spacy download en_core_web_md
# Get secret EXAMPLE and output it to /test at buildtime
RUN --mount=type=secret,id=HF_Token,mode=0444,required=true \
cat /run/secrets/HF_Token > $HOME/HF_Token
# Get secret SECRET_EXAMPLE and clone it as repo at buildtime
#RUN --mount=type=secret,id=HF_Token,mode=0444,required=true \
# git clone $(cat /run/secrets/HF_Token)
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]