-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
143 lines (127 loc) · 3.12 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
ARG NGINX_VERSION=1.18.0
ARG NGINX_RTMP_VERSION=1.2.1
ARG FFMPEG_VERSION=4.3.1
##############################
# Build the NGINX-build image.
FROM alpine:latest as build-nginx
ARG NGINX_VERSION
ARG NGINX_RTMP_VERSION
ARG FFMPEG_VERSION
ARG PREFIX=/usr/local
ARG MAKEFLAGS="-j4"
# Set default ports.
ENV HTTP_PORT 80
ENV HTTPS_PORT 443
ENV RTMP_PORT 1935
# Build dependencies.
RUN apk add --update \
build-base \
ca-certificates \
curl \
coreutils \
freetype-dev \
gcc \
gettext \
lame \
lame-dev \
libogg \
libogg-dev \
libass \
libass-dev \
libvpx \
libvpx-dev \
libvorbis \
libvorbis-dev \
libwebp \
libwebp-dev \
libtheora \
libtheora-dev \
libc-dev \
libgcc \
linux-headers \
make \
musl-dev \
openssl \
openssl-dev \
opus \
opus-dev \
pcre \
pcre-dev \
pkgconf \
pkgconfig \
rtmpdump \
rtmpdump-dev \
wget \
x264-dev \
x265-dev \
yasm \
zlib-dev
# Get nginx source.
RUN cd /tmp && \
wget https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz && \
tar zxf nginx-${NGINX_VERSION}.tar.gz && \
rm nginx-${NGINX_VERSION}.tar.gz
# Get nginx-rtmp module.
RUN cd /tmp && \
wget https://github.com/arut/nginx-rtmp-module/archive/v${NGINX_RTMP_VERSION}.tar.gz && \
tar zxf v${NGINX_RTMP_VERSION}.tar.gz && rm v${NGINX_RTMP_VERSION}.tar.gz
# Compile nginx with nginx-rtmp module.
RUN cd /tmp/nginx-${NGINX_VERSION} && \
./configure \
--prefix=/usr/local/nginx \
--add-module=/tmp/nginx-rtmp-module-${NGINX_RTMP_VERSION} \
--conf-path=/etc/nginx/nginx.conf \
--with-threads \
--with-file-aio \
--with-http_ssl_module \
--with-debug \
--with-http_secure_link_module \
--with-http_realip_module \
--with-cc-opt="-Wimplicit-fallthrough=0" && \
cd /tmp/nginx-${NGINX_VERSION} && make && make install
RUN echo http://dl-cdn.alpinelinux.org/alpine/edge/community >> /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 \
--prefix=${PREFIX} \
--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-postproc \
--enable-avresample \
--enable-libfreetype \
--enable-openssl \
--disable-debug \
--disable-doc \
--disable-ffplay \
--extra-libs="-lpthread -lm" && \
make && make install && make distclean
# Cleanup.
RUN rm -rf /var/cache/* /tmp/*
#Add NGINX path, config and static files.
ENV PATH "${PATH}:/usr/local/nginx/sbin"
ADD nginx.conf /etc/nginx/nginx.conf.template
RUN mkdir -p /opt/data && mkdir /www && mkdir -p /var/log/nginx
RUN mkdir -p /srv/data/hls
ADD static /www/static
EXPOSE 1935
EXPOSE 80
CMD envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < \
/etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf && \
nginx