-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-rpi
159 lines (134 loc) · 4.59 KB
/
Dockerfile-rpi
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
ARG IMAGE=debian:buster-slim
FROM $IMAGE as builder
MAINTAINER datarhei <[email protected]>
ARG LAME_VERSION=3.100
ARG FFMPEG_VERSION=4.1.5
ARG NGINX_VERSION=1.18.0
ARG NGINXRTMP_VERSION=1.2.1
ARG NODE_VERSION=12.16.3
ENV SRC="/usr/local/" \
LD_LIBRARY_PATH="/usr/local/lib" \
PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/opt/vc/lib/pkgconfig"
RUN apt-get update && \
apt-get install -y \
pkg-config \
cmake \
libomxil-bellagio-dev \
git \
curl \
libpcre3-dev \
libtool \
libssl-dev \
zlib1g-dev \
libasound2-dev \
sudo \
xz-utils \
build-essential
# Build rpi userland
RUN mkdir -p /dist && cd /dist && git clone --depth 1 https://github.com/raspberrypi/userland.git
RUN cd /dist/userland && ./buildme
# Required to link deps
RUN echo "/opt/vc/lib" > /etc/ld.so.conf.d/00-vmcs.conf
RUN ldconfig
# x264
RUN mkdir -p /dist && cd /dist && \
curl -OL https://code.videolan.org/videolan/x264/-/archive/stable/x264-stable.tar.bz2 && \
tar -xvj -f x264-stable.tar.bz2 && \
cd x264-stable && \
./configure --prefix="${SRC}" --bindir="${SRC}/bin" --enable-shared && \
make -j$(nproc) && \
make install
# libmp3lame
RUN mkdir -p /dist && cd /dist && \
curl -OL "https://downloads.sourceforge.net/project/lame/lame/${LAME_VERSION}/lame-${LAME_VERSION}.tar.gz" && \
tar -xvz -f lame-${LAME_VERSION}.tar.gz && \
cd lame-${LAME_VERSION} && \
./configure --prefix="${SRC}" --bindir="${SRC}/bin" --disable-static && \
make -j$(nproc) && \
make install
# ffmpeg && patch
COPY ./contrib/ffmpeg /dist/restreamer/contrib/ffmpeg
RUN mkdir -p /dist && cd /dist && \
curl -OL "https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.xz" && \
tar -xv -f ffmpeg-${FFMPEG_VERSION}.tar.xz
RUN cd /dist/ffmpeg-${FFMPEG_VERSION} && \
patch -p1 < /dist/restreamer/contrib/ffmpeg/bitrate.patch && \
./configure \
--bindir="${SRC}/bin" \
--extra-cflags="-I${SRC}/include" \
--extra-ldflags="-L${SRC}/lib" \
--prefix="${SRC}" \
--enable-nonfree \
--enable-gpl \
--enable-version3 \
--enable-libmp3lame \
--enable-libx264 \
--enable-omx \
--enable-omx-rpi \
--enable-mmal \
--enable-openssl \
--enable-postproc \
--enable-small \
--enable-static \
--disable-debug \
--disable-doc \
--disable-shared && \
make -j$(nproc) && \
make install
# nginx-rtmp
RUN mkdir -p /dist && cd /dist && \
curl -OL "https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz" && \
tar -xvz -f "nginx-${NGINX_VERSION}.tar.gz" && \
curl -OL "https://github.com/arut/nginx-rtmp-module/archive/v${NGINXRTMP_VERSION}.tar.gz" && \
tar -xvz -f "v${NGINXRTMP_VERSION}.tar.gz" && \
sed -i"" -e '/case ESCAPE:/i /* fall through */' nginx-rtmp-module-${NGINXRTMP_VERSION}/ngx_rtmp_eval.c && \
cd nginx-${NGINX_VERSION} && \
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_v2_module --add-module=/dist/nginx-rtmp-module-${NGINXRTMP_VERSION} && \
make -j$(nproc) && \
make install
# node.js
RUN mkdir -p /dist && cd /dist && \
curl -OL "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-armv7l.tar.xz" && \
tar -xvJ -f "node-v${NODE_VERSION}-linux-armv7l.tar.xz" && \
cd node-v${NODE_VERSION}-linux-armv7l && \
cp -R bin /usr/local && \
cp -R lib /usr/local
FROM $IMAGE
COPY --from=builder /usr/local/bin /usr/local/bin
COPY --from=builder /usr/local/nginx /usr/local/nginx
COPY --from=builder /usr/local/lib /usr/local/lib
RUN echo "/opt/vc/lib" > /etc/ld.so.conf.d/00-vmcs.conf
RUN ldconfig
RUN apt-get update && \
apt-get install -y \
ca-certificates \
libomxil-bellagio-dev \
git \
procps \
libpcre3 \
openssl \
libssl1.1 \
zlib1g \
v4l-utils \
libv4l-0 \
alsa-utils \
libatomic1
COPY . /restreamer
WORKDIR /restreamer
RUN cd /restreamer && \
npm install -g grunt-cli nodemon eslint && \
npm install && \
grunt build && \
npm prune --production && \
npm cache verify && \
npm uninstall -g grunt-cli nodemon eslint && \
npm prune --production && \
apt-get remove -y \
git \
curl && \
apt autoremove -y
ENV DEVICE=raspi
EXPOSE 8080
EXPOSE 8181
VOLUME ["/restreamer/db"]
CMD ["./run.sh"]