Dockerfile 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. # build container
  2. FROM debian:bookworm-slim AS build
  3. # install build dependencies
  4. RUN apt-get update && \
  5. apt-get upgrade -y && \
  6. apt-get install -y --no-install-recommends \
  7. build-essential \
  8. cmake \
  9. libmp3lame-dev \
  10. libshout3-dev \
  11. libconfig++-dev \
  12. libfftw3-dev \
  13. libsoapysdr-dev \
  14. libpulse-dev \
  15. \
  16. git \
  17. ca-certificates \
  18. libusb-1.0-0-dev \
  19. debhelper \
  20. pkg-config \
  21. && \
  22. apt-get clean && \
  23. rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
  24. # set working dir for compiling dependencies
  25. WORKDIR /build_dependencies
  26. # compile / install rtl-sdr-blog version of rtl-sdr for v4 support
  27. RUN git clone https://github.com/rtlsdrblog/rtl-sdr-blog && \
  28. cd rtl-sdr-blog/ && \
  29. dpkg-buildpackage -b --no-sign && \
  30. cd .. && \
  31. dpkg -i librtlsdr0_*.deb && \
  32. dpkg -i librtlsdr-dev_*.deb && \
  33. dpkg -i rtl-sdr_*.deb
  34. # compile / install libmirisdr-4
  35. RUN git clone https://github.com/f4exb/libmirisdr-4 && \
  36. cd libmirisdr-4 && \
  37. mkdir build && \
  38. cd build && \
  39. cmake ../ && \
  40. VERBOSE=1 make install && \
  41. ldconfig
  42. # TODO: build anything from source?
  43. # set working dir for project build
  44. WORKDIR /rtl_airband_build
  45. # copy in the rtl_airband source
  46. # WARNING: not copying in the whole repo, this may need to be updated if build files are added outside of src/
  47. COPY ./.git/ .git/
  48. COPY ./src/ src/
  49. COPY ./scripts/ scripts/
  50. COPY ./CMakeLists.txt .
  51. # configure and build
  52. # TODO: detect platforms
  53. RUN uname -m && \
  54. echo | gcc -### -v -E - | tee compiler_native_info.txt && \
  55. cmake -B build_dir -DPLATFORM=generic -DCMAKE_BUILD_TYPE=Release -DNFM=TRUE -DBUILD_UNITTESTS=TRUE && \
  56. VERBOSE=1 cmake --build build_dir -j4
  57. # make sure unit tests pass
  58. RUN ./build_dir/src/unittests
  59. # application container
  60. FROM debian:bookworm-slim
  61. # install runtime dependencies
  62. RUN apt-get update && \
  63. apt-get upgrade -y && \
  64. apt-get install -y --no-install-recommends \
  65. tini \
  66. libc6 \
  67. libmp3lame0 \
  68. libshout3 \
  69. libconfig++9v5 \
  70. libfftw3-single3 \
  71. libsoapysdr0.8 \
  72. libpulse0 \
  73. libusb-1.0-0-dev \
  74. && \
  75. apt-get clean && \
  76. rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
  77. # install (from build container) rtl-sdr-blog version of rtl-sdr for v4 support
  78. COPY --from=build /build_dependencies/librtlsdr0_*.deb /build_dependencies/librtlsdr-dev_*.deb /build_dependencies/rtl-sdr_*.deb /tmp/
  79. RUN dpkg -i /tmp/librtlsdr0_*.deb && \
  80. dpkg -i /tmp/librtlsdr-dev_*.deb && \
  81. dpkg -i /tmp/rtl-sdr_*.deb && \
  82. rm -rf /tmp/*.deb && \
  83. echo '' | tee --append /etc/modprobe.d/rtl_sdr.conf && \
  84. echo 'blacklist dvb_usb_rtl28xxun' | tee --append /etc/modprobe.d/rtl_sdr.conf && \
  85. echo 'blacklist rtl2832' | tee --append /etc/modprobe.d/rtl_sdr.conf && \
  86. echo 'blacklist rtl2830' | tee --append /etc/modprobe.d/rtl_sdr.conf
  87. # copy (from build container) libmirisdr-4 library
  88. COPY --from=build /usr/local/lib/libmirisdr.so.4 /usr/local/lib/
  89. # Copy rtl_airband from the build container
  90. COPY LICENSE /app/
  91. COPY --from=build /rtl_airband_build/build_dir/src/unittests /app/
  92. COPY --from=build /rtl_airband_build/build_dir/src/rtl_airband /app/
  93. RUN chmod a+x /app/unittests /app/rtl_airband
  94. # make sure unit tests pass
  95. RUN /app/unittests
  96. # Use tini as init and run rtl_airband from /app/
  97. ENTRYPOINT ["/usr/bin/tini", "--"]
  98. WORKDIR /app/
  99. CMD ["/app/rtl_airband", "-F", "-e", "-c", "/app/rtl_airband.conf"]