Skip to content

Commit dff7f41

Browse files
Update Dockerfile
1 parent 035b730 commit dff7f41

File tree

1 file changed

+46
-5
lines changed

1 file changed

+46
-5
lines changed

Dockerfile

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,55 @@
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
134
FROM python:3.10-slim
235

336
RUN useradd -m ffapi
37+
438
WORKDIR /home/ffapi/app
539

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
846

9-
COPY requirements.txt ./
10-
RUN pip install --no-cache-dir -r requirements.txt
1147
COPY . .
48+
49+
# Ensure our ffapi user owns everything
50+
RUN chown -R ffapi:ffapi /home/ffapi/app
51+
1252
USER ffapi
1353
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

Comments
 (0)