-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
207 lines (185 loc) · 6.34 KB
/
Copy pathDockerfile
File metadata and controls
207 lines (185 loc) · 6.34 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# syntax=docker/dockerfile:1
# check=error=true
# We have to ignore some dockerfile-utils errors, because `--unpack` is currently unsupported for the `ADD` instruction
# - https://github.com/microsoft/vscode-containers/issues/297
# - https://github.com/rcjsuen/dockerfile-utils/issues/131
#
# When updating tarball versions, update the checksums as well:
# - curl -fsSL TARBALL_URL | sha256sum
FROM --platform=$BUILDPLATFORM tonistiigi/xx AS xx
FROM --platform=$BUILDPLATFORM alpine:3.24 AS builder
LABEL org.opencontainers.image.title="Oktomusic Custom FFmpeg"
LABEL org.opencontainers.image.description="Custom build of FFmpeg for Oktomusic project"
LABEL org.opencontainers.image.authors="AFCMS <afcm.contact@gmail.com>"
LABEL org.opencontainers.image.licenses="LGPL-2.1-only"
LABEL org.opencontainers.image.source="https://github.com/oktomusic/ffmpeg-custom"
LABEL io.artifacthub.package.readme-url="https://raw.githubusercontent.com/oktomusic/ffmpeg-custom/refs/heads/master/README.md"
LABEL io.artifacthub.package.category="skip-prediction"
LABEL io.artifacthub.package.keywords="music,media,tool"
LABEL io.artifacthub.package.license="LGPL-2.1-only"
LABEL io.artifacthub.package.maintainers='[{"name":"AFCMS","email":"afcm.contact@gmail.com"}]'
COPY --from=xx / /
# ---------------------------
# Install build dependencies
# ---------------------------
RUN apk add --no-cache \
clang \
lld \
llvm \
llvm-dev \
build-base \
pkgconfig \
yasm \
nasm \
bash \
autoconf \
automake \
libtool
ARG TARGETPLATFORM
RUN xx-info env
RUN xx-apk add --no-cache \
musl-dev \
gcc \
g++ \
zlib-dev
WORKDIR /usr/local/src
# ---------------------------
# Build libogg from official tarball
# ---------------------------
ENV OGG_VERSION=1.3.6
ENV OGG_CHECKSUM=sha256:83e6704730683d004d20e21b8f7f55dcb3383cdf84c0daedf30bde175f774638
# dockerfile-utils: ignore
ADD --unpack=true \
--checksum=${OGG_CHECKSUM} \
https://github.com/xiph/ogg/releases/download/v${OGG_VERSION}/libogg-${OGG_VERSION}.tar.gz \
/usr/local/src/
WORKDIR /usr/local/src/libogg-${OGG_VERSION}
RUN CC=xx-clang ./configure \
--host=$(xx-clang --print-target-triple) \
--disable-shared \
--enable-static \
--prefix=$(xx-info sysroot)usr/local \
&& make -j$(nproc) \
&& make install
# ---------------------------
# Build Opus statically from official tarball
# ---------------------------
ENV OPUS_VERSION=1.5.2
ENV OPUS_CHECKSUM=sha256:65c1d2f78b9f2fb20082c38cbe47c951ad5839345876e46941612ee87f9a7ce1
# dockerfile-utils: ignore
ADD --unpack=true \
--checksum=${OPUS_CHECKSUM} \
https://github.com/xiph/opus/releases/download/v${OPUS_VERSION}/opus-${OPUS_VERSION}.tar.gz \
/usr/local/src/
WORKDIR /usr/local/src/opus-${OPUS_VERSION}
RUN CC=xx-clang ./configure \
--host=$(xx-clang --print-target-triple) \
--disable-shared \
--enable-static \
--prefix=$(xx-info sysroot)usr/local \
&& make -j$(nproc) \
&& make install
# ---------------------------
# Build FLAC statically from official tarball
# ---------------------------
WORKDIR /usr/local/src
ENV FLAC_VERSION=1.5.0
ENV FLAC_CHECKSUM=sha256:f2c1c76592a82ffff8413ba3c4a1299b6c7ab06c734dee03fd88630485c2b920
# dockerfile-utils: ignore
ADD --unpack=true \
--checksum=${FLAC_CHECKSUM} \
https://github.com/xiph/flac/releases/download/${FLAC_VERSION}/flac-${FLAC_VERSION}.tar.xz \
/usr/local/src/
WORKDIR /usr/local/src/flac-${FLAC_VERSION}
RUN CC=xx-clang ./configure \
--host=$(xx-clang --print-target-triple) \
--disable-shared \
--enable-static \
--prefix=$(xx-info sysroot)usr/local \
LDFLAGS="-static" \
&& make -j$(nproc) AM_LDFLAGS="-all-static" \
&& make install \
&& cp src/metaflac/metaflac /usr/local/bin/metaflac
# ---------------------------
# Build FFmpeg statically with Opus and FLAC support
# ---------------------------
WORKDIR /usr/local/src
ENV FFMPEG_VERSION=9.0.2
ENV FFMPEG_CHECKSUM=sha256:8c3850283eb25fa026482078a04051e0be17347b09ef81a0849bec15a96e002e
# dockerfile-utils: ignore
ADD --unpack=true \
--checksum=${FFMPEG_CHECKSUM} \
https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.xz \
/usr/local/src/
# Configure FFmpeg static build
WORKDIR /usr/local/src/ffmpeg-${FFMPEG_VERSION}
RUN xx-clang --setup-target-triple && \
export PKG_CONFIG_PATH=$(xx-info sysroot)usr/local/lib/pkgconfig && \
export PKG_CONFIG_LIBDIR=$(xx-info sysroot)usr/local/lib/pkgconfig && \
./configure \
--prefix=/usr/local \
--extra-version=oktomusic \
--enable-cross-compile \
--cross-prefix=$(xx-clang --print-target-triple)- \
--arch=$(xx-info arch) \
--target-os=linux \
--cc=xx-clang \
--cxx=xx-clang++ \
--ar=llvm-ar \
--ranlib=llvm-ranlib \
--nm=llvm-nm \
--strip=llvm-strip \
--pkg-config-flags="--static" \
--extra-cflags="-static" \
--extra-ldflags="-static" \
--disable-everything \
# Build configuration
--disable-shared \
--enable-static \
--disable-doc \
--disable-debug \
# Tools
--disable-ffplay \
--enable-ffprobe \
# External libraries
--enable-libopus \
# Codecs (encoders/decoders)
--enable-encoder=flac \
--enable-decoder=flac \
--enable-encoder=libopus \
--enable-decoder=libopus \
--enable-decoder=mjpeg \
--enable-decoder=png \
# Formats (muxers/demuxers)
--enable-muxer=flac \
--enable-demuxer=flac \
--enable-muxer=opus \
--enable-demuxer=opus \
--enable-muxer=image2 \
# Filters
--enable-filter=aresample \
--enable-filter=aformat \
--enable-filter=anull \
# Protocols
--enable-protocol=file \
# Subsystems/features
--disable-avdevice \
--disable-network \
--disable-bsfs \
--disable-iconv \
--disable-vaapi \
--disable-vdpau \
--enable-swresample \
--disable-swscale
RUN make -j$(nproc) && make install && make clean
RUN xx-verify --static /usr/local/bin/ffmpeg
RUN xx-verify --static /usr/local/bin/ffprobe
RUN xx-verify --static /usr/local/bin/metaflac
# ---------------------------
# Create minimal runtime image
# ---------------------------
FROM scratch AS runtime
COPY --from=builder /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg
COPY --from=builder /usr/local/bin/ffprobe /usr/local/bin/ffprobe
COPY --from=builder /usr/local/bin/metaflac /usr/local/bin/metaflac
ENTRYPOINT ["/usr/local/bin/ffmpeg"]