forked from Garfield96/docker-nginx-rtmp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
106 lines (92 loc) · 2.24 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
ARG NGINX_VERSION=1.27.2
ARG NGINX_RTMP_VERSION=dev
##############################
# Build the NGINX-build image.
FROM alpine:3.20 as build-nginx
ARG NGINX_VERSION
ARG NGINX_RTMP_VERSION
ARG MAKEFLAGS="-j4"
# Build dependencies.
RUN apk add --no-cache \
build-base \
ca-certificates \
curl \
gcc \
libc-dev \
libgcc \
linux-headers \
make \
musl-dev \
openssl \
openssl-dev \
pcre \
pcre-dev \
pkgconf \
pkgconfig \
zlib-dev
WORKDIR /tmp
# Get nginx source.
RUN 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 wget https://github.com/sergey-dryabzhinsky/nginx-rtmp-module/archive/${NGINX_RTMP_VERSION}.tar.gz && \
tar zxf ${NGINX_RTMP_VERSION}.tar.gz && \
rm ${NGINX_RTMP_VERSION}.tar.gz
# Compile nginx with nginx-rtmp module.
WORKDIR /tmp/nginx-${NGINX_VERSION}
RUN \
./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_stub_status_module \
--with-cc-opt="-Wimplicit-fallthrough=0" && \
make && \
make install
# Cleanup.
RUN rm -rf /var/cache/* /tmp/*
##########################
# Build the release image.
FROM alpine:3.20
LABEL MAINTAINER Thomas Lekanger <[email protected]>
# Set default environment variables.
ENV HTTP_PORT 80
ENV HTTPS_PORT 443
ENV RTMP_PORT 1935
ENV STAT_LOCATION "/stat"
ENV CONTROL_LOCATION="/control"
ENV RTMP_STREAM_KEY="secret"
RUN apk add --no-cache \
ca-certificates \
gettext \
openssl \
pcre \
lame \
libogg \
curl \
libass \
libvpx \
libvorbis \
libwebp \
libtheora \
opus \
rtmpdump \
x264-dev \
x265-dev
COPY --from=build-nginx /usr/local/nginx /usr/local/nginx
COPY --from=build-nginx /etc/nginx /etc/nginx
# Add NGINX path, config and static files.
ENV PATH "${PATH}:/usr/local/nginx/sbin"
COPY nginx.conf /etc/nginx/nginx.conf.template
RUN mkdir -p /opt/data && mkdir /www
COPY 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