File size: 2,010 Bytes
8cc1163
 
 
 
 
 
 
 
 
 
 
 
 
6a75bc0
 
 
 
 
 
 
 
8cc1163
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
48
49
50
51
52
53
# HARP dual-interpreter Space: pyharp/Gradio frontend (Python 3.10) +
# isolated model backend (Python 3.9) via one-shot subprocess IPC.
FROM python:3.10-slim-bullseye

ENV DEBIAN_FRONTEND=noninteractive \
    PYTHONUNBUFFERED=1 \
    PYTHONIOENCODING=UTF-8 \
    FRONTEND_VENV=/opt/frontend \
    BACKEND_VENV=/opt/backend \
    BACKEND_PYTHON=/opt/backend/bin/python \
    BACKEND_SCRIPT=/app/backend_worker.py \
    PORT=7860

# Debian 11 is end-of-life, so its packages now live on archive.debian.org.
# Point apt there before the first update, and accept the stale Release files.
RUN set -eux; \
    printf 'deb http://archive.debian.org/debian bullseye main\ndeb http://archive.debian.org/debian-security bullseye-security main\n' \
      > /etc/apt/sources.list; \
    rm -f /etc/apt/sources.list.d/*.list; \
    printf 'Acquire::Check-Valid-Until "false";\n' > /etc/apt/apt.conf.d/99no-check-valid-until

RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    curl \
    git \
    python3.9 \
    python3.9-dev \
    python3.9-venv \
    python3.9-distutils \
    libsndfile1 \
    libsndfile-dev \
    ffmpeg \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY requirements-backend.txt /tmp/requirements-backend.txt
RUN /usr/bin/python3.9 -m venv "$BACKEND_VENV" \
    && printf 'setuptools<81\nwheel\n' > /tmp/backend-build-constraints.txt \
    && "$BACKEND_VENV/bin/pip" install --no-cache-dir -U pip wheel "setuptools<81" \
    && PIP_CONSTRAINT=/tmp/backend-build-constraints.txt "$BACKEND_VENV/bin/pip" install --no-cache-dir -r /tmp/requirements-backend.txt

COPY requirements-frontend.txt /tmp/requirements-frontend.txt
RUN /usr/local/bin/python3.10 -m venv "$FRONTEND_VENV" \
    && "$FRONTEND_VENV/bin/pip" install --no-cache-dir -U pip wheel \
    && "$FRONTEND_VENV/bin/pip" install --no-cache-dir -r /tmp/requirements-frontend.txt

COPY backend_worker.py frontend_app.py start.sh ./
RUN chmod +x /app/start.sh

EXPOSE 7860
CMD ["/app/start.sh"]