2
0

Dockerfile 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. ARG ARCH
  2. ARG IMAGE=ossrs/srs:ubuntu20
  3. FROM ${ARCH}${IMAGE} AS build
  4. ARG CONFARGS
  5. ARG MAKEARGS
  6. ARG INSTALLDEPENDS
  7. ARG BUILDPLATFORM
  8. ARG TARGETPLATFORM
  9. ARG SRS_AUTO_PACKAGER
  10. RUN echo "BUILDPLATFORM: $BUILDPLATFORM, TARGETPLATFORM: $TARGETPLATFORM, PACKAGER: ${#SRS_AUTO_PACKAGER}, CONFARGS: ${CONFARGS}, MAKEARGS: ${MAKEARGS}, INSTALLDEPENDS: ${INSTALLDEPENDS}"
  11. # https://serverfault.com/questions/949991/how-to-install-tzdata-on-a-ubuntu-docker-image
  12. ENV DEBIAN_FRONTEND=noninteractive
  13. # To use if in RUN, see https://github.com/moby/moby/issues/7281#issuecomment-389440503
  14. # Note that only exists issue like "/bin/sh: 1: [[: not found" for Ubuntu20, no such problem in CentOS7.
  15. SHELL ["/bin/bash", "-c"]
  16. # Install depends tools.
  17. RUN if [[ $INSTALLDEPENDS != 'NO' ]]; then \
  18. apt-get update && apt-get install -y gcc make g++ patch unzip perl git libasan5; \
  19. fi
  20. # Copy source code to docker.
  21. COPY . /srs
  22. WORKDIR /srs/trunk
  23. # Build and install SRS.
  24. # Note that SRT is enabled by default, so we configure without --srt=on.
  25. # Note that we have copied all files by make install.
  26. RUN ./configure ${CONFARGS} && make ${MAKEARGS} && make install
  27. ############################################################
  28. # dist
  29. ############################################################
  30. FROM ${ARCH}ubuntu:focal AS dist
  31. ARG BUILDPLATFORM
  32. ARG TARGETPLATFORM
  33. RUN echo "BUILDPLATFORM: $BUILDPLATFORM, TARGETPLATFORM: $TARGETPLATFORM"
  34. # Expose ports for streaming @see https://github.com/ossrs/srs#ports
  35. EXPOSE 1935 1985 8080 5060 9000 8000/udp 10080/udp
  36. # FFMPEG 4.1
  37. COPY --from=build /usr/local/bin/ffmpeg /usr/local/srs/objs/ffmpeg/bin/ffmpeg
  38. # SRS binary, config files and srs-console.
  39. COPY --from=build /usr/local/srs /usr/local/srs
  40. # Test the version of binaries.
  41. RUN ldd /usr/local/srs/objs/ffmpeg/bin/ffmpeg && \
  42. /usr/local/srs/objs/ffmpeg/bin/ffmpeg -version && \
  43. ldd /usr/local/srs/objs/srs && \
  44. /usr/local/srs/objs/srs -v
  45. # Default workdir and command.
  46. WORKDIR /usr/local/srs
  47. ENV SRS_DAEMON=off SRS_IN_DOCKER=on
  48. CMD ["./objs/srs", "-c", "conf/docker.conf"]