-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathDockerfile
150 lines (125 loc) · 5.47 KB
/
Dockerfile
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
FROM python:3.13-slim AS base
ARG BUILD_TYPE
ARG TARGETARCH
ARG COMSKIP_BRANCH=master
ARG JELLYFIN_FFMPEG_BRANCH=jellyfin-6.0
# http://stackoverflow.com/questions/48162574/ddg#49462622
ENV APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn
# https://askubuntu.com/questions/972516/debian-frontend-environment-variable
ENV DEBIAN_FRONTEND="noninteractive"
ENV PIP_CACHE_DIR=/root/.cache/pip
ENV RUFF_CACHE_DIR=/root/.cache/ruff
ENV UV_CACHE_DIR=/root/.cache/uv
RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \
apt-get update \
&& apt-get install --no-install-recommends --no-install-suggests -y \
build-essential \
git \
htop \
less \
locales \
net-tools \
netcat-openbsd \
procps \
wget \
&& sed -i -e 's/# es_ES.UTF-8 UTF-8/es_ES.UTF-8 UTF-8/' /etc/locale.gen \
&& locale-gen
WORKDIR /tmp
COPY requirements.txt .
RUN --mount=type=cache,target=/root/.cache \
pip install --disable-pip-version-check --root-user-action ignore --use-pep517 uv \
&& uv pip install --link-mode=copy --system -r requirements.txt
ENV ffmpeg_CFLAGS="-I/usr/lib/jellyfin-ffmpeg/include"
ENV ffmpeg_LIBS="-L/usr/lib/jellyfin-ffmpeg/lib -lavcodec -lavformat -lavutil -lswscale"
COPY patches/comskip.patch .
RUN --mount=type=cache,sharing=locked,target=/var/cache/apt \
if [ "$BUILD_TYPE" = "full" ]; then \
APT_SRC=/etc/apt/sources.list.d/jellyfin.sources \
&& echo "Types: deb" > ${APT_SRC} \
&& echo "URIs: https://repo.jellyfin.org/debian" >> ${APT_SRC} \
&& echo "Suites: $( awk -F'=' '/^VERSION_CODENAME=/{ print $NF }' /etc/os-release )" >> ${APT_SRC} \
&& echo "Components: main" >> ${APT_SRC} \
&& echo "Architectures: $( dpkg --print-architecture )" >> ${APT_SRC} \
&& echo "Signed-By: /etc/apt/keyrings/jellyfin.gpg" >> ${APT_SRC} \
&& apt-get install --no-install-recommends --no-install-suggests -y gnupg \
&& wget -O- https://repo.jellyfin.org/jellyfin_team.gpg.key | gpg --dearmor --yes --output /etc/apt/keyrings/jellyfin.gpg \
&& apt-get update \
&& apt-get install --no-install-recommends --no-install-suggests -y \
jellyfin-ffmpeg6 \
&& apt-get purge -y gnupg \
&& apt-get install --no-install-recommends --no-install-suggests -y \
autoconf \
automake \
libargtable2-dev \
libtool \
pkg-config \
&& git clone -b ${JELLYFIN_FFMPEG_BRANCH} https://github.com/jellyfin/jellyfin-ffmpeg \
&& cd jellyfin-ffmpeg \
&& ./configure --prefix=/usr/lib/jellyfin-ffmpeg --disable-x86asm \
&& make -j$(nproc) install-headers \
&& cd .. \
&& rm -fr jellyfin-ffmpeg \
&& git clone -b ${COMSKIP_BRANCH} https://github.com/erikkaashoek/Comskip \
&& cd Comskip \
&& patch -p1 < ../comskip.patch \
&& ./autogen.sh \
&& ./configure \
&& make -j$(nproc) \
&& make -j$(nproc) install \
&& cd .. \
&& rm -f comskip.patch \
&& rm -fr Comskip \
&& rm -fr /usr/lib/jellyfin-ffmpeg/include \
&& apt-get purge -y \
autoconf \
automake \
libargtable2-dev \
libtool \
pkg-config \
&& apt-get install --no-install-recommends --no-install-suggests -y libargtable2.0 \
&& ln -s /usr/lib/jellyfin-ffmpeg/ff* /usr/local/bin/ \
&& ln -s /usr/lib/jellyfin-ffmpeg/lib/libavcodec.so.* /usr/local/lib/ \
&& ln -s /usr/lib/jellyfin-ffmpeg/lib/libavformat.so.* /usr/local/lib/ \
&& ln -s /usr/lib/jellyfin-ffmpeg/lib/libavutil.so.* /usr/local/lib/ \
&& ln -s /usr/lib/jellyfin-ffmpeg/lib/libswscale.so.* /usr/local/lib/; \
fi
RUN apt-get purge -y binutils-common build-essential dpkg-dev git git-man gpg-agent libcurl3-gnutls \
liberror-perl libgdbm-compat4 libldap-2.5-0 libnghttp2-14 libperl5.36 librtmp1 libsasl2-2 \
libsasl2-modules-db libssh2-1 patch perl perl-modules-5.36 pkgconf \
&& apt-get clean autoclean -y \
&& apt-get autoremove -y
WORKDIR /app
COPY . .
RUN --mount=type=cache,target=/root/.cache \
if [ "${BUILD_TYPE}" = "full" ] && [ "$TARGETARCH" = "amd64" ]; then \
uv pip install --link-mode=copy --system bandit pycodestyle pylint ruff 2>&1 | tee /tmp/lint-install.txt \
&& bandit -v *.py \
&& pycodestyle -v *.py \
&& pylint --rcfile pyproject.toml -v *.py \
&& ruff check --config pyproject.toml -v *.py \
&& ruff check --config pyproject.toml --diff --no-fix-only -v *.py \
&& ruff format --config pyproject.toml --diff -v *.py \
&& uv pip uninstall --system $( awk '/==/ { print $2 }' /tmp/lint-install.txt ); \
fi
RUN --mount=type=cache,target=/root/.cache \
pip uninstall --disable-pip-version-check --root-user-action ignore -y uv wheel
RUN rm -fr \
Dockerfile patches pyproject.toml requirements*.txt tox.ini \
/tmp/* /usr/local/.lock /var/cache/* /var/lib/apt/lists/* *.conf
RUN chown nobody:nogroup /home && chmod g+s /home
######################
# Squash final image #
######################
FROM scratch
COPY --from=base / /
# https://github.com/NVIDIA/nvidia-docker/wiki/Installation-(Native-GPU-Support)
ENV NVIDIA_DRIVER_CAPABILITIES="compute,utility,video"
ENV LC_ALL=es_ES.UTF-8
ENV LANG=es_ES.UTF-8
ENV LANGUAGE=es_ES:UTF-8
ENV HOME=/home
ENV PATH=/home/.local/bin:/usr/local/bin:/usr/sbin:/usr/bin
ENV PYTHONPATH=/app
ENV TMP=/tmp
WORKDIR /home
CMD ["/app/mu7d.py"]