Skip to content

Commit

Permalink
Merge pull request #934 from projecthorus/testing
Browse files Browse the repository at this point in the history
auto_rx 1.8.0 release - Full ka9q-radio support!
  • Loading branch information
darksidelemm authored Dec 15, 2024
2 parents 757925e + eba2a08 commit 35d9515
Show file tree
Hide file tree
Showing 47 changed files with 1,399 additions and 590 deletions.
5 changes: 0 additions & 5 deletions .devcontainer.json

This file was deleted.

137 changes: 110 additions & 27 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
@@ -1,59 +1,142 @@
name: Container Images
name: Container image

on:
push:
branches:
- 'master'
- 'testing'
tags:
- 'v*'
pull_request:
workflow_dispatch:
schedule:
- cron: '25 4 * * 3'

jobs:
main:
build:
name: Build container image
runs-on: ubuntu-latest
strategy:
matrix:
platform: [linux/amd64, linux/386, linux/arm64, linux/arm/v6, linux/arm/v7]
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Checkout repository
uses: actions/checkout@v4

- name: Calculate Container Metadata
id: meta
uses: docker/metadata-action@v4
- name: Declare platform
run: |
platform=${{ matrix.platform }}
echo "PLATFORM=${platform//\//-}" >> $GITHUB_ENV
- name: Cache wheels
uses: actions/cache@v4
with:
images: ghcr.io/${{ github.repository }}
path: ${{ github.workspace }}/wheels
key: wheels-${{ env.PLATFORM }}-${{ github.run_id }}
restore-keys: |
wheels-${{ env.PLATFORM }}-
- name: List wheels
run: ls -lR ${{ github.workspace }}/wheels || true

- name: Setup QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3

- name: Setup Buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build Images
if: ${{ github.event_name == 'pull_request' }}
uses: docker/build-push-action@v3
- name: Calculate container metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}

- name: Build stage
id: build
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64, linux/386, linux/arm64, linux/arm/v6, linux/arm/v7
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}:buildcache
tags: ${{ steps.meta.outputs.tags }}
platforms: ${{ matrix.platform }}
provenance: false
labels: ${{ steps.meta.outputs.labels }}

- name: Build and Push Images
if: ${{ github.event_name != 'pull_request' }}
uses: docker/build-push-action@v3
outputs: type=local,dest=/tmp/build-output
cache-to: type=local,dest=/tmp/build-cache,mode=max
target: build

- name: Final stage and push by digest
id: final
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64, linux/386, linux/arm64, linux/arm/v6, linux/arm/v7
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}:buildcache
cache-to: type=registry,ref=ghcr.io/${{ github.repository }}:buildcache,mode=max
push: true
tags: ${{ steps.meta.outputs.tags }}
platforms: ${{ matrix.platform }}
provenance: false
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=ghcr.io/${{ github.repository }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' && 'true' || 'false' }}
cache-from: type=local,src=/tmp/build-cache

- name: Export digest
if: ${{ github.event_name != 'pull_request' }}
run: |
mkdir -p /tmp/digests
digest="${{ steps.final.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
if: ${{ github.event_name != 'pull_request' }}
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

- name: Move and list wheels
run: |
mv -f /tmp/build-output/root/.cache/pip/wheels ${{ github.workspace }}/ || true
ls -lR ${{ github.workspace }}/wheels || true
merge:
name: Publish multi-platform image
if: ${{ github.event_name != 'pull_request' }}
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true

- name: Calculate container metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}

- name: Setup Buildx
uses: docker/setup-buildx-action@v2

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create and push manifest
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf 'ghcr.io/${{ github.repository }}@sha256:%s ' *)
- name: Inspect container image
run: |
docker buildx imagetools inspect ghcr.io/${{ github.repository }}:${{ steps.meta.outputs.version }}
49 changes: 44 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,47 @@
# -------------------
# The build container
# -------------------
FROM debian:bullseye-slim AS build
FROM debian:bookworm-slim AS build

# Upgrade base packages.
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
autoconf \
automake \
build-essential \
cmake \
git \
libatlas-base-dev \
libsamplerate0-dev \
libusb-1.0-0-dev \
ninja-build \
pkg-config \
python3 \
python3-dev \
python3-pip \
python3-setuptools \
python3-wheel && \
python3-wheel \
libavahi-client-dev \
libbsd-dev \
libfftw3-dev \
libiniparser-dev \
libopus-dev && \
rm -rf /var/lib/apt/lists/*

# Copy in existing wheels.
COPY wheel[s]/ /root/.cache/pip/wheels/

# No wheels might exist.
RUN mkdir -p /root/.cache/pip/wheels/

# Copy in requirements.txt.
COPY auto_rx/requirements.txt \
/root/radiosonde_auto_rx/auto_rx/requirements.txt

# Install Python packages.
RUN --mount=type=cache,target=/root/.cache/pip pip3 install \
--user --no-warn-script-location --ignore-installed --no-binary numpy \
RUN pip3 install \
--user --break-system-packages --no-warn-script-location --ignore-installed \
-r /root/radiosonde_auto_rx/auto_rx/requirements.txt

# Compile rtl-sdr from source.
Expand All @@ -44,6 +58,15 @@ RUN git clone https://github.com/miweber67/spyserver_client.git /root/spyserver_
cd /root/spyserver_client && \
make

# Compile ka9q-radio from source
RUN git clone https://github.com/ka9q/ka9q-radio.git /root/ka9q-radio && \
cd /root/ka9q-radio && \
git checkout ff7fe26a12909317b26bdb24a0576db87c15baf2 && \
make \
-f Makefile.linux \
"COPTS=-std=gnu11 -pthread -Wall -funsafe-math-optimizations -fno-math-errno -fcx-limited-range -D_GNU_SOURCE=1" \
tune powers pcmcat

# Copy in radiosonde_auto_rx.
COPY . /root/radiosonde_auto_rx

Expand All @@ -54,7 +77,7 @@ RUN /bin/sh build.sh
# -------------------------
# The application container
# -------------------------
FROM debian:bullseye-slim
FROM debian:bookworm-slim

EXPOSE 5000/tcp

Expand All @@ -69,6 +92,10 @@ RUN apt-get update && \
rng-tools \
sox \
tini \
libbsd0 \
avahi-utils \
libnss-mdns \
avahi-utils \
usbutils && \
rm -rf /var/lib/apt/lists/*

Expand All @@ -88,6 +115,18 @@ COPY --from=build /root/spyserver_client/ss_client /opt/auto_rx/
RUN ln -s ss_client /opt/auto_rx/ss_iq && \
ln -s ss_client /opt/auto_rx/ss_power

# Copy ka9q-radio utilities
COPY --from=build /root/ka9q-radio/tune /usr/local/bin/
COPY --from=build /root/ka9q-radio/powers /usr/local/bin/
COPY --from=build /root/ka9q-radio/pcmcat /usr/local/bin/

# Allow mDNS resolution for ka9q-radio utilities
RUN sed -i -e 's/files dns/files mdns4_minimal [NOTFOUND=return] dns/g' /etc/nsswitch.conf

# NOTE: These volume flags must be set for avahi to talk to the local host:
# -v /var/run/dbus:/var/run/dbus
# -v /var/run/avahi-daemon/socket:/var/run/avahi-daemon/socket

# Set the working directory.
WORKDIR /opt/auto_rx

Expand Down
20 changes: 17 additions & 3 deletions auto_rx/auto_rx.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,6 @@ def email_error(message="foo"):
else:
logging.debug("Not sending Email notification, as Email not configured.")


def main():
"""Main Loop"""
global config, exporter_objects, exporter_functions, logging_level, rs92_ephemeris, gpsd_adaptor, email_exporter
Expand Down Expand Up @@ -971,18 +970,30 @@ def main():

# OziExplorer
if config["ozi_enabled"] or config["payload_summary_enabled"]:
if config["ozi_enabled"]:
if config["ozi_host"]:
_ozi_host = config["ozi_host"]
else:
_ozi_host = None

if config["ozi_enabled"]: # Causes port to be set to None which disables the export.
_ozi_port = config["ozi_port"]
else:
_ozi_port = None

if config["payload_summary_enabled"]:
if config["payload_summary_host"]:
_summary_host = config["payload_summary_host"]
else:
_summary_host = None

if config["payload_summary_enabled"]: # Causes port to be set to None which disables the export.
_summary_port = config["payload_summary_port"]
else:
_summary_port = None

_ozimux = OziUploader(
ozimux_host=_ozi_host,
ozimux_port=_ozi_port,
payload_summary_host=_summary_host,
payload_summary_port=_summary_port,
update_rate=config["ozi_update_rate"],
station=config["habitat_uploader_callsign"],
Expand All @@ -1009,11 +1020,14 @@ def main():
config["rotator_home_azimuth"],
config["rotator_home_elevation"],
],
azimuth_only=config["rotator_azimuth_only"]
)

exporter_objects.append(_rotator)
exporter_functions.append(_rotator.add)

autorx.rotator_object = _rotator

# Sondehub v2 Database
if config["sondehub_enabled"]:
if config["habitat_upload_listener_position"] is False:
Expand Down
5 changes: 4 additions & 1 deletion auto_rx/autorx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# MINOR - New sonde type support, other fairly big changes that may result in telemetry or config file incompatability issus.
# PATCH - Small changes, or minor feature additions.

__version__ = "1.7.4"
__version__ = "1.8.0"

# Global Variables

Expand Down Expand Up @@ -44,5 +44,8 @@
# Global scan inhibit flag, used by web interface.
scan_inhibit = False

# Rotator object
rotator_object = None

# Logging Directory
logging_path = "./log/"
Loading

0 comments on commit 35d9515

Please sign in to comment.