-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathDockerfile.linux
More file actions
54 lines (40 loc) · 2.57 KB
/
Dockerfile.linux
File metadata and controls
54 lines (40 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# syntax=docker/dockerfile:1.7
#
# Copyright(C) 2019-2026, The Homebridge Team. All rights reserved.
#
# Dockerfile.linux: create a cross-compilation environment to build FFmpeg statically for multiple CPU architectures, using QEMU emulation only when needed.
# Define the base image that will be used for the build environment.
ARG BASE_IMAGE=alpine:3.20
# Define the platform where the Docker build is running.
ARG BUILDPLATFORM=linux/amd64
# Define the target platform for the container. This gets reconciled against BUILDPLATFORM to determine if we're cross-compiling or not. If we are, we use QEMU.
ARG TARGETPLATFORM=linux/amd64
# Pass through our command-line arguments to the next stage.
ARG TARGETARCH
# First, we extract the QEMU static binary for the target architecture. We use the multiarch/qemu-user-static image which contains statically compiled QEMU binaries for
# various architectures.
FROM --platform=${BUILDPLATFORM} multiarch/qemu-user-static:latest AS qemu
# Next, we set up the main build environment. We start from the specified base image and configure it for cross-compilation.
FROM --platform=${TARGETPLATFORM} ${BASE_IMAGE}
# Pass through our command-line arguments.
ARG BUILDPLATFORM
ARG TARGETPLATFORM
ARG TARGETARCH
# Copy the QEMU static binary from the first stage into our build environment. This binary enables transparent emulation of the target architecture, allowing us to run
# binaries compiled for different architectures as if they were native, when needed.
COPY --from=qemu /usr/bin/qemu-*-static /usr/bin/
# If we're building on the same architecture as our target, we remove QEMU so we can run natively.
RUN if [ "${TARGETPLATFORM}" = "${BUILDPLATFORM}" ]; then rm -f /usr/bin/qemu-*-static; fi
# Install our dependencies ahead of building our FFmpeg release.
RUN apk add --no-cache autoconf automake bash cmake curl diffutils g++ gcc gettext-static giflib-static git lame-dev libogg-static libpng-dev libpng-static \
libtheora-dev libtheora-static libtool libvorbis-dev libvorbis-static libwebp-dev libwebp-static linux-headers m4 make meson nasm opencore-amr-dev openssl-dev \
openssl-libs-static pcre-dev perl python3 samurai tar xvidcore-dev xvidcore-static xz yasm zlib-static
# Copy over our FFmpeg build script.
COPY build-ffmpeg /build-ffmpeg
RUN chmod +x /build-ffmpeg
# Define a volume mount point at /build that we can copy our binary from later.
VOLUME /build
# Set our working directory to /build where all the magic happens.
WORKDIR /build
# Our build command for FFmpeg.
CMD ["/build-ffmpeg", "--build", "--enable-gpl-and-non-free", "--full-static"]