File size: 2,780 Bytes
5afa8d3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6cbb1a3
 
5afa8d3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM ubuntu:22.04

# Build args (change if upstream playit repo changes)
ARG PLAYIT_GPG_URL="https://playit-cloud.github.io/ppa/key.gpg"
ARG PLAYIT_APT_LINE="deb [signed-by=/etc/apt/trusted.gpg.d/playit.gpg] https://playit-cloud.github.io/ppa/data ./"


ENV DEBIAN_FRONTEND=noninteractive \
    TZ=Etc/UTC \
    LANG=C.UTF-8

USER root
# Install dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    libpcre3 libpcre3-dev \
    libssl-dev \
    zlib1g-dev \
    wget \
    nginx \
    ffmpeg \
    git \
    build-essential \
    libpcre3 libpcre3-dev \
    libssl-dev \
    wget \
    curl \
    unzip \
    openssl \
    apt-transport-https \
    ca-certificates \
    gnupg \
    dirmngr \
    tzdata \
    gettext-base \
    ; \
    # ensure tzdata doesn't prompt (already set TZ env); configure timezone non-interactively
    ln -fs /usr/share/zoneinfo/$TZ /etc/localtime; \
    dpkg-reconfigure --frontend noninteractive tzdata || true; \
    # prepare apt trusted key location
    mkdir -p /etc/apt/trusted.gpg.d; \
    # fetch playit GPG key and dearmor it for apt
    curl -fsSL "${PLAYIT_GPG_URL}" -o /tmp/playit.key.gpg; \
    gpg --dearmor --batch --yes -o /etc/apt/trusted.gpg.d/playit.gpg /tmp/playit.key.gpg; \
    rm -f /tmp/playit.key.gpg; \
    # add apt source list
    echo "${PLAYIT_APT_LINE}" > /etc/apt/sources.list.d/playit-cloud.list; \
    apt-get update; \
    # Install playit, telling dpkg to accept default config answers if asked
    apt-get install -y --no-install-recommends -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" playit; \
    # cleanup apt caches
    apt-get clean; \
    rm -rf /var/lib/apt/lists/* /tmp/*



# Install Nginx with RTMP module
RUN mkdir -p /opt/nginx && \
    cd /opt/nginx && \
    git clone https://github.com/arut/nginx-rtmp-module.git && \
    wget http://nginx.org/download/nginx-1.25.0.tar.gz && \
    tar -zxvf nginx-1.25.0.tar.gz && \
    cd nginx-1.25.0 && \
    ./configure --with-http_ssl_module --add-module=../nginx-rtmp-module && \
    make && make install

RUN mkdir -p /tmp/nginx /tmp/nginx/logs  /tmp/nginx/proxy_temp /tmp/nginx/html /tmp/nginx/html/media/hls /tmp/nginx/html/media/rhls /tmp/nginx/html/media/recordings \
 && chmod -R 777 /tmp/nginx /tmp/nginx/html /usr/local/nginx/sbin/nginx
RUN chmod -R 755 /tmp/nginx/html/media
# Copy configs and web UI
COPY nginx.conf /tmp/nginx/nginx.conf
COPY www/ /tmp/nginx/html/
COPY mime.types /tmp/nginx/mime.types

# Copy entrypoint
COPY init.sh /tmp/nginx/entrypoint.sh
RUN chmod +x /tmp/nginx/entrypoint.sh
RUN chmod +x /tmp/nginx/logs


# Expose only HF Spaces allowed port
EXPOSE 7860/tcp

# Workdir
WORKDIR /tmp/app
USER root
ENTRYPOINT ["/tmp/nginx/entrypoint.sh"]
CMD []