Here’s what I eventually settled on, in case someone with as little knowledge as me is trying something similar.
I create a Dockerfile that sets environment variables and directory paths, installs dependencies needed for the ffmpeg build (and tzdata for time zone setting), creates directories, sets a handy alias for bash root, and sets time zone. PUID and PGID are set to my user ID.
Then simple YAML code is used to start the container. It sets an important link between an internal container path and external host path for persistent storage. That storage is used for the Dockerfile, local git repositories and other packages that need to be compiled before ffmpeg, and the ffmpeg build script. This volumes
step cannot be done in the Dockerfile.
Then the location of the Dockerfile is specified, network mode set, and needed commands executed, including the ffmpeg build script. I tried using the command
directive for the commands, but the order of execution changes, and the commands attempt to execute before the volumes
directive. That doesn’t work in this case.
The ffmpeg build script (not shown) logs all output to a file in external storage, so I can see what goes wrong, if anything, and tweak the script as needed. At the end it copies the final binaries to the external storage so they can be used from anywhere.
Dockerfile:
FROM debian:latest
# Set environment variables and directory paths
ENV PAKS=/ffstor/ffmpeg/packages \
BUILD=/ffmpeg/build \
TARGET=/ffmpeg/target \
PATH=$PATH:/ffmpeg/target/bin \
TZ="America/Los_Angeles" \
PUID=1001 \
PGID=1001
# Install build dependencies, create directories, set alias, and set time zone
# Third apt is build dependencies for fontconfig
RUN apt update && \
apt --yes install curl git build-essential pkg-config yasm nasm cmake autoconf libtool libfribidi-dev rsync nano wget tzdata && \
apt --yes install gperf libfreetype-dev libxml2-dev python-is-python3 && \
mkdir -p ${BUILD} ${TARGET} && \
echo "alias ll='ls -lahp'" >> /root/.bashrc && \
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
echo $TZ > /etc/timezone
YAML code:
services:
debian-container:
volumes:
- /mnt/Ark/Media/FFstor:/ffstor
build:
context: /mnt/Ark/Media/FFstor/ffmpeg # location of 'Dockerfile' on host
network_mode: host
entrypoint: ["/bin/bash", "-c", "chmod u+s /ffstor && /ffstor/ffmpeg/buildffmpeg.sh && sleep infinity"]