diff --git a/Dockerfile b/Dockerfile index e4a2978..d68b9ea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM ubuntu:18.04 RUN apt-get update RUN apt-get upgrade -y -RUN apt-get install -y build-essential libpcre3 libpcre3-dev libssl-dev unzip ffmpeg wget zlib1g zlib1g-dev libssl-dev sudo +RUN apt-get install -y build-essential libpcre3 libpcre3-dev libssl-dev unzip ffmpeg wget zlib1g zlib1g-dev libssl-dev sudo curl RUN useradd --create-home -s /bin/bash www ;\ adduser www sudo @@ -29,6 +29,11 @@ ADD crossdomain.xml /usr/local/nginx/html/crossdomain.xml ADD nginx.conf /home/www RUN sudo chown -R www:www /usr/local/nginx +# aws cli +RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" +RUN unzip -u awscliv2.zip +RUN sudo ./aws/install + EXPOSE 80 443 1935 CMD ["/usr/local/nginx/sbin/nginx", "-c", "/home/www/nginx.conf"] diff --git a/README.md b/README.md index 35f1781..429b5f6 100644 --- a/README.md +++ b/README.md @@ -18,3 +18,8 @@ Then stop the container and start it again with the same command. ``` docker run -p 1935:1935 -p 8080:8080 -p 16666:4443 -v /home/deploy/viz/fullchain.pem:/etc/letsencrypt/live/viz.streampusher.com/fullchain.pem -v /home/deploy/viz/privkey.pem:/etc/letsencrypt/live/viz.streampusher.com/privkey.pem datafruits/viz:latest ``` + +## Building new image: +``` +docker build -t datafruits/viz:latest . +``` diff --git a/nginx.conf b/nginx.conf index aed3ba5..5a3b0b0 100644 --- a/nginx.conf +++ b/nginx.conf @@ -11,36 +11,36 @@ events { http { server { listen 8080; - listen 4443 ssl; - server_name viz.streampusher.com; - ssl_certificate /etc/letsencrypt/live/viz.streampusher.com/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/viz.streampusher.com/privkey.pem; + # listen 4443 ssl; + # server_name viz.streampusher.com; + # ssl_certificate /etc/letsencrypt/live/viz.streampusher.com/fullchain.pem; + # ssl_certificate_key /etc/letsencrypt/live/viz.streampusher.com/privkey.pem; server_name vjstream.streampusher.com localhost; location /hls { - # Serve HLS fragments - - # CORS setup - add_header 'Access-Control-Allow-Origin' '*' always; - add_header 'Access-Control-Expose-Headers' 'Content-Length'; - - # allow CORS preflight requests - if ($request_method = 'OPTIONS') { - add_header 'Access-Control-Allow-Origin' '*'; - add_header 'Access-Control-Max-Age' 1728000; - add_header 'Content-Type' 'text/plain charset=UTF-8'; - add_header 'Content-Length' 0; - return 204; - } + # Serve HLS fragments + # CORS setup + add_header 'Access-Control-Allow-Origin' '*' always; + add_header 'Access-Control-Expose-Headers' 'Content-Length'; - types { - application/vnd.apple.mpegurl m3u8; - video/mp2t ts; - } - root /tmp; - add_header Cache-Control no-cache; + # allow CORS preflight requests + if ($request_method = 'OPTIONS') { + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Max-Age' 1728000; + add_header 'Content-Type' 'text/plain charset=UTF-8'; + add_header 'Content-Length' 0; + return 204; + } + + + types { + application/vnd.apple.mpegurl m3u8; + video/mp2t ts; + } + root /tmp; + add_header Cache-Control no-cache; } location /vj { @@ -69,13 +69,37 @@ http { } location /vj2 { -# Serve HLS fragments + # Serve HLS fragments + + # CORS setup + add_header 'Access-Control-Allow-Origin' '*' always; + add_header 'Access-Control-Expose-Headers' 'Content-Length'; + + # allow CORS preflight requests + if ($request_method = 'OPTIONS') { + add_header 'Access-Control-Allow-Origin' '*'; + add_header 'Access-Control-Max-Age' 1728000; + add_header 'Content-Type' 'text/plain charset=UTF-8'; + add_header 'Content-Length' 0; + return 204; + } + + types { + application/vnd.apple.mpegurl m3u8; + video/mp2t ts; + } -# CORS setup + root /tmp; + add_header Cache-Control no-cache; + } + location /datafruits_hls { + # Serve HLS fragments from liquidsoap output + + # CORS setup add_header 'Access-Control-Allow-Origin' '*' always; add_header 'Access-Control-Expose-Headers' 'Content-Length'; -# allow CORS preflight requests + # allow CORS preflight requests if ($request_method = 'OPTIONS') { add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Max-Age' 1728000; @@ -92,6 +116,7 @@ http { root /tmp; add_header Cache-Control no-cache; } + location /live { # Serve HLS fragments @@ -133,6 +158,17 @@ rtmp { record all; record_path /home/www/video_recordings; record_suffix -%d-%b-%y-%T.flv; + + # on_record_done http://example.com/recorded; + + # convert recorded file to mp4 format + # exec_record_done ffmpeg -y -i $path -acodec libmp3lame -ar 44100 -ac 1 -vcodec libx264 $dirname/$basename.mp4; + # exec_record_done ./sync_to_s3.sh $path + on_publish http://streampusher-rails-1:3000/dj_login.json; + + # send to icecast and rtmp listener in one ffmpeg command + exec_push ffmpeg -i rtmp://localhost/$app/$name -map 0:a -c:a libmp3lame -f mp3 icecast://rtmp_source:pricemaster9876@datafruits_liquidsoap:9001/datafruits_rtmp -map 0:v -map 0:a -c copy -f flv rtmp://datafruits_liquidsoap:1936/live/$name; + } application vj { diff --git a/sync_to_s3.sh b/sync_to_s3.sh new file mode 100755 index 0000000..2c7237f --- /dev/null +++ b/sync_to_s3.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +PATH=ARGV[1] +aws s3 cp $PATH s3://datafruitsvizdumps +rm $PATH