Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential docker enhancements & two-stage build #940

Merged
merged 4 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 38 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -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 && \
Expand All @@ -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"]
8 changes: 3 additions & 5 deletions docs/Install/INSTALL-DOCKER.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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
Loading