-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDockerfile
188 lines (156 loc) · 5.73 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
FROM alpine:3.4
MAINTAINER Soma Szélpál <[email protected]>
ENV NGINX_VERSION 1.15.2
ENV NGINX_DEVEL_KIT_VERSION=0.3.0
ENV NGINX_RTMP_MODULE_VERSION 1.2.1
ENV NGINX_LUA_MODULE_VERSION=0.10.13
ENV LUAJIT_VERSION=2.0.5
ENV FFMPEG_VERSION=4.0.2
ENV LUAROCKS_VERSION=3.0.0
ENV OPENRESTY_VERSION=1.13.6.1
ENV NGINX_DEVEL_KIT ngx_devel_kit-${NGINX_DEVEL_KIT_VERSION}
ENV NGINX_RTMP_MODULE nginx-rtmp-module-${NGINX_RTMP_MODULE_VERSION}
ENV NGINX_LUA_MODULE lua-nginx-module-${NGINX_LUA_MODULE_VERSION}
ENV LUAROCKS luarocks-${LUAROCKS_VERSION}
ENV OPENRESTY openresty-${OPENRESTY_VERSION}
ENV LUAJIT_LIB /usr/local/lib
ENV LUAJIT_INC /usr/local/include/luajit-2.0
# Common dependencies
ENV DEPS_COMMON="bash nano lua"
# Common build tools
ENV DEPS_BUILD_TOOLS="git perl unzip gcc binutils-libs binutils build-base libgcc make pkgconf pkgconfig openssl openssl-dev ca-certificates pcre nasm yasm yasm-dev coreutils musl-dev libc-dev pcre-dev zlib-dev lua-dev"
# FFMPEG dependencies
ENV DEPS_FFMPEG "gnutls-dev libogg-dev libvpx-dev libvorbis-dev freetype-dev libass-dev libwebp-dev rtmpdump-dev libtheora-dev lame-dev xvidcore-dev imlib2-dev x264-dev bzip2-dev perl-dev libvpx-dev sdl2-dev libxfixes-dev libva-dev alsa-lib-dev v4l-utils-dev opus-dev x265-dev"
# Updating certificates
RUN apk update \
&& apk add openssl ca-certificates \
&& update-ca-certificates
# Installing common dependencies
RUN apk update && apk add --virtual .common-dependencies ${DEPS_COMMON}
# Installing build dependencies
RUN apk update && apk add --virtual .build-dependencies ${DEPS_BUILD_TOOLS}
# Build Luarocks.
RUN cd /tmp \
&& wget https://github.com/luarocks/luarocks/archive/v${LUAROCKS_VERSION}.tar.gz -O ${LUAROCKS}.tar.gz \
&& tar zxf ${LUAROCKS}.tar.gz \
&& rm ${LUAROCKS}.tar.gz \
&& cd ${LUAROCKS} \
&& ./configure \
&& make build install
RUN rm -rf /tmp/${LUAROCKS}
# Get LuaJIT.
RUN cd /tmp \
&& wget http://luajit.org/download/LuaJIT-${LUAJIT_VERSION}.tar.gz \
&& tar zxf LuaJIT-${LUAJIT_VERSION}.tar.gz \
&& rm LuaJIT-${LUAJIT_VERSION}.tar.gz
RUN cd /tmp/LuaJIT-${LUAJIT_VERSION} && make && make install
# Build OpenResty.
RUN cd /tmp \
&& wget http://openresty.org/download/openresty-${OPENRESTY_VERSION}.tar.gz -O ${OPENRESTY}.tar.gz \
&& tar zxf ${OPENRESTY}.tar.gz \
&& rm ${OPENRESTY}.tar.gz \
&& cd ${OPENRESTY} \
&& ./configure -j2 \
&& make -j2 \
&& make install
RUN rm -rf /tmp/${OPENRESTY}
# Get nginx source.
RUN cd /tmp \
&& wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz \
&& tar zxf nginx-${NGINX_VERSION}.tar.gz \
&& rm nginx-${NGINX_VERSION}.tar.gz
# Get ngx_devel_kit.
RUN cd /tmp \
&& wget https://github.com/simpl/ngx_devel_kit/archive/v${NGINX_DEVEL_KIT_VERSION}.tar.gz -O ${NGINX_DEVEL_KIT}.tar.gz \
&& tar zxf ${NGINX_DEVEL_KIT}.tar.gz \
&& rm ${NGINX_DEVEL_KIT}.tar.gz
# Get nginx-rtmp module.
RUN cd /tmp \
&& wget https://github.com/arut/nginx-rtmp-module/archive/v${NGINX_RTMP_MODULE_VERSION}.tar.gz -O ${NGINX_RTMP_MODULE}.tar.gz \
&& tar zxf ${NGINX_RTMP_MODULE}.tar.gz \
&& rm ${NGINX_RTMP_MODULE}.tar.gz
# Get lua-nginx-module.
RUN cd /tmp \
&& wget https://github.com/openresty/lua-nginx-module/archive/v${NGINX_LUA_MODULE_VERSION}.tar.gz -O ${NGINX_LUA_MODULE}.tar.gz \
&& tar zxf ${NGINX_LUA_MODULE}.tar.gz \
&& rm ${NGINX_LUA_MODULE}.tar.gz
# patch nginx lua compilation error on nginx 1.13 (https://github.com/openresty/lua-nginx-module/issues/1016)
#ADD ./patch/patch-src-ngx_http_lua_headers.c.diff /tmp/
#RUN cd /tmp/${NGINX_LUA_MODULE}/src \
# && patch < /tmp/patch-src-ngx_http_lua_headers.c.diff
# Compile nginx with nginx-rtmp module.
RUN cd /tmp/nginx-${NGINX_VERSION} \
&& ./configure \
--prefix=/opt/nginx \
--with-ld-opt="-Wl,-rpath,${LUAJIT_LIB}" \
--add-module=/tmp/${NGINX_DEVEL_KIT} \
--add-module=/tmp/${NGINX_LUA_MODULE} \
--add-module=/tmp/${NGINX_RTMP_MODULE} \
--conf-path=/opt/nginx/nginx.conf \
--error-log-path=/opt/nginx/logs/error.log \
--http-log-path=/opt/nginx/logs/access.log \
--with-debug \
--with-http_auth_request_module
RUN cd /tmp/nginx-${NGINX_VERSION} && make && make install
# ffmpeg dependencies.
RUN apk add --update --virtual .ffmpeg-dependencies ${DEPS_FFMPEG}
RUN echo http://dl-cdn.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories
RUN apk add --update fdk-aac-dev
# Get ffmpeg source.
RUN cd /tmp/ && wget http://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.gz \
&& tar zxf ffmpeg-${FFMPEG_VERSION}.tar.gz && rm ffmpeg-${FFMPEG_VERSION}.tar.gz
# Compile ffmpeg.
RUN cd /tmp/ffmpeg-${FFMPEG_VERSION} && \
./configure \
--enable-version3 \
--enable-gpl \
--enable-nonfree \
--enable-small \
--enable-libmp3lame \
--enable-libx264 \
--enable-libx265 \
--enable-libvpx \
--enable-libtheora \
--enable-libvorbis \
--enable-libopus \
--enable-libfdk-aac \
--enable-libass \
--enable-libwebp \
--enable-librtmp \
--enable-postproc \
--enable-avresample \
--enable-libfreetype \
--enable-openssl \
--enable-avfilter \
--enable-libxvid \
--enable-libv4l2 \
--enable-pic \
--enable-shared \
--enable-vaapi \
--enable-pthreads \
--enable-shared \
--disable-stripping \
--disable-static \
--disable-debug
RUN cd /tmp/ffmpeg-${FFMPEG_VERSION} && make && make install && make distclean
# Remove unneccessary dependencies
#RUN apk del .ffmpeg-dependencies .build-dependencies
#RUN apk del ${DEPS_FFMPEG} ${DEPS_NGINX}
# Cleanup.
RUN rm -rf /tmp/*
# Adding nginx configuration file
ADD nginx.conf /opt/nginx/nginx.conf
# Prepare data directory
RUN mkdir -p /data
RUN mkdir -p /data/hls
RUN mkdir -p /data/dash
# Prepare www directory
RUN mkdir -p /www
# Add static files
ADD static /www/static
# Expose RTMP port
EXPOSE 1935
# Expose HTTP port
EXPOSE 80
# Start NGINX
CMD ["/opt/nginx/sbin/nginx"]