Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 76b9316

Browse files
committedJul 24, 2024
docker: Add official local docker support
Lets add our own docker container and use github actions to build and push it. For now, only the alpine container is built and pushed, but we can very easily add a matrix entry for a debian container if there's enough demand. Best to reduce the amount of configurations we offer, as it also means more that can break. Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
1 parent 75ad926 commit 76b9316

File tree

6 files changed

+183
-1
lines changed

6 files changed

+183
-1
lines changed
 

‎.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
examples/
+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Create and publish Container image
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
tags:
8+
- '[0-9]+.[0-9]+*'
9+
pull_request:
10+
branches:
11+
- master
12+
13+
env:
14+
REGISTRY: ghcr.io
15+
IMAGE_NAME: ${{ github.repository }}
16+
17+
jobs:
18+
build-and-push-image:
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
22+
packages: write
23+
strategy:
24+
matrix:
25+
include:
26+
- container: ./dist/Containerfile
27+
autotag: auto
28+
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 0
34+
35+
- name: Set up QEMU
36+
uses: docker/setup-qemu-action@v3
37+
38+
- name: Set up Docker Buildx
39+
uses: docker/setup-buildx-action@v3
40+
41+
- name: Login to Container registry
42+
uses: docker/login-action@v3
43+
with:
44+
registry: ${{ env.REGISTRY }}
45+
username: ${{ github.actor }}
46+
password: ${{ secrets.GITHUB_TOKEN }}
47+
48+
- name: Docker meta
49+
id: meta
50+
uses: docker/metadata-action@v5
51+
with:
52+
images: |
53+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
54+
tags: |
55+
type=ref,event=branch
56+
type=ref,event=pr
57+
type=edge
58+
type=semver,pattern={{version}}
59+
type=semver,pattern={{major}}.{{minor}}
60+
type=semver,pattern={{major}}
61+
flavor: |
62+
latest=${{ matrix.autotag }}
63+
suffix=${{ matrix.suffix }}
64+
65+
- name: Build and push
66+
uses: docker/build-push-action@v6
67+
with:
68+
platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7,linux/arm/v6
69+
context: .
70+
file: ${{ matrix.container }}
71+
push: ${{ github.event_name != 'pull_request' }}
72+
tags: ${{ steps.meta.outputs.tags }}
73+
labels: ${{ steps.meta.outputs.labels }}

‎README.md

+18-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,24 @@ On FreeBSD, `pkg install rtl-433`.
2525

2626
On MacOS, `brew install rtl_433`.
2727

28-
Docker images with rtl_433 are available [on the github page of hertzg](https://github.com/hertzg/rtl_433_docker).
28+
## Docker
29+
30+
Running the application through docker is easy with the offical docker image from this repository. Either use `latest` for the latest stable, a tagged version or `master` for the latest build from master. See https://github.com/merbanan/rtl_433/pkgs/container/rtl_433 for available releases.
31+
32+
```console
33+
$ docker run \
34+
--device '/dev/bus/usb:/dev/bus/usb' \
35+
--interactive \
36+
--rm \
37+
--tty \
38+
--volume '/path/for/dumps:/dumps' \
39+
--workdir '/dumps' \
40+
ghcr.io/merbanan/rtl_433/rtl_433:latest --help
41+
```
42+
43+
> __Note:__ The volume (and workdir) arguments are only needed to store (and load) dumps.
44+
45+
> __Warning:__ The `--privileged` flag might be needed instead of the `--device` flag in certain cases if the USB devices cannot be enumerated and accessed from within the container. Also the container could be run as the current user by using `--user "$(id -u):$(id -g)"`, but then care with user mapping and the use of udev rules is needed. This left as an exercise to the reader.
2946
3047
## How to add support for unsupported sensors
3148

‎dist/Containerfile

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# SPDX-License-Identifier: GPL-2.0-or-later
2+
#
3+
# Copyright (C) 2024 Olliver Schinagl <oliver@schinagl.nl>
4+
5+
ARG ALPINE_VERSION="latest"
6+
ARG TARGET_ARCH="library"
7+
8+
FROM docker.io/${TARGET_ARCH}/alpine:${ALPINE_VERSION} AS builder
9+
10+
WORKDIR /src
11+
12+
COPY . /src/
13+
14+
RUN apk add --no-cache \
15+
'build-base' \
16+
'cmake' \
17+
'git' \
18+
'librtlsdr-dev' \
19+
'libusb-dev' \
20+
'ninja' \
21+
'openssl-dev>3' \
22+
'soapy-sdr-dev' \
23+
&& \
24+
cmake -B '.build' -GNinja \
25+
-DFORCE_COLORED_BUILD:BOOL=ON \
26+
-DCMAKE_BUILD_TYPE=Release \
27+
-DCMAKE_INSTALL_PREFIX='/usr' \
28+
-DCMAKE_INSTALL_SYSCONFDIR='/etc' \
29+
-DENABLE_OPENSSL=ON \
30+
&& \
31+
cmake --build '.build' -j $(($(nproc) -1 )) && \
32+
DESTDIR='/rtl_433' cmake --build '.build' --target install && \
33+
rm -f -r '/rtl_433/include' && \
34+
rm -f -r '/rtl_433/usr/share'
35+
36+
FROM docker.io/${TARGET_ARCH}/alpine:${ALPINE_VERSION}
37+
38+
LABEL maintainer="Olliver Schinagl <oliver@schinagl.nl>"
39+
40+
RUN apk add --no-cache \
41+
'librtlsdr' \
42+
'libusb' \
43+
'openssl' \
44+
'soapy-sdr-libs' \
45+
'tini' \
46+
'tzdata' \
47+
;
48+
49+
COPY --from=builder "/rtl_433" "/"
50+
COPY "dist/container-entrypoint.sh" "/init"
51+
52+
ENTRYPOINT [ "/sbin/tini", "--", "/init" ]

‎dist/container-entrypoint.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
# SPDX-License-Identifier: GPL-2.0-or-later
3+
#
4+
# Copyright (C) 2024 Olliver Schinagl <oliver@schinagl.nl>
5+
#
6+
# A beginning user should be able to docker run image bash (or sh) without
7+
# needing to learn about --entrypoint
8+
# https://github.com/docker-library/official-images#consistency
9+
10+
set -eu
11+
if [ -n "${DEBUG_TRACE_SH:-}" ] && \
12+
[ "${DEBUG_TRACE_SH:-}" != "${DEBUG_TRACE_SH#*"$(basename "${0}")"*}" ] || \
13+
[ "${DEBUG_TRACE_SH:-}" = 'all' ]; then
14+
set -x
15+
fi
16+
17+
bin='rtl_433'
18+
19+
# Prefix args with $bin if $1 is not a valid command
20+
if ! command -v -- "${1:-}" > '/dev/null' 2>&1; then
21+
set -- "${bin:?}" "${@}"
22+
fi
23+
exec "${@}"
24+
25+
exit 0

‎docs/BUILDING.md

+14
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,20 @@ Purge all SoapySDR packages and source installation from /usr/local.
107107
Then install only from packages (version 0.7) or only from source (version 0.8).
108108
:::
109109

110+
## Docker
111+
112+
To build the container (and thus the application) from source:
113+
114+
```console
115+
$ docker build \
116+
--rm \
117+
--tag 'rtl_433:MR123' \
118+
--file dist/Containerfile \
119+
'./'
120+
```
121+
122+
and then can be run as above, with `rtl_433:MR123` as container name instead when running the container.
123+
110124
## Package maintainers
111125

112126
To properly configure builds without relying on automatic feature detection you should set all options explicitly, e.g.

0 commit comments

Comments
 (0)
Please sign in to comment.