HF-Space-Deployer / Dockerfile
HuggingFace0920's picture
Update Dockerfile
239e53c verified
raw
history blame contribute delete
948 Bytes
# 使用Python 3.11作为基础镜像
FROM python:3.11-slim
# 设置工作目录
WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# 安装依赖,包括 git 和 redis-server
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
redis-server \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# 克隆仓库
RUN git clone https://github.com/kfcx/HFSpaceDeploy.git
RUN chmod +x HFSpaceDeploy/start.sh
# 设置工作目录为HFSpaceDeploy
WORKDIR /app/HFSpaceDeploy
# 安装 HFSpaceDeploy 目录下的 Python 依赖
RUN pip install --no-cache-dir -r requirements.txt
# 复制应用代码
COPY . .
# 创建非 root 用户,并赋予 /app 目录和脚本权限
RUN adduser --disabled-password --gecos "" appuser \
&& chown -R appuser:appuser /app
# 切换到非 root 用户
USER appuser
# 暴露端口
EXPOSE 7860
# 使用启动脚本启动 Redis 和 Python 应用
CMD ["./start.sh"]