# -*- Dockerfile -*-
#
# Recipe to build a container image for dash-mpd-cli + helper applications, for Linux/riscv64
#
# 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 (here the "edge"
# distribution, because there is not yet an official distribution for riscv64).
#
# To build the container locally (not needed for an end user)
#
# podman manifest create dash-mpd-cli
# podman build -f etc/Containerfile_linux_riscv64 --platform linux/riscv64 --tag dash-mpd-cli-linux-riscv64 --manifest dash-mpd-cli .
# We make a 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 --platform=linux/riscv64 docker.io/alpine:edge AS builder
WORKDIR /src
COPY ./ ./
RUN apk update && \
apk upgrade && \
apk add --no-cache bash curl bsd-compat-headers linux-headers build-base file git \
musl-dev pkgconfig g++ binutils make cmake zlib-dev zlib-static ninja python3 cargo rust protoc && \
cd /src && cargo update && \
cargo build --release && \
# shaka-packager needs a few tweaks to build from source. We see C compiler errors when building
# with a build type of Release. The official Dockerfile is building with BUILD_TYPE of Debug...
# We work around a C compiler error when building the c-ares third party library, which doesn't
# build due to -Werror=shift-count-overflow errors from -Werr. We need to modify CMakeLists.txt
# to remove the -Werror and add a definition for _LARGEFILE64_SOURCE which is needed while
# compiling the abseil-cpp dependency.
cd /src && git clone --depth 1 --recurse-submodules https://github.com/shaka-project/shaka-packager.git && \
cd shaka-packager && \
sed --in-place 's/^.*add_compile_options.*Werror.*/ add_compile_definitions(_LARGEFILE64_SOURCE)/' packager/CMakeLists.txt && \
cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_POLICY_VERSION_MINIMUM=4.0 && \
cmake --build build/ && \
ls -l build/packager && \
file build/packager/packager && \
cd /src && git clone --depth 1 https://github.com/gpac/gpac.git && \
cd gpac && ./configure --static-bin && \
make -j 4 && \
ls -l bin/gcc/ && \
file bin/gcc/MP4Box
# Now build the final image
FROM --platform=linux/riscv64 docker.io/alpine:edge
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
# - mkvmerge (from mkvtoolnix): GNU GPL v2 -- not packaged in this container
# - vlc: GNU GPL v2, not installed because it inflates image size considerably
# - mp4decrypt (from bento4): GNU GPL v2
# - xsltproc (from libxslt): MIT
# - Shaka packager: MIT
#
# Note that as of 2024-06, mkvtoolnix is not packaged in alpine:edge/riscv64.
RUN apk update && \
apk upgrade && \
apk add --no-cache ca-certificates libc6-compat wget ffmpeg bento4 libxslt && \
update-ca-certificates && \
mkdir /content && \
chown root:root /content && \
chmod a=rwx,o+t /content
COPY --from=builder --chown=root:root --chmod=755 \
/src/target/release/dash-mpd-cli /usr/local/bin
COPY --from=builder --chown=root:root --chmod=755 \
/src/gpac/bin/gcc/MP4Box /usr/local/bin
COPY --from=builder --chown=root:root --chmod=755 \
/src/shaka-packager/build/packager/packager /usr/local/bin/shaka-packager
WORKDIR /content
ENV TERM=xterm-256color
ENTRYPOINT ["/usr/local/bin/dash-mpd-cli"]
# Size of our container image:
# with vlc: 331 MB
# without vlc nor mkvtoolnix: 245 MB (riscv64)