forked from sandreas/m4b-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
103 lines (89 loc) · 3.69 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
##############################
#
# m4b-tool build image
# alias m4b-tool='docker run -it --rm -u $(id -u):$(id -g) -v "$(pwd)":/mnt m4b-tool'
# alias m4b-tool='docker run -it --entrypoint=m4b-tool-pre --rm -u $(id -u):$(id -g) -v "$(pwd)":/mnt m4b-tool'
##############################
FROM alpine:3.14 as builder
ARG FDK_AAC_VERSION=2.0.1
ARG FDK_AAC_URL="https://github.com/mstorsjo/fdk-aac/archive/v$FDK_AAC_VERSION.tar.gz"
ARG FDK_AAC_SHA256=a4142815d8d52d0e798212a5adea54ecf42bcd4eec8092b37a8cb615ace91dc6
RUN echo "---- INSTALL BUILD DEPENDENCIES ----" \
&& apk add --no-cache --update --upgrade --virtual=build-dependencies \
autoconf \
libtool \
automake \
boost-dev \
build-base \
gcc \
git \
tar \
wget \
&& echo "---- COMPILE SANDREAS MP4V2 (for sort-title, sort-album and sort-author) ----" \
&& cd /tmp/ \
&& wget https://github.com/sandreas/mp4v2/archive/master.zip \
&& unzip master.zip \
&& cd mp4v2-master \
&& ./configure && \
make -j4 && \
make install && make distclean \
&& echo "---- PREPARE FDKAAC-DEPENDENCIES ----" \
&& cd /tmp/ \
&& wget -O fdk-aac.tar.gz "$FDK_AAC_URL" \
&& tar xfz fdk-aac.tar.gz \
&& cd fdk-aac-* && ./autogen.sh && ./configure --enable-static --disable-shared && make -j$(nproc) install \
&& echo "---- COMPILE FDKAAC ENCODER (executable binary for usage of --audio-profile) ----" \
&& cd /tmp/ \
&& wget https://github.com/nu774/fdkaac/archive/1.0.0.tar.gz \
&& tar xzf 1.0.0.tar.gz \
&& cd fdkaac-1.0.0 \
&& autoreconf -i && ./configure --enable-static --disable-shared && make -j4 && make install && rm -rf /tmp/* \
&& echo "---- REMOVE BUILD DEPENDENCIES (to keep image small) ----" \
&& apk del --purge build-dependencies && rm -rf /tmp/*
##############################
#
# m4b-tool development image
#
##############################
FROM alpine:3.14
ENV WORKDIR /mnt/
ENV M4BTOOL_TMP_DIR /tmp/m4b-tool/
RUN echo "---- INSTALL RUNTIME PACKAGES ----" && \
apk add --no-cache --update --upgrade \
# mp4v2: required libraries
libstdc++ \
# m4b-tool: php cli, required extensions and php settings
php7-cli \
php7-dom \
php7-json \
php7-xml \
php7-mbstring \
php7-phar \
php7-tokenizer \
php7-xmlwriter \
php7-openssl \
&& echo "date.timezone = UTC" >> /etc/php7/php.ini
# copy ffmpeg static with libfdk from mwader docker image
COPY --from=mwader/static-ffmpeg:4.4.0 /ffmpeg /usr/local/bin/
# copy compiled mp4v2 binaries, libs and fdkaac encoder to runtime image
COPY --from=builder /usr/local/bin/mp4* /usr/local/bin/fdkaac /usr/local/bin/
COPY --from=builder /usr/local/lib/libmp4v2* /usr/local/lib/
ARG M4B_TOOL_DOWNLOAD_LINK="https://github.com/sandreas/m4b-tool/releases/latest/download/m4b-tool.tar.gz"
# workaround to copy a local m4b-tool.phar IF it exists
ADD ./Dockerfile ./dist/m4b-tool.phar* /tmp/
RUN echo "---- INSTALL M4B-TOOL ----" \
&& if [ ! -f /tmp/m4b-tool.phar ]; then \
wget "${M4B_TOOL_DOWNLOAD_LINK}" -O /tmp/m4b-tool.tar.gz && \
if [ ! -f /tmp/m4b-tool.phar ]; then \
tar xzf /tmp/m4b-tool.tar.gz -C /tmp/ && rm /tmp/m4b-tool.tar.gz ;\
fi \
fi \
&& mv /tmp/m4b-tool.phar /usr/local/bin/m4b-tool \
&& M4B_TOOL_PRE_RELEASE_LINK=$(wget -q -O - https://github.com/sandreas/m4b-tool/releases/tag/latest | grep -o 'M4B_TOOL_DOWNLOAD_LINK=[^ ]*' | head -1 | cut -d '=' -f 2) \
&& wget "${M4B_TOOL_PRE_RELEASE_LINK}" -O /tmp/m4b-tool.tar.gz \
&& tar xzf /tmp/m4b-tool.tar.gz -C /tmp/ && rm /tmp/m4b-tool.tar.gz \
&& mv /tmp/m4b-tool.phar /usr/local/bin/m4b-tool-pre \
&& chmod +x /usr/local/bin/m4b-tool /usr/local/bin/m4b-tool-pre
WORKDIR ${WORKDIR}
CMD ["list"]
ENTRYPOINT ["m4b-tool"]