diff --git a/Dockerfile b/Dockerfile index 244d00cb7..373e8420c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,16 @@ -FROM ubuntu:22.04 AS base +FROM ubuntu:22.04 AS builder # Install docker for passing the socket to allow for intercontainer exec RUN apt-get update && \ apt-get -y upgrade &&\ export DEBIAN_FRONTEND=noninteractive && \ - apt-get install -y \ - apt-transport-https \ + apt-get install --no-install-recommends -y \ build-essential \ ca-certificates \ cmake \ curl \ - docker.io \ - fdkaac \ git \ - gnupg \ - gnuradio \ gnuradio-dev \ - gr-funcube \ - gr-iqbal \ libairspy-dev \ libairspyhf-dev \ libbladerf-dev \ @@ -29,22 +22,33 @@ RUN apt-get update && \ libmirisdr-dev \ liborc-0.4-dev \ libpthread-stubs0-dev \ - librtlsdr-dev \ libsndfile1-dev \ libsoapysdr-dev \ libssl-dev \ libuhd-dev \ libusb-dev \ + libusb-1.0-0-dev \ libxtrx-dev \ pkg-config \ - software-properties-common \ - sox \ - wget && \ - rm -rf /var/lib/apt/lists/* + wget \ + python3-six -# Fix the error message level for SmartNet - -RUN sed -i 's/log_level = debug/log_level = info/g' /etc/gnuradio/conf.d/gnuradio-runtime.conf +# Compile librtlsdr-dev 2.0 for SDR-Blog v4 support and other updates +# Ubuntu 22.04 LTS has librtlsdr 0.6.0 +RUN cd /tmp && \ + git clone https://github.com/steve-m/librtlsdr.git && \ + cd librtlsdr && \ + mkdir build && \ + cd build && \ + cmake .. && \ + make -j$(nproc) && \ + make install && \ + # We need to install both in / and /newroot to use in this image + # and to copy over to the final image + make DESTDIR=/newroot install && \ + ldconfig && \ + cd /tmp && \ + rm -rf librtlsdr # Compile gr-osmosdr ourselves using a fork with various patches included RUN cd /tmp && \ @@ -55,23 +59,37 @@ RUN cd /tmp && \ cmake -DENABLE_NONFREE=TRUE .. && \ make -j$(nproc) && \ make install && \ + # We need to install both in / and /newroot to use in this image + # and to copy over to the final image + make DESTDIR=/newroot install && \ ldconfig && \ cd /tmp && \ rm -rf gr-osmosdr + WORKDIR /src COPY . . WORKDIR /src/build -RUN cmake .. && make -j$(nproc) && make install +RUN cmake .. && make -j$(nproc) && make DESTDIR=/newroot install -#USER nobody +#Stage 2 build +FROM ubuntu:22.04 +RUN apt-get update && apt-get install --no-install-recommends -y ca-certificates gr-funcube gr-iqbal curl wget rsync libboost-log1.74.0 \ + libboost-chrono1.74.0 libgnuradio-digital3.10.1 libgnuradio-analog3.10.1 libgnuradio-filter3.10.1 libgnuradio-network3.10.1 \ + libgnuradio-uhd3.10.1 libsoapysdr0.8 soapysdr0.8-module-all libairspyhf1 libfreesrp0 libxtrx0 sox fdkaac docker.io && \ + rm -rf /var/lib/apt/lists/* +COPY --from=builder /newroot / + +# Fix the error message level for SmartNet +RUN mkdir -p /etc/gnuradio/conf.d/ && echo 'log_level = info' >> /etc/gnuradio/conf.d/gnuradio-runtime.conf && ldconfig WORKDIR /app # GNURadio requires a place to store some files, can only be set via $HOME env var. ENV HOME=/tmp -CMD trunk-recorder --config=/app/config.json +#USER nobody +CMD ["trunk-recorder", "--config=/app/config.json"] diff --git a/docs/Install/INSTALL-DOCKER.md b/docs/Install/INSTALL-DOCKER.md index 7b41f9b81..24e8c0150 100644 --- a/docs/Install/INSTALL-DOCKER.md +++ b/docs/Install/INSTALL-DOCKER.md @@ -10,9 +10,8 @@ To get started, create a directory and place your **config.json** file there and ```bash docker run -it \ - --privileged -e TZ=$(cat /etc/timezone) --user "$(id -u):$(id -g)" \ + --devices "/dev/bus/usb:/dev/bus/usb:rwm" -e TZ=$(cat /etc/timezone) --user "$(id -u):$(id -g)" \ -v $(pwd):/app \ - -v /dev/bus/usb:/dev/bus/usb \ -v /var/run/dbus:/var/run/dbus \ -v /var/run/avahi-daemon/socket:/var/run/avahi-daemon/socket \ robotastic/trunk-recorder:latest @@ -21,15 +20,14 @@ docker run -it \ To use it as part of a [Docker Compose](https://docs.docker.com/compose/) file: ```yaml -version: '3' services: recorder: image: robotastic/trunk-recorder:latest container_name: trunk-recorder restart: always - privileged: true + devices: + - "/dev/bus/usb:/dev/bus/usb:rwm" volumes: - - /dev/bus/usb:/dev/bus/usb - /var/run/dbus:/var/run/dbus - /var/run/avahi-daemon/socket:/var/run/avahi-daemon/socket - ./:/app diff --git a/utils/README.md b/utils/README.md index bbc882963..e92a2fd28 100644 --- a/utils/README.md +++ b/utils/README.md @@ -30,9 +30,9 @@ This maps in the current directory, so you can try building files from you local `docker run -v ${PWD}:/src -it tr-ubuntu /bin/bash` -`docker run --privileged --ulimit core=-1 -v ${PWD}:/src -v /dev/bus/usb:/dev/bus/usb -v /var/run/dbus:/var/run/dbus -v /var/run/avahi-daemon/socket:/var/run/avahi-daemon/socket -v /home/luke/trunk-recorder-docker:/app -it tr-arch-aur /bin/bash` +`docker run --devices "/dev/bus/usb:/dev/bus/usb:rwm" --ulimit core=-1 -v ${PWD}:/src -v /var/run/dbus:/var/run/dbus -v /var/run/avahi-daemon/socket:/var/run/avahi-daemon/socket -v /home/luke/trunk-recorder-docker:/app -it tr-arch-aur /bin/bash` -`docker run --privileged --ulimit core=-1 -v ${PWD}:/src -v /dev/bus/usb:/dev/bus/usb -v /var/run/dbus:/var/run/dbus -v /var/run/avahi-daemon/socket:/var/run/avahi-daemon/socket -v /home/luke/trunk-recorder-docker:/app -it tr-fedora /bin/bash` +`docker run --devices "/dev/bus/usb:/dev/bus/usb:rwm" --ulimit core=-1 -v ${PWD}:/src -v /var/run/dbus:/var/run/dbus -v /var/run/avahi-daemon/socket:/var/run/avahi-daemon/socket -v /home/luke/trunk-recorder-docker:/app -it tr-fedora /bin/bash` *On an M1 based Mac:* `docker run --platform=linux/amd64 -v ${PWD}:/src -it tr-arch /bin/bash` @@ -44,6 +44,6 @@ In the */utils* directory, run the following command to build the AUR package: `docker build -t tr-arch-aur --build-arg AUR_PACKAGE=trunk-recorder -f utils/Dockerfile.arch-latest-aur.dev .` In a directory with a config.json file you want to test, run this command. It will mirror your current directory to */app*. -`docker run --privileged --ulimit core=-1 -v ${PWD}:/app -v /dev/bus/usb:/dev/bus/usb -v /var/run/dbus:/var/run/dbus -v /var/run/avahi-daemon/socket:/var/run/avahi-daemon/socket -it tr-arch-aur /bin/bash` +`docker run --devices "/dev/bus/usb:/dev/bus/usb:rwm" --ulimit core=-1 -v ${PWD}:/app -v /var/run/dbus:/var/run/dbus -v /var/run/avahi-daemon/socket:/var/run/avahi-daemon/socket -it tr-arch-aur /bin/bash` If you want to capture a core dump: https://stackoverflow.com/questions/28335614/how-to-generate-core-file-in-docker-container