File size: 2,718 Bytes
ae9275e
ff36e71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
03b6c45
ff36e71
2c79dbf
 
 
 
508316a
ff36e71
 
 
 
e561127
 
 
 
 
 
 
 
 
 
7a1584a
 
 
 
 
3b02b50
7a1584a
 
 
8a83d52
508316a
 
2c79dbf
ff36e71
508316a
ff36e71
 
 
508316a
ff36e71
 
 
 
7e34fe7
2c79dbf
 
 
 
ff36e71
 
8a83d52
2c79dbf
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
FROM node:22

# Install dependencies for Puppeteer to run headlessly
RUN apt-get update && apt-get install -y \
    ca-certificates \
    fonts-liberation \
    libappindicator3-1 \
    libasound2 \
    libatk-bridge2.0-0 \
    libatk1.0-0 \
    libc6 \
    libcairo2 \
    libcups2 \
    libdbus-1-3 \
    libexpat1 \
    libfontconfig1 \
    libgbm1 \
    libgcc1 \
    libglib2.0-0 \
    libgtk-3-0 \
    libnspr4 \
    libnss3 \
    libpango-1.0-0 \
    libpangocairo-1.0-0 \
    libstdc++6 \
    libx11-6 \
    libx11-xcb1 \
    libxcb1 \
    libxcomposite1 \
    libxcursor1 \
    libxdamage1 \
    libxext6 \
    libxfixes3 \
    libxi6 \
    libxrandr2 \
    libxrender1 \
    libxss1 \
    libxtst6 \
    lsb-release \
    curl \
    xdg-utils \
    python3 \
    python3-venv \
    python3-pip \
    git \
    sudo \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# --- IServ filter: removes person, place and school names from IServ tasks (iserv-filter/, see src/api/iserv-filtered.js)
# Own unprivileged user and venv. Its process gets only API_BEARER_TOKEN, never the IServ secrets (see start.sh).
RUN useradd -m -s /bin/bash iserv_runner
RUN echo "node ALL=(iserv_runner) NOPASSWD: ALL" >> /etc/sudoers
COPY iserv-filter/requirements.txt /tmp/iserv-filter-requirements.txt
RUN python3 -m venv /opt/filter-venv \
    && /opt/filter-venv/bin/pip install --no-cache-dir --upgrade pip \
    && /opt/filter-venv/bin/pip install --no-cache-dir torch==2.12.1+cpu --extra-index-url https://download.pytorch.org/whl/cpu \
    && /opt/filter-venv/bin/pip install --no-cache-dir -r /tmp/iserv-filter-requirements.txt

# Download and setup Piper TTS
RUN mkdir -p piper_tts && \
    curl -L https://github.com/rhasspy/piper/releases/download/2023.11.14-2/piper_linux_x86_64.tar.gz -o piper.tar.gz && \
    tar -xzf piper.tar.gz -C piper_tts --strip-components=1 && \
    rm piper.tar.gz && \
    chmod +x piper_tts/piper && \
    curl -L "https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/de/de_DE/thorsten/high/de_DE-thorsten-high.onnx" -o piper_tts/de_DE-thorsten-high.onnx && \
    curl -L "https://huggingface.co/rhasspy/piper-voices/resolve/v1.0.0/de/de_DE/thorsten/high/de_DE-thorsten-high.onnx.json" -o piper_tts/de_DE-thorsten-high.onnx.json

# --- Python dependencies ---
# Install uv (fast python package manager) globally via pip to ensure it's in PATH
RUN pip3 install --break-system-packages uv

# Install Node modules
COPY package*.json ./
RUN npm install

# Copy application source
COPY . .

# Build Vite App
RUN npm run build


# Copy start script
RUN chmod +x /app/start.sh

# Expose Hugging Face Space port (Node.js)
EXPOSE 7860

# Start Node server + IServ filter
CMD ["/app/start.sh"]