|
| 1 | +# Dockerfile |
| 2 | +FROM python:3.10-slim AS builder |
| 3 | + |
| 4 | +# Install deps for ffmpeg extraction |
| 5 | +RUN apt-get update \ |
| 6 | + && apt-get install -y --no-install-recommends \ |
| 7 | + curl xz-utils \ |
| 8 | + && rm -rf /var/lib/apt/lists/* |
| 9 | + |
| 10 | +# Pick up code |
| 11 | +WORKDIR /home/ffapi/app |
| 12 | +COPY requirements.txt ./ |
| 13 | +RUN pip install --no-cache-dir -r requirements.txt |
| 14 | + |
| 15 | +COPY . . |
| 16 | + |
| 17 | +# Download BtbN static FFmpeg build per architecture |
| 18 | +# BuildKit will set TARGETPLATFORM, so we can choose the correct binary |
| 19 | +RUN set -eux; \ |
| 20 | + case "${TARGETPLATFORM}" in \ |
| 21 | + "linux/amd64") ARCH="amd64" ;; \ |
| 22 | + "linux/arm64") ARCH="arm64" ;; \ |
| 23 | + *) echo "Unsupported platform ${TARGETPLATFORM}" >&2; exit 1 ;; \ |
| 24 | + 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 |
1 | 34 | FROM python:3.10-slim
|
2 | 35 |
|
3 | 36 | RUN useradd -m ffapi
|
| 37 | + |
4 | 38 | WORKDIR /home/ffapi/app
|
5 | 39 |
|
6 |
| -RUN apt-get update && apt-get install -y --no-install-recommends \ |
7 |
| - ssh gcc libsm6 libxext6 libxrender1 && rm -rf /var/lib/apt/lists/* |
| 40 | +# copy ffmpeg binaries + Python deps + app code |
| 41 | +COPY --from=builder /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg |
| 42 | +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) |
| 45 | +COPY --from=builder /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages |
8 | 46 |
|
9 |
| -COPY requirements.txt ./ |
10 |
| -RUN pip install --no-cache-dir -r requirements.txt |
11 | 47 | COPY . .
|
| 48 | + |
| 49 | +# Ensure our ffapi user owns everything |
| 50 | +RUN chown -R ffapi:ffapi /home/ffapi/app |
| 51 | + |
12 | 52 | USER ffapi
|
13 | 53 | EXPOSE 8000
|
14 |
| -CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"] |
| 54 | + |
| 55 | +ENTRYPOINT ["uvicorn","app.main:app","--host","0.0.0.0","--port","8000"] |
0 commit comments