File size: 1,478 Bytes
58f00c9
 
5f400f8
58f00c9
5f400f8
58f00c9
 
5f400f8
 
 
 
 
 
 
 
 
 
 
 
58f00c9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM python:3.12-slim

# ffmpeg/ffprobe: metadata + track keep/reorder (stream copy, no re-encoding); curl: fetches the Speedtest CLI below
RUN apt-get update \
    && apt-get install -y --no-install-recommends ffmpeg ca-certificates curl \
    && rm -rf /var/lib/apt/lists/*

# Ookla's official Speedtest CLI for /speed. Optional: if the download fails the build goes on and /speed
# uses the speedtest-cli Python package (also Ookla) instead.
RUN set -eux; \
    case "$(dpkg --print-architecture)" in amd64) arch=x86_64 ;; arm64) arch=aarch64 ;; *) arch="" ;; esac; \
    if [ -n "$arch" ]; then \
        curl -fsSL --retry 3 --max-time 120 -o /tmp/speedtest.tgz "https://install.speedtest.net/app/cli/ookla-speedtest-1.2.0-linux-${arch}.tgz" \
        && tar -xzf /tmp/speedtest.tgz -C /tmp speedtest \
        && install -m 0755 /tmp/speedtest /usr/local/bin/ookla-speedtest \
        || echo "Ookla Speedtest CLI not installed: /speed will use the speedtest-cli package"; \
        rm -f /tmp/speedtest.tgz /tmp/speedtest; \
    fi

# Hugging Face Spaces run Docker containers as user 1000
RUN useradd -m -u 1000 user
USER user

ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH \
    PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    PORT=7860 \
    TEMP_DIR=/tmp/rename

WORKDIR /home/user/app

COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY --chown=user bot ./bot

EXPOSE 7860
CMD ["python", "-m", "bot"]