diff --git a/trunk/Dockerfile b/trunk/Dockerfile old mode 100644 new mode 100755 index f7a711dc4a..ad68e009f7 --- a/trunk/Dockerfile +++ b/trunk/Dockerfile @@ -39,6 +39,12 @@ RUN echo "BUILDPLATFORM: $BUILDPLATFORM, TARGETPLATFORM: $TARGETPLATFORM" # Expose ports for streaming @see https://github.com/ossrs/srs#ports EXPOSE 1935 1985 8080 8000/udp 10080/udp +# For SRS Log Rotate +ARG DEBIAN_FRONTEND=noninteractive +ARG DEBCONF_NOWARNINGS="yes" +RUN apt-get update && apt-get install -y --no-install-recommends --no-install-suggests cron logrotate +COPY trunk/scripts/start.sh /usr/local/srs/ + # FFMPEG 4.1 COPY --from=build /usr/local/bin/ffmpeg /usr/local/srs/objs/ffmpeg/bin/ffmpeg # SRS binary, config files and srs-console. @@ -46,4 +52,4 @@ COPY --from=build /usr/local/srs /usr/local/srs # Default workdir and command. WORKDIR /usr/local/srs -CMD ["./objs/srs", "-c", "conf/docker.conf"] +ENTRYPOINT ["/usr/local/srs/start.sh"] \ No newline at end of file diff --git a/trunk/scripts/start.sh b/trunk/scripts/start.sh new file mode 100755 index 0000000000..24f67e4389 --- /dev/null +++ b/trunk/scripts/start.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# create logrotate config for srs log +SRS_LOG_FILE=`grep srs_log_file /usr/local/srs/conf/bruce.conf | awk '{print $NF}' | cut -d ';' -f 1` +cat > /etc/logrotate.d/srs << EOF +$SRS_LOG_FILE { + daily + dateext + dateformat -%Y-%m-%d.log + compress + delaycompress + missingok + rotate 7 + sharedscripts + postrotate + if [ -f /usr/local/srs/objs/srs.pid ]; then + kill -USR1 \`cat /usr/local/srs/objs/srs.pid\` + fi + endscript +} +EOF + +# start cron for logrotate +service cron start + +# start srs +/usr/local/srs/objs/srs -c conf/bruce.conf