From 5b58ef69cdb6d084ff6c27b8c2f0613e4b4282dc Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Mon, 3 Feb 2020 21:50:04 +0100 Subject: [PATCH] Initial version --- Dockerfile | 27 +++++++++++++++++++++ docker-entrypoint.sh | 7 ++++++ nginx.conf | 58 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 Dockerfile create mode 100755 docker-entrypoint.sh create mode 100644 nginx.conf diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3bd912b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM alpine:latest as fetch + +RUN set -ex \ + && apk --no-cache add \ + ca-certificates \ + curl \ + && curl -sSfLo /tmp/dumb-init "https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_amd64" \ + && chmod +x \ + /tmp/dumb-init + + +FROM alpine:latest + +RUN set -ex \ + && apk --no-cache add \ + bash \ + nginx \ + nginx-mod-rtmp + +COPY --from=fetch /tmp/dumb-init /usr/local/bin/ +COPY docker-entrypoint.sh /usr/local/bin/ +COPY nginx.conf /etc/nginx/nginx.conf + +EXPOSE 80 1935 +VOLUME ["/data"] + +CMD ["/usr/local/bin/docker-entrypoint.sh"] diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 0000000..e5ade26 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,7 @@ +#!/usr/local/bin/dumb-init /bin/bash +set -euxo pipefail + +# Ensure nginx can work with the /data dir +chown -R nginx: /data + +exec nginx -g "daemon off;" diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..bbed065 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,58 @@ + +user nginx; +worker_processes auto; + +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; + +include /etc/nginx/modules/rtmp.conf; + +events { + worker_connections 1024; +} + + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + access_log /var/log/nginx/access.log main; + + sendfile on; + keepalive_timeout 65; + + server { + listen 80 default_server; + server_name localhost; + + types { + application/vnd.apple.mpegurl m3u8; + } + + root /data; + + add_header Cache-Control no-cache; + add_header Access-Control-Allow-Origin *; + } +} + +rtmp { + server { + listen 1935; + + application hls { + live on; + + hls on; + hls_fragment 1m; + hls_fragment_naming system; + hls_fragment_slicing aligned; + hls_path /data; + hls_playlist_length 24h; + hls_nested on; + } + } +}