difybackend / Dockerfile
leonsimon23's picture
Update Dockerfile
bdfd3b6 verified
raw
history blame
762 Bytes
# syntax=docker/dockerfile:1.4
FROM python:3.11-slim
WORKDIR /app
# 1. 安装git
RUN apt-get update && apt-get install -y --no-install-recommends git && rm -rf /var/lib/apt/lists/*
# 2. 升级pip
RUN pip install --upgrade pip
# 3. 使用secret挂载方式安全地克隆私有仓库
RUN --mount=type=secret,id=GITHUB_TOKEN,required=true \
git clone https://x-access-token:$(cat /run/secrets/GITHUB_TOKEN)@github.com/leoncool23/difybackend.git . \
&& chmod -R 777 /app
# 4. 安装Python依赖
RUN pip install --no-cache-dir -r requirements.txt
# 5. 设置环境变量
ENV FLASK_APP=app.py
ENV FLASK_ENV=production
ENV PORT=7860
# 6. 暴露端口
EXPOSE 7860
# 7. 启动命令
CMD ["gunicorn", "--workers", "4", "--bind", "0.0.0.0:7860", "app:app"]