Spaces:
Running
Running
File size: 1,265 Bytes
a803b83 693eb6c fe0aec3 a803b83 fe0aec3 a803b83 953d202 8bf0955 fe0aec3 a803b83 fe0aec3 d4b1508 c237b52 d4b1508 c237b52 d4b1508 c237b52 d4b1508 c237b52 d4b1508 c237b52 d4b1508 878fde1 8bf0955 878fde1 91e61c6 878fde1 768a233 878fde1 417cad6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# 使用官方的 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"] |