Skip to content

Commit 3a32eb4

Browse files
Update Dockerfile
1 parent 630ad03 commit 3a32eb4

File tree

1 file changed

+38
-24
lines changed

1 file changed

+38
-24
lines changed

Dockerfile

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,66 @@
1-
# Dockerfile
1+
# Use Docker BuildKit syntax v1.3+ for multi‐arch args
2+
# syntax=docker/dockerfile:1.3
3+
4+
########################################
5+
# 1. Builder stage: install deps & FFmpeg
6+
########################################
27
FROM python:3.10-slim AS builder
38

4-
# Install deps for ffmpeg extraction
9+
# Declare the build platform variable
10+
ARG TARGETPLATFORM
11+
12+
# Install tools for download & extraction
513
RUN apt-get update \
6-
&& apt-get install -y --no-install-recommends \
7-
curl xz-utils \
8-
&& rm -rf /var/lib/apt/lists/*
14+
&& apt-get install -y --no-install-recommends \
15+
curl xz-utils ca-certificates \
16+
&& rm -rf /var/lib/apt/lists/*
917

10-
# Pick up code
1118
WORKDIR /home/ffapi/app
12-
COPY requirements.txt ./
13-
RUN pip install --no-cache-dir -r requirements.txt
19+
20+
# Python deps
21+
COPY requirements.txt .
22+
RUN python -m pip install --upgrade pip \
23+
&& pip install --no-cache-dir -r requirements.txt
1424

1525
COPY . .
1626

17-
# Download BtbN static FFmpeg build per architecture
18-
# BuildKit will set TARGETPLATFORM, so we can choose the correct binary
27+
# Download & extract correct FFmpeg build
1928
RUN set -eux; \
2029
case "${TARGETPLATFORM}" in \
2130
"linux/amd64") ARCH="amd64" ;; \
2231
"linux/arm64") ARCH="arm64" ;; \
2332
*) echo "Unsupported platform ${TARGETPLATFORM}" >&2; exit 1 ;; \
2433
esac; \
25-
FFBIN="ffmpeg-git-${ARCH}-static.tar.xz"; \
26-
echo "Downloading ${FFBIN}"; \
27-
curl -L \
28-
"https://github.com/BtbN/FFmpeg-Builds/releases/latest/download/${FFBIN}" \
29-
-o /tmp/${FFBIN}; \
30-
tar -xJf /tmp/${FFBIN} -C /usr/local/bin --strip-components=1; \
31-
rm /tmp/${FFBIN}
32-
33-
# Runtime image
34+
URL="https://github.com/BtbN/FFmpeg-Builds/releases/latest/download/ffmpeg-git-${ARCH}-static.tar.xz"; \
35+
echo "Downloading FFmpeg from ${URL}"; \
36+
curl -fL "${URL}" -o /tmp/ffmpeg.tar.xz; \
37+
mkdir -p /tmp/ffmpeg; \
38+
tar -xJf /tmp/ffmpeg.tar.xz -C /tmp/ffmpeg --strip-components=1; \
39+
install -m755 /tmp/ffmpeg/ffmpeg /usr/local/bin/ffmpeg; \
40+
install -m755 /tmp/ffmpeg/ffprobe /usr/local/bin/ffprobe; \
41+
install -m755 /tmp/ffmpeg/ffplay /usr/local/bin/ffplay; \
42+
rm -rf /tmp/ffmpeg /tmp/ffmpeg.tar.xz
43+
44+
########################################
45+
# 2. Runtime stage
46+
########################################
3447
FROM python:3.10-slim
3548

3649
RUN useradd -m ffapi
3750

3851
WORKDIR /home/ffapi/app
3952

40-
# copy ffmpeg binaries + Python deps + app code
41-
COPY --from=builder /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg
53+
# Copy over static FFmpeg binaries
54+
COPY --from=builder /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg
4255
COPY --from=builder /usr/local/bin/ffprobe /usr/local/bin/ffprobe
43-
COPY --from=builder /usr/local/bin/ffplay /usr/local/bin/ffplay
44-
# (VMAF binary if needed—you can optionally download it similarly)
56+
COPY --from=builder /usr/local/bin/ffplay /usr/local/bin/ffplay
57+
58+
# Copy Python packages
4559
COPY --from=builder /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
4660

61+
# Copy application code
4762
COPY . .
4863

49-
# Ensure our ffapi user owns everything
5064
RUN chown -R ffapi:ffapi /home/ffapi/app
5165

5266
USER ffapi

0 commit comments

Comments
 (0)