forked from ShaneIsrael/fireshare
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
executable file
·194 lines (177 loc) · 6.7 KB
/
Copy pathDockerfile
File metadata and controls
executable file
·194 lines (177 loc) · 6.7 KB
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
FROM node:24-slim AS client
WORKDIR /app
ENV PATH=/app/node_modules/.bin:$PATH
COPY app/client/package.json ./
COPY app/client/package-lock.json ./
COPY app/client/.env.* ./
RUN npm ci --silent
COPY app/client/ ./
RUN npm run build
# FFmpeg builder stage with CUDA development tools
FROM nvidia/cuda:11.8.0-devel-ubuntu22.04 AS ffmpeg-builder
WORKDIR /tmp
# Install build dependencies
# Remove stale NVIDIA apt sources (GPG keys rotate) and swap archive.ubuntu.com
# for kernel.org's mirror, which is accessible when Canonical's servers aren't
RUN rm -f /etc/apt/sources.list.d/cuda.list /etc/apt/sources.list.d/nvidia-ml.list \
&& sed -i 's|http://archive.ubuntu.com/ubuntu|http://mirrors.edge.kernel.org/ubuntu|g' /etc/apt/sources.list
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
cmake \
pkg-config \
yasm \
nasm \
git \
wget \
xz-utils \
ca-certificates \
libx264-dev \
libx265-dev \
libvpx-dev \
libaom-dev \
libdav1d-dev \
libopus-dev \
libvorbis-dev \
libass-dev \
libfreetype6-dev \
libmp3lame-dev \
libwebp-dev \
&& rm -rf /var/lib/apt/lists/*
# Build SVT-AV1 from source, V1.8.0 for FFmpeg 6.1
RUN git clone --depth 1 --branch v1.8.0 https://gitlab.com/AOMediaCodec/SVT-AV1.git && \
cd SVT-AV1/Build && \
cmake .. -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release && \
make -j$(nproc) && \
make install
# Install NVIDIA codec headers for NVENC support
RUN git clone --depth 1 --branch n12.1.14.0 https://github.com/FFmpeg/nv-codec-headers.git && \
cd nv-codec-headers && \
make install && \
ldconfig
# Download and extract FFmpeg
RUN wget -q https://ffmpeg.org/releases/ffmpeg-6.1.tar.xz && \
tar -xf ffmpeg-6.1.tar.xz
# Configure FFmpeg with NVENC and all necessary encoders
RUN cd ffmpeg-6.1 && \
./configure \
--prefix=/usr/local \
--enable-gpl \
--enable-version3 \
--enable-nonfree \
--enable-ffnvcodec \
--enable-libx264 \
--enable-libx265 \
--enable-libvpx \
--enable-libaom \
--enable-libdav1d \
--enable-libopus \
--enable-libvorbis \
--enable-libmp3lame \
--enable-libass \
--enable-libfreetype \
--enable-libsvtav1 \
--enable-libwebp \
--disable-debug \
--disable-doc
# Build and install FFmpeg
RUN cd ffmpeg-6.1 && \
make -j$(nproc) && \
make install && \
ldconfig
# Verify FFmpeg was built correctly
RUN ffmpeg -version && \
ffmpeg -hide_banner -encoders 2>/dev/null | grep -E "(nvenc|264|265|vpx|aom|svt)" | head -20
# Python build stage — compiles Python 3.14 from source; works on all architectures
FROM ubuntu:22.04 AS python-source
ARG PYTHON_VERSION=3.14.0
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential wget xz-utils ca-certificates \
libssl-dev libffi-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev \
liblzma-dev uuid-dev \
&& rm -rf /var/lib/apt/lists/*
RUN wget -q https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz && \
tar -xf Python-${PYTHON_VERSION}.tar.xz && \
cd Python-${PYTHON_VERSION} && \
./configure \
--prefix=/opt/python3.14 \
--enable-shared \
--with-ensurepip=install \
LDFLAGS="-Wl,-rpath /opt/python3.14/lib" && \
make -j$(nproc) && \
make altinstall && \
/opt/python3.14/bin/python3.14 -m pip install --upgrade pip && \
rm -f /tmp/Python-${PYTHON_VERSION}.tar.xz
# Main application stage
FROM nvidia/cuda:11.8.0-runtime-ubuntu22.04
WORKDIR /
# Copy FFmpeg from builder
COPY --from=ffmpeg-builder /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg
COPY --from=ffmpeg-builder /usr/local/bin/ffprobe /usr/local/bin/ffprobe
COPY --from=ffmpeg-builder /usr/local/lib/lib* /usr/local/lib/
# Install runtime dependencies
RUN DEBIAN_FRONTEND=noninteractive apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
nginx-extras supervisor \
libldap2-dev libsasl2-dev libssl-dev \
libffi-dev libc-dev \
build-essential \
gosu \
ca-certificates \
tzdata \
libx264-163 libx265-199 libvpx7 libaom3 libdav1d5 \
libopus0 libvorbis0a libvorbisenc2 \
libass9 libfreetype6 libmp3lame0 libwebp7 libwebpmux3 \
libldap-2.5-0 libsasl2-2 \
&& rm -rf /var/lib/apt/lists/*
COPY --from=python-source /opt/python3.14 /opt/python3.14
RUN echo "/opt/python3.14/lib" > /etc/ld.so.conf.d/python3.14.conf && \
ldconfig && \
ln -sf /opt/python3.14/bin/python3.14 /usr/bin/python3.14 && \
ln -sf /opt/python3.14/bin/python3.14 /usr/bin/python3 && \
ln -sf /opt/python3.14/bin/python3.14 /usr/bin/python && \
ln -sf /opt/python3.14/bin/pip3.14 /usr/bin/pip3.14
# Create symlinks and configure library path
RUN ln -sf /usr/local/bin/ffmpeg /usr/bin/ffmpeg && \
ln -sf /usr/local/bin/ffprobe /usr/bin/ffprobe && \
echo "/usr/local/lib" > /etc/ld.so.conf.d/usr-local.conf && \
echo "/usr/local/cuda/lib64" >> /etc/ld.so.conf.d/usr-local.conf && \
echo "/usr/local/nvidia/lib" >> /etc/ld.so.conf.d/nvidia.conf && \
echo "/usr/local/nvidia/lib64" >> /etc/ld.so.conf.d/nvidia.conf && \
ldconfig && \
ffmpeg -version && \
echo "Available encoders:" && \
ffmpeg -hide_banner -encoders 2>/dev/null | grep -E "(nvenc|libaom|libvpx|libx264)" || true
RUN adduser --disabled-password --gecos '' nginx
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log
RUN mkdir /data && mkdir /processed
COPY entrypoint.sh /
COPY app/nginx/prod.conf /etc/nginx/nginx.conf.template
COPY app/nginx/error.html /etc/nginx/error.html
COPY app/nginx/api_unavailable.html /etc/nginx/api_unavailable.html
COPY app/server/ /app/server
COPY migrations/ /migrations
COPY --from=client /app/build /app/build
COPY --from=client /app/package.json /app
RUN python3.14 -m pip install --no-cache-dir --ignore-installed /app/server \
&& apt-get purge -y --auto-remove \
libldap2-dev libsasl2-dev libssl-dev \
libffi-dev libc-dev \
build-essential \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/* /root/.cache/pip /tmp/*
ENV FLASK_APP=/app/server/fireshare:create_app()
ENV ENVIRONMENT=production
ENV DATA_DIRECTORY=/data
ENV VIDEO_DIRECTORY=/videos
ENV IMAGE_DIRECTORY=/images
ENV PROCESSED_DIRECTORY=/processed
ENV TEMPLATE_PATH=/app/server/fireshare/templates
ENV ADMIN_PASSWORD=admin
ENV ANALYTICS_TRACKING_SCRIPT=""
ENV TZ=UTC
ENV LD_LIBRARY_PATH=/usr/local/nvidia/lib:/usr/local/nvidia/lib64:/usr/local/lib:/usr/local/cuda/lib64:$LD_LIBRARY_PATH
ENV PATH=/opt/python3.14/bin:/usr/local/bin:$PATH
EXPOSE 80
CMD ["bash", "/entrypoint.sh"]