| |
| FROM python:3.9-slim as builder |
|
|
| |
| RUN apt-get update && apt-get install -y \ |
| build-essential \ |
| gcc \ |
| g++ \ |
| && rm -rf /var/lib/apt/lists/* |
|
|
| |
| RUN python -m venv /opt/venv |
| ENV PATH="/opt/venv/bin:$PATH" |
|
|
| |
| COPY requirements.txt /tmp/requirements.txt |
| COPY webui/requirements.txt /tmp/webui_requirements.txt |
|
|
| |
| RUN pip install --no-cache-dir --upgrade pip && \ |
| pip install --no-cache-dir -r /tmp/requirements.txt |
|
|
| |
| RUN pip install --no-cache-dir -r /tmp/webui_requirements.txt |
|
|
| |
| RUN pip install --no-cache-dir gunicorn |
|
|
| |
| FROM python:3.9-slim |
|
|
| |
| RUN apt-get update && apt-get install -y \ |
| curl \ |
| && rm -rf /var/lib/apt/lists/* |
|
|
| |
| RUN useradd -m -u 1000 user && \ |
| mkdir -p /app && \ |
| chown -R user:user /app |
|
|
| |
| COPY --from=builder /opt/venv /opt/venv |
| ENV PATH="/opt/venv/bin:$PATH" |
|
|
| |
| WORKDIR /app |
|
|
| |
| COPY --chown=user:user . /app |
|
|
| |
| RUN chmod +x /app/webui/docker_start.sh |
|
|
| |
| USER user |
|
|
| |
| EXPOSE 7860 |
|
|
| |
| HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ |
| CMD curl -f http://localhost:7860/ || exit 1 |
|
|
| |
| ENV PYTHONPATH=/app |
| ENV FLASK_APP=webui/app.py |
| ENV FLASK_ENV=production |
| ENV PORT=7860 |
| ENV HF_HOME=/home/user/.cache/huggingface |
| ENV HUGGINGFACE_HUB_CACHE=/home/user/.cache/huggingface |
| ENV HF_HUB_DISABLE_TELEMETRY=1 |
| ENV PIP_NO_CACHE_DIR=1 |
|
|
| |
| CMD ["python", "webui/app.py"] |