diff --git a/Dockerfile b/Dockerfile index a3fbeed..e492528 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,8 @@ FROM debian:buster-slim ENV NGINX_VERSION=1.18.0 ENV CUSTOM_MODULES "--with-file-aio --with-http_auth_request_module --with-http_ssl_module" +WORKDIR /tmp + RUN apt update && \ apt install -y \ wget \ @@ -15,36 +17,28 @@ RUN apt update && \ unzip \ zlib1g-dev -RUN addgroup --system --gid 1001 nginx \ - && adduser --system --disabled-login --ingroup nginx --no-create-home --home /nonexistent --gecos "nginx user" --shell /bin/false --uid 1001 nginx - -WORKDIR /tmp - -RUN wget http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz - -RUN echo $(pwd) - -RUN tar -xzvf nginx-$NGINX_VERSION.tar.gz - -RUN git clone "https://github.com/sergey-dryabzhinsky/nginx-rtmp-module.git" - -RUN cd nginx-$NGINX_VERSION && ./configure --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --add-module=/tmp/nginx-rtmp-module $CUSTOM_MODULES - -RUN cd nginx-$NGINX_VERSION && make && make install +RUN wget http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz && \ + git clone "https://github.com/sergey-dryabzhinsky/nginx-rtmp-module.git" + +RUN addgroup --system --gid 1001 nginx && \ + adduser --system --disabled-login --ingroup nginx --no-create-home --home /nonexistent --gecos "nginx user" --shell /bin/false --uid 1001 nginx && \ + mkdir -p /home/videos/vod && \ + mkdir -p /home/videos/recordings && \ + touch /home/videos/recordings/auth && \ + tar -xzvf nginx-$NGINX_VERSION.tar.gz && \ + cd nginx-$NGINX_VERSION && \ + ./configure --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --add-module=/tmp/nginx-rtmp-module $CUSTOM_MODULES && \ + make && \ + make install && \ + rm -rf nginx* COPY templates/nginx/nginx.conf /etc/nginx/nginx.conf ARG RTMP_AUTH_URL=http://localhost/auth ARG HLS_AUTH_URL=http://localhost/auth -RUN sed -i "s/proxy_pass http:\/\/localhost\/rtmp-auth;/proxy_pass $(printf '%s\n' "$RTMP_AUTH_URL" | sed -e 's/[\/&]/\\&/g');/g" /etc/nginx/nginx.conf -RUN sed -i "s/proxy_pass http:\/\/localhost\/hls-auth;/proxy_pass $(printf '%s\n' "$HLS_AUTH_URL" | sed -e 's/[\/&]/\\&/g');/g" /etc/nginx/nginx.conf - -RUN mkdir -p /home/videos/vod && mkdir -p /home/videos/recordings - -RUN touch /home/videos/recordings/auth - -RUN rm -rf nginx* +RUN sed -i "s/proxy_pass http:\/\/localhost\/rtmp-auth;/proxy_pass $(printf '%s\n' "$RTMP_AUTH_URL" | sed -e 's/[\/&]/\\&/g');/g" /etc/nginx/nginx.conf && \ + sed -i "s/proxy_pass http:\/\/localhost\/hls-auth;/proxy_pass $(printf '%s\n' "$HLS_AUTH_URL" | sed -e 's/[\/&]/\\&/g');/g" /etc/nginx/nginx.conf RUN nginx -t