# -*- Dockerfile -*-
#
# Recipe to build a container image for dash-mpd-cli + help applications, for Linux/AMD64.
#
# This Containerfile contains the recipe needed to generate a docker/podman/OCI container image
# including the dash-mpd-cli binary alongside the external helper applications that it uses for
# muxing media streams, for extracting/converting subtitle streams, and for decrypting content
# infected with DRM. These are packaged with a minimal Alpine Linux installation so that they can be
# run on any host that can run Linux/AMD64 containers (using Podman or Docker on Linux, Microsoft
# Windows and MacOS).
#
# To build the container locally (not needed for an end user) on an AMD64 host:
#
# podman manifest create dash-mpd-cli
# podman build -f etc/Containerfile_linux_amd64 --arch amd64 --tag dash-mpd-cli-linux-amd64 --manifest dash-mpd-cli .
FROM docker.io/rust:latest AS rustbuilder
RUN apt-get update && apt-get install -y musl-tools musl-dev protobuf-compiler cmake && \
rustup target add x86_64-unknown-linux-musl && \
update-ca-certificates
WORKDIR /src
COPY ../ ./
RUN cargo update && \
RUSTFLAGS="-C target-cpu=x86-64-v3" cargo build --target x86_64-unknown-linux-musl --release --features sandbox
# static build of MP4Box from GPAC, which is not packaged for Alpine Linux.
# https://github.com/gpac/gpac/wiki/GPAC-Build-Guide-for-Linux
FROM alpine:latest AS gpacbuilder
WORKDIR /src
RUN apk update && \
apk upgrade && \
apk add --no-cache musl-dev pkgconfig git g++ binutils make zlib-dev zlib-static && \
git clone --depth 1 https://github.com/gpac/gpac.git && \
cd gpac && ./configure --static-bin && \
make -j 3 && \
ls -l bin/gcc/
# here there should be MP4Box
# Now build the final image
FROM alpine:latest
LABEL org.opencontainers.image.description "Download media content from a DASH-MPEG or DASH-WebM MPD manifest."
LABEL org.opencontainers.image.title "dash-mpd-cli"
LABEL org.opencontainers.image.url "https://github.com/emarsden/dash-mpd-cli"
LABEL org.opencontainers.image.source "https://github.com/emarsden/dash-mpd-cli"
LABEL org.opencontainers.image.version "0.2.32"
LABEL org.opencontainers.image.authors "eric.marsden@risk-engineering.org"
LABEL org.opencontainers.image.licenses "MIT"
# Install our external dependencies. Licences for the external dependencies:
# - ffmpeg: GNU GPL v2
# - mkvtoolnix: GNU GPL v2
# - vlc: GNU GPL v2, not installed because it inflates image size considerably
# - mp4decrypt (bento4): GNU GPL v2
# - xsltproc: MIT
# - Shaka packager: MIT
RUN apk update && \
apk upgrade && \
apk add --no-cache ca-certificates ffmpeg mkvtoolnix bento4 libxslt && \
update-ca-certificates && \
mkdir /content && \
chown root:root /content && \
chmod a=rwx,o+t /content
COPY --from=docker.io/google/shaka-packager:latest --chown=root:root \
/usr/bin/packager /usr/local/bin/shaka-packager
COPY --from=rustbuilder --chown=root:root --chmod=755 \
/src/target/x86_64-unknown-linux-musl/release/dash-mpd-cli /usr/local/bin
COPY --from=gpacbuilder --chown=root:root --chmod=755 \
/src/gpac/bin/gcc/MP4Box /usr/local/bin
WORKDIR /content
ENV TERM=xterm-256color
ENTRYPOINT ["/usr/local/bin/dash-mpd-cli"]
# Size of our container image (for Linux/AMD64):
# with vlc: 331 MB
# without vlc: 217 MB
# static ffmpeg + shaka-packager from docker: 299 MB
# shaka-packager from docker: 216 MB