Dockerfile-orgin-backup 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. ARG NGINX_VERSION=1.23.1
  2. ARG NGINX_RTMP_VERSION=1.2.2
  3. ARG FFMPEG_VERSION=5.1
  4. ##############################
  5. # Build the NGINX-build image.
  6. FROM alpine:3.16.1 as build-nginx
  7. ARG NGINX_VERSION
  8. ARG NGINX_RTMP_VERSION
  9. ARG MAKEFLAGS="-j4"
  10. # Build dependencies.
  11. RUN apk add --no-cache \
  12. build-base \
  13. ca-certificates \
  14. curl \
  15. gcc \
  16. libc-dev \
  17. libgcc \
  18. linux-headers \
  19. make \
  20. musl-dev \
  21. openssl \
  22. openssl-dev \
  23. pcre \
  24. pcre-dev \
  25. pkgconf \
  26. pkgconfig \
  27. zlib-dev
  28. WORKDIR /tmp
  29. # Get nginx source.
  30. RUN wget https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz && \
  31. tar zxf nginx-${NGINX_VERSION}.tar.gz && \
  32. rm nginx-${NGINX_VERSION}.tar.gz
  33. # Get nginx-rtmp module.
  34. RUN wget https://github.com/arut/nginx-rtmp-module/archive/v${NGINX_RTMP_VERSION}.tar.gz && \
  35. tar zxf v${NGINX_RTMP_VERSION}.tar.gz && \
  36. rm v${NGINX_RTMP_VERSION}.tar.gz
  37. # Compile nginx with nginx-rtmp module.
  38. WORKDIR /tmp/nginx-${NGINX_VERSION}
  39. RUN \
  40. ./configure \
  41. --prefix=/usr/local/nginx \
  42. --add-module=/tmp/nginx-rtmp-module-${NGINX_RTMP_VERSION} \
  43. --conf-path=/etc/nginx/nginx.conf \
  44. --with-threads \
  45. --with-file-aio \
  46. --with-http_ssl_module \
  47. --with-debug \
  48. --with-http_stub_status_module \
  49. --with-cc-opt="-Wimplicit-fallthrough=0" && \
  50. make && \
  51. make install
  52. ###############################
  53. # Build the FFmpeg-build image.
  54. FROM alpine:3.16.1 as build-ffmpeg
  55. ARG FFMPEG_VERSION
  56. ARG PREFIX=/usr/local
  57. ARG MAKEFLAGS="-j4"
  58. # FFmpeg build dependencies.
  59. RUN apk add --no-cache \
  60. build-base \
  61. coreutils \
  62. freetype-dev \
  63. lame-dev \
  64. libogg-dev \
  65. libass \
  66. libass-dev \
  67. libvpx-dev \
  68. libvorbis-dev \
  69. libwebp-dev \
  70. libtheora-dev \
  71. openssl-dev \
  72. opus-dev \
  73. pkgconf \
  74. pkgconfig \
  75. rtmpdump-dev \
  76. wget \
  77. x264-dev \
  78. x265-dev \
  79. yasm
  80. RUN echo http://dl-cdn.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories
  81. RUN apk add --no-cache fdk-aac-dev
  82. WORKDIR /tmp
  83. # Get FFmpeg source.
  84. RUN wget http://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.gz && \
  85. tar zxf ffmpeg-${FFMPEG_VERSION}.tar.gz && \
  86. rm ffmpeg-${FFMPEG_VERSION}.tar.gz
  87. # Compile ffmpeg.
  88. WORKDIR /tmp/ffmpeg-${FFMPEG_VERSION}
  89. RUN \
  90. ./configure \
  91. --prefix=${PREFIX} \
  92. --enable-version3 \
  93. --enable-gpl \
  94. --enable-nonfree \
  95. --enable-small \
  96. --enable-libmp3lame \
  97. --enable-libx264 \
  98. --enable-libx265 \
  99. --enable-libvpx \
  100. --enable-libtheora \
  101. --enable-libvorbis \
  102. --enable-libopus \
  103. --enable-libfdk-aac \
  104. --enable-libass \
  105. --enable-libwebp \
  106. --enable-postproc \
  107. --enable-libfreetype \
  108. --enable-openssl \
  109. --disable-debug \
  110. --disable-doc \
  111. --disable-ffplay \
  112. --extra-libs="-lpthread -lm" && \
  113. make && \
  114. make install && \
  115. make distclean
  116. # Cleanup.
  117. RUN rm -rf /var/cache/* /tmp/*
  118. ##########################
  119. # Build the release image.
  120. FROM alpine:3.16.1
  121. LABEL MAINTAINER Alfred Gutierrez <alf.g.jr@gmail.com>
  122. # Set default ports.
  123. ENV HTTP_PORT 80
  124. ENV HTTPS_PORT 443
  125. ENV RTMP_PORT 1935
  126. RUN apk add --no-cache \
  127. ca-certificates \
  128. gettext \
  129. openssl \
  130. pcre \
  131. lame \
  132. libogg \
  133. curl \
  134. libass \
  135. libvpx \
  136. libvorbis \
  137. libwebp \
  138. libtheora \
  139. opus \
  140. rtmpdump \
  141. x264-dev \
  142. x265-dev
  143. COPY --from=build-nginx /usr/local/nginx /usr/local/nginx
  144. COPY --from=build-nginx /etc/nginx /etc/nginx
  145. COPY --from=build-ffmpeg /usr/local /usr/local
  146. COPY --from=build-ffmpeg /usr/lib/libfdk-aac.so.2 /usr/lib/libfdk-aac.so.2
  147. # Add NGINX path, config and static files.
  148. ENV PATH "${PATH}:/usr/local/nginx/sbin"
  149. COPY nginx.conf /etc/nginx/nginx.conf.template
  150. RUN mkdir -p /opt/data && mkdir /www
  151. COPY static /www/static
  152. EXPOSE 1935
  153. EXPOSE 80
  154. CMD envsubst "$(env | sed -e 's/=.*//' -e 's/^/\$/g')" < \
  155. /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf && \
  156. nginx