-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathDockerfile
237 lines (180 loc) · 4.44 KB
/
Dockerfile
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# syntax = docker/dockerfile:1.5
ARG FFMPEG_VERSION="7.0.2"
FROM akashisn/ffmpeg:${FFMPEG_VERSION} AS ffmpeg-linux-image
FROM ghcr.io/akashisn/ffmpeg-windows:${FFMPEG_VERSION} AS ffmpeg-windows-image
#
# build env base image
#
FROM ubuntu:22.04 AS build-env
SHELL ["/bin/bash", "-e", "-c"]
ENV DEBIAN_FRONTEND=noninteractive
# Install ca-certificates
RUN <<EOT
apt-get update
apt-get install -y ca-certificates
rm -rf /var/lib/apt/lists/*
EOT
# Install build tools
RUN <<EOT
sed -i -r 's@http://(jp.)?archive.ubuntu.com/ubuntu/@https://ftp.udx.icscoe.jp/Linux/ubuntu/@g' /etc/apt/sources.list
apt-get update
apt-get install -y \
autopoint \
bc \
build-essential \
clang \
cmake \
curl \
gettext \
git \
git-lfs \
gperf \
libtool \
lzip \
make \
meson \
mingw-w64 \
mingw-w64-tools \
nasm \
p7zip \
pkg-config \
python3 \
ragel \
subversion \
wget \
xxd \
yasm
EOT
# Clone Implib.so
RUN <<EOT
git clone --filter=blob:none --depth=1 https://github.com/yugr/Implib.so /opt/implib
EOT
# Environment
ARG FFMPEG_VERSION
ENV FFMPEG_VERSION="${FFMPEG_VERSION}" \
PREFIX="/usr/local" \
ARTIFACT_DIR="/dist" \
RUNTIME_LIB_DIR="/runtime" \
WORKDIR="/workdir"
WORKDIR ${WORKDIR}
# Copy build script
ADD ./scripts/base.sh ./
#
# ffmpeg library build stage
#
FROM build-env AS ffmpeg-library-build
# Environment
ARG TARGET_OS="Linux"
ENV TARGET_OS=${TARGET_OS} \
RUNTIME_LIB_DIR=${ARTIFACT_DIR}${RUNTIME_LIB_DIR}
# Copy build script
ADD ./scripts/build-library.sh ./
# Run build
RUN bash ./build-library.sh
#
# final ffmpeg-library image
#
FROM scratch AS ffmpeg-library
COPY --from=ffmpeg-library-build /dist /
#
# ffmpeg linux binary build stage
#
FROM build-env AS ffmpeg-linux-build
# Environment
ENV TARGET_OS="Linux"
# Copy build script
ADD ./scripts/build-ffmpeg.sh ./
# Copy ffmpeg-library image
COPY --from=ghcr.io/akashisn/ffmpeg-library:linux / /
# Build ffmpeg
RUN bash ./build-ffmpeg.sh
# Copy run.sh
COPY --chmod=755 <<'EOT' ${ARTIFACT_DIR}/${PREFIX}/run.sh
#!/bin/sh
export PATH=$(dirname $0)/bin:$PATH
export LD_LIBRARY_PATH=$(dirname $0)/lib:$LD_LIBRARY_PATH
export LIBVA_DRIVERS_PATH=$(dirname $0)/lib/dri
export LIBVA_DRIVER_NAME=iHD
exec $@
EOT
#
# final ffmpeg-linux image
#
FROM ubuntu:22.04 AS ffmpeg-linux
SHELL ["/bin/sh", "-e", "-c"]
# Environment
ENV DEBIAN_FRONTEND=noninteractive \
LD_LIBRARY_PATH=/usr/local/lib \
LIBVA_DRIVERS_PATH=/usr/local/lib/dri \
LIBVA_DRIVER_NAME=iHD
# Copy ffmpeg
COPY --from=ffmpeg-linux-build /dist /
# Run ldconfig
RUN ldconfig
WORKDIR /workdir
ENTRYPOINT [ "ffmpeg" ]
CMD [ "--help" ]
#
# ffmpeg windows binary build image
#
FROM build-env AS ffmpeg-windows-build
# Environment
ENV TARGET_OS="Windows"
# Copy build script
ADD ./scripts/build-ffmpeg.sh ./
# Copy ffmpeg-library image
COPY --from=ghcr.io/akashisn/ffmpeg-library:windows / /
# Build ffmpeg
RUN bash ./build-ffmpeg.sh
#
# final ffmpeg-windows image
#
FROM scratch AS ffmpeg-windows
COPY --from=ffmpeg-windows-build /dist /
#
# export image
#
FROM scratch AS ffmpeg-linux-export
COPY --from=ffmpeg-linux-image /usr/local/bin /bin
COPY --from=ffmpeg-linux-image /usr/local/lib /lib
COPY --from=ffmpeg-linux-image /usr/local/configure_options /
COPY --from=ffmpeg-linux-image /usr/local/run.sh /
#
# export windws exe
#
FROM scratch AS ffmpeg-windows-export
COPY --from=ffmpeg-windows-image /usr/local /
#
# vainfo build image
#
FROM ubuntu:22.04 AS vainfo-build
SHELL ["/bin/bash", "-e", "-c"]
# Copy ffmpeg-library image
COPY --from=ghcr.io/akashisn/ffmpeg-library:linux / /
# Copy vainfo library
RUN <<EOT
mkdir -p /dist
cp --archive --parents --no-dereference /usr/local/bin/vainfo /dist
cd /runtime
cp --archive --parents --no-dereference usr/local/lib/libpciaccess.so* /dist
cp --archive --parents --no-dereference usr/local/lib/libva{,-drm}.so* /dist
cp --archive --parents --no-dereference usr/local/lib/libdrm*.so* /dist
cp --archive --parents --no-dereference usr/local/lib/libigdgmm.so* /dist
cp --archive --parents --no-dereference usr/local/lib/dri /dist
EOT
#
# vainfo image
#
FROM ubuntu:22.04 AS vainfo
SHELL ["/bin/bash", "-e", "-c"]
# Environment
ENV DEBIAN_FRONTEND=noninteractive \
LD_LIBRARY_PATH=/usr/local/lib \
LIBVA_DRIVERS_PATH=/usr/local/lib/dri \
LIBVA_DRIVER_NAME=iHD
# Copy ffmpeg-library image
COPY --from=vainfo-build /dist /
# Run ldconfig
RUN ldconfig
WORKDIR /workdir
ENTRYPOINT [ "/usr/local/bin/vainfo" ]