Dockerfile 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. # Dockerfile/Open GoPro, Version 2.0 (C) Copyright 2021 GoPro, Inc. (http://gopro.com/OpenGoPro).
  2. # This copyright was auto-generated on Fri Jun 9 22:45:24 UTC 2023
  3. ARG ALPINE_VERSION=3.16
  4. ##### Building stage #####
  5. FROM alpine:${ALPINE_VERSION} as builder
  6. # Versions of nginx, rtmp-module and ffmpeg
  7. ARG NGINX_VERSION=1.23.0
  8. ARG NGINX_RTMP_MODULE_VERSION=1.2.2
  9. ARG FFMPEG_VERSION=5.1
  10. # Install dependencies
  11. RUN apk update && \
  12. apk --no-cache add \
  13. bash build-base ca-certificates \
  14. openssl openssl-dev make \
  15. gcc libgcc libc-dev rtmpdump-dev \
  16. zlib-dev musl-dev pcre pcre-dev lame-dev \
  17. yasm pkgconf pkgconfig libtheora-dev \
  18. libvorbis-dev libvpx-dev freetype-dev \
  19. x264-dev x265-dev && \
  20. rm -rf /var/lib/apt/lists/*
  21. # Download nginx source
  22. RUN mkdir -p /tmp/build && \
  23. cd /tmp/build && \
  24. wget https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz && \
  25. tar zxf nginx-${NGINX_VERSION}.tar.gz && \
  26. rm nginx-${NGINX_VERSION}.tar.gz
  27. # Download rtmp-module source
  28. RUN cd /tmp/build && \
  29. wget https://github.com/arut/nginx-rtmp-module/archive/v${NGINX_RTMP_MODULE_VERSION}.tar.gz && \
  30. tar zxf v${NGINX_RTMP_MODULE_VERSION}.tar.gz && \
  31. rm v${NGINX_RTMP_MODULE_VERSION}.tar.gz
  32. # Build nginx with nginx-rtmp module
  33. RUN cd /tmp/build/nginx-${NGINX_VERSION} && \
  34. ./configure \
  35. --sbin-path=/usr/local/sbin/nginx \
  36. --conf-path=/etc/nginx/nginx.conf \
  37. --error-log-path=/var/log/nginx/error.log \
  38. --http-log-path=/var/log/nginx/access.log \
  39. --pid-path=/var/run/nginx/nginx.pid \
  40. --lock-path=/var/lock/nginx.lock \
  41. --http-client-body-temp-path=/tmp/nginx-client-body \
  42. --with-http_ssl_module \
  43. --with-stream \
  44. --with-stream_ssl_module \
  45. --with-threads \
  46. --add-module=/tmp/build/nginx-rtmp-module-${NGINX_RTMP_MODULE_VERSION} && \
  47. make CFLAGS=-Wno-error -j $(getconf _NPROCESSORS_ONLN) && \
  48. make install
  49. # Download ffmpeg source
  50. RUN cd /tmp/build && \
  51. wget http://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.gz && \
  52. tar zxf ffmpeg-${FFMPEG_VERSION}.tar.gz && \
  53. rm ffmpeg-${FFMPEG_VERSION}.tar.gz
  54. # Build ffmpeg
  55. RUN cd /tmp/build/ffmpeg-${FFMPEG_VERSION} && \
  56. ./configure \
  57. --enable-version3 \
  58. --enable-gpl \
  59. --enable-small \
  60. --enable-libx264 \
  61. --enable-libx265 \
  62. --enable-libvpx \
  63. --enable-libtheora \
  64. --enable-libvorbis \
  65. --enable-librtmp \
  66. --enable-postproc \
  67. --enable-swresample \
  68. --enable-libfreetype \
  69. --enable-libmp3lame \
  70. --disable-debug \
  71. --disable-doc \
  72. --disable-ffplay \
  73. --extra-libs="-lpthread -lm" && \
  74. make -j $(getconf _NPROCESSORS_ONLN) && \
  75. make install
  76. # Copy stats.xsl file to nginx html directory and clean build files
  77. RUN cp /tmp/build/nginx-rtmp-module-${NGINX_RTMP_MODULE_VERSION}/stat.xsl /usr/local/nginx/html/stat.xsl && \
  78. rm -rf /tmp/build
  79. ##### Building the final image #####
  80. FROM alpine:${ALPINE_VERSION}
  81. # Install dependencies
  82. RUN apk update && \
  83. apk --no-cache add \
  84. bash ca-certificates openssl \
  85. pcre libtheora libvorbis lame libvpx \
  86. librtmp x264-dev x265-dev freetype htop && \
  87. rm -rf /var/lib/apt/lists/*
  88. # Copy files from build stage to final stage
  89. COPY --from=builder /usr/local /usr/local
  90. COPY --from=builder /etc/nginx /etc/nginx
  91. COPY --from=builder /var/log/nginx /var/log/nginx
  92. COPY --from=builder /var/lock /var/lock
  93. COPY --from=builder /var/run/nginx /var/run/nginx
  94. # Forward logs to Docker
  95. RUN ln -sf /dev/stdout /var/log/nginx/access.log && \
  96. ln -sf /dev/stderr /var/log/nginx/error.log
  97. COPY ./hls.html /usr/local/nginx/html/player.html
  98. COPY ./nginx.conf /etc/nginx/nginx.conf
  99. COPY ./cert_request.ext /cert_request.ext
  100. COPY ./cert_request.ini /cert_request.ini
  101. # Copy run script to container
  102. COPY entrypoint.sh /entrypoint.sh
  103. CMD ["bash", "/entrypoint.sh"]