From fd6b6631594c4cb801246d665f775402e8f96567 Mon Sep 17 00:00:00 2001 From: marvinlehmann Date: Thu, 5 Nov 2020 02:26:25 +0100 Subject: [PATCH] Added Dockerfile --- Dockerfile | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..09c3547 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,47 @@ +ARG NGINX_TMP_INSTALL_DIR=/tmp/nginx-rtmp + +FROM alpine:latest as builder + +ENV NGINX_VERSION=1.18.0 +ENV NGINX_RTMP_MODULE_COMMIT=23ec4ce2d769830124abf3be1353dd9b105ab09c + +# Install dependencies +RUN apk --update-cache add build-base openssl-dev pcre-dev zlib-dev + +# Download and extract nginx source +RUN mkdir -p /tmp/build/nginx && \ + cd /tmp/build/nginx && \ + wget -O nginx.tar.gz https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz && \ + tar -zxf nginx.tar.gz + +# Download and extract RTMP module source +RUN mkdir -p /tmp/build/nginx-rtmp-module && \ + cd /tmp/build/nginx-rtmp-module && \ + wget -O module.zip https://github.com/sergey-dryabzhinsky/nginx-rtmp-module/archive/${NGINX_RTMP_MODULE_COMMIT}.zip && \ + unzip module.zip + +# Build and install nginx in a specific directory in order to isolate it for later copy +RUN cd /tmp/build/nginx/nginx-${NGINX_VERSION} && \ + ./configure \ + --sbin-path=/usr/local/sbin/nginx \ + --pid-path=/var/run/nginx.pid \ + --lock-path=/var/lock/nginx.lock \ + --error-log-path=/var/log/nginx/error.log \ + --http-log-path=/var/log/nginx/access.log \ + --http-client-body-temp-path=/tmp/nginx-client-body \ + --with-http_ssl_module \ + --with-threads \ + --add-module=/tmp/build/nginx-rtmp-module/nginx-rtmp-module-${NGINX_RTMP_MODULE_COMMIT} && \ + make -j$(nproc) && \ + make DESTDIR=${NGINX_TMP_INSTALL_DIR} install + +# Replace default with custom config +COPY nginx.conf ${NGINX_TMP_INSTALL_DIR}/usr/local/nginx/conf/nginx.conf + + +FROM alpine:latest + +# Copy installed nginx from previous stage +COPY --from=builder ${NGINX_TMP_INSTALL_DIR} / + +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file