destiny-platform / Dockerfile
sunhonghua's picture
Upload 10 files
3cb3053 verified
Raw
History Blame Contribute Delete
935 Bytes
FROM python:3.10-slim
# 设置工作目录
WORKDIR /app
# 安装底层系统依赖(如有需要)
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# 复制需求文件并安装依赖
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# 为了使用 Gunicorn 来做 Linux 上的生产服务器
RUN pip install gunicorn
# 授权可访问整个应用
COPY . .
# Hugging Face 默认的开放端口是 7860
EXPOSE 7860
# 直接传入端口给配置或确保环境变量
ENV PORT=7860
ENV FLASK_APP=app.py
ENV SECRET_KEY="huggingface-production-secret-key-please-change"
ENV DEFAULT_ADMIN_PASSWORD="admin"
# 创建数据库及其权限,让 sqlite 能够运行(在HF上 /app 具有读写权限)
RUN chmod -R 777 /app
# 启动 Gunicorn 服务并挂载 Flask 应用
CMD ["gunicorn", "-b", "0.0.0.0:7860", "-w", "4", "app:app"]