File size: 2,544 Bytes
c7cfb9b
 
 
 
 
 
 
 
a343e4e
c7cfb9b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7afcba7
a343e4e
 
 
 
 
 
 
 
c7cfb9b
a343e4e
 
 
 
 
c7cfb9b
 
cae83c3
c7cfb9b
 
 
cae83c3
c7cfb9b
 
 
 
 
 
 
 
7afcba7
c7cfb9b
033facc
c7cfb9b
cae83c3
 
c7cfb9b
 
 
 
2a63a5b
c7cfb9b
7afcba7
c76fcf9
4bdd653
c7cfb9b
7afcba7
 
a343e4e
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
# Base image with CUDA support
FROM nvidia/cuda:11.3.1-base-ubuntu20.04

# Set non-interactive mode for apt
ENV DEBIAN_FRONTEND=noninteractive \
    TZ=Europe/Paris

# Remove any third-party apt sources to avoid issues with expiring keys.
# Install basic utilities and Cloudflared
RUN rm -f /etc/apt/sources.list.d/*.list && \
    apt-get update && apt-get install -y --no-install-recommends \
    curl \
    ca-certificates \
    sudo \
    git \
    wget \
    procps \
    git-lfs \
    zip \
    unzip \
    htop \
    vim \
    nano \
    bzip2 \
    libx11-6 \
    build-essential \
    software-properties-common \
    python3-pip \
 && rm -rf /var/lib/apt/lists/* && \
    # Add Cloudflare GPG key
    mkdir -p --mode=0755 /usr/share/keyrings && \
    curl -fsSL https://pkg.cloudflare.com/cloudflare-main.gpg | tee /usr/share/keyrings/cloudflare-main.gpg >/dev/null && \
    # Add Cloudflare repository
    echo 'deb [signed-by=/usr/share/keyrings/cloudflare-main.gpg] https://pkg.cloudflare.com/cloudflared jammy main' | tee /etc/apt/sources.list.d/cloudflared.list && \
    # Install Cloudflared
    apt-get update && apt-get install -y cloudflared

# Add the Jellyfin repository and install Jellyfin
RUN wget -O - https://repo.jellyfin.org/ubuntu/jellyfin_team.gpg.key | apt-key add - && \
    echo "deb [arch=$( dpkg --print-architecture )] https://repo.jellyfin.org/ubuntu focal main" | tee /etc/apt/sources.list.d/jellyfin.list && \
    apt-get update && \
    apt-get install -y jellyfin

# Create a working directory
WORKDIR /tmp/app

# Create a non-root user and switch to it
RUN adduser --disabled-password --gecos '' --shell /bin/bash user \
 && chown -R user:user /tmp/app
RUN echo "user ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-user
USER user

# All users can use /home/user as their home directory
ENV HOME=/home/user
RUN mkdir $HOME/.cache $HOME/.config \
 && chmod -R 777 $HOME

# Clone the jellyfin-uploader repository and install its requirements
USER root
RUN pip3 install --no-cache-dir gradio

# Copy the current directory contents into the container at /tmp/app, setting the owner to the user
COPY --chown=user . /tmp/app

# Environment variables for Jellyfin
ENV PYTHONUNBUFFERED=1 \
    SYSTEM=spaces \
    SHELL=/bin/bash

# Expose ports for Jellyfin and the Flask server
EXPOSE 8096
EXPOSE 7860

# Start Jellyfin and the Flask server
USER user
CMD ["sh", "-c", "jellyfin -d /home/user/app/jellyfin --webdir /usr/share/jellyfin/web & cd /tmp/app && python3 app.py & cloudflared tunnel --url localhost:7860"]