From bc8c920e7f51c275066bae54a2bc3b4f8e44f92b Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Mon, 1 Jan 2024 10:56:05 -0700 Subject: [PATCH 01/32] first hack at running with bridge --- Dockerfile | 19 ++++++- README.md | 25 ++++----- .../dependencies.d/01-acarsdec | 0 .../dependencies.d/03-sdrplay-license | 0 .../s6-rc.d/{acars_stats => acars_bridge}/run | 0 .../{acars_feeder => acars_bridge}/type | 0 .../etc/s6-overlay/s6-rc.d/acars_feeder/run | 2 - .../dependencies.d/03-sdrplay-license | 0 .../etc/s6-overlay/s6-rc.d/acars_server/run | 2 - .../etc/s6-overlay/s6-rc.d/acars_server/type | 1 - .../acars_stats/dependencies.d/01-acarsdec | 0 .../dependencies.d/03-sdrplay-license | 0 .../etc/s6-overlay/s6-rc.d/acars_stats/type | 1 - .../contents.d/acars_bridge} | 0 .../s6-rc.d/user/contents.d/acars_feeder | 0 .../s6-rc.d/user/contents.d/acars_server | 0 .../s6-rc.d/user/contents.d/acars_stats | 0 rootfs/etc/s6-overlay/scripts/acars_bridge | 52 +++++++++++++++++++ rootfs/etc/s6-overlay/scripts/acars_feeder | 30 ----------- rootfs/etc/s6-overlay/scripts/acars_server | 8 --- rootfs/etc/s6-overlay/scripts/acars_stats | 45 ---------------- rootfs/etc/s6-overlay/scripts/acarsdec | 4 ++ 22 files changed, 86 insertions(+), 103 deletions(-) rename rootfs/etc/s6-overlay/s6-rc.d/{acars_feeder => acars_bridge}/dependencies.d/01-acarsdec (100%) rename rootfs/etc/s6-overlay/s6-rc.d/{acars_feeder => acars_bridge}/dependencies.d/03-sdrplay-license (100%) rename rootfs/etc/s6-overlay/s6-rc.d/{acars_stats => acars_bridge}/run (100%) rename rootfs/etc/s6-overlay/s6-rc.d/{acars_feeder => acars_bridge}/type (100%) delete mode 100755 rootfs/etc/s6-overlay/s6-rc.d/acars_feeder/run delete mode 100644 rootfs/etc/s6-overlay/s6-rc.d/acars_server/dependencies.d/03-sdrplay-license delete mode 100755 rootfs/etc/s6-overlay/s6-rc.d/acars_server/run delete mode 100644 rootfs/etc/s6-overlay/s6-rc.d/acars_server/type delete mode 100644 rootfs/etc/s6-overlay/s6-rc.d/acars_stats/dependencies.d/01-acarsdec delete mode 100644 rootfs/etc/s6-overlay/s6-rc.d/acars_stats/dependencies.d/03-sdrplay-license delete mode 100644 rootfs/etc/s6-overlay/s6-rc.d/acars_stats/type rename rootfs/etc/s6-overlay/s6-rc.d/{acars_server/dependencies.d/01-acarsdec => user/contents.d/acars_bridge} (100%) delete mode 100644 rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/acars_feeder delete mode 100644 rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/acars_server delete mode 100644 rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/acars_stats create mode 100755 rootfs/etc/s6-overlay/scripts/acars_bridge delete mode 100755 rootfs/etc/s6-overlay/scripts/acars_feeder delete mode 100755 rootfs/etc/s6-overlay/scripts/acars_server delete mode 100755 rootfs/etc/s6-overlay/scripts/acars_stats diff --git a/Dockerfile b/Dockerfile index b1663c5..82401bf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,15 @@ +#build acars-bridge +FROM rust:1.75.0 as builder +WORKDIR /tmp/acars-bridge +# hadolint ignore=DL3008,DL3003,SC1091 +RUN set -x && \ + apt-get update && \ + apt-get install -y --no-install-recommends libzmq3-dev + +RUN set -x && \ + git clone https://github.com/sdr-enthusiasts/acars-bridge.git . && \ + cargo build --release + FROM ghcr.io/sdr-enthusiasts/docker-baseimage:acars-decoder ENV DEVICE_INDEX="" \ @@ -9,8 +21,9 @@ ENV DEVICE_INDEX="" \ RTLMULT="160" \ SERIAL="" \ SOAPYSDR="" \ - SERVER="acarshub" \ - SERVER_PORT="5550" \ + OUTPUT_SERVER="acars_router" \ + OUTPUT_SERVER_PORT="5550" \ + OUTPUT_SERVER_MODE="udp" \ MODE="J" SHELL ["/bin/bash", "-o", "pipefail", "-c"] @@ -29,6 +42,7 @@ RUN set -x && \ TEMP_PACKAGES+=(wget) && \ TEMP_PACKAGES+=(libusb-1.0-0-dev) && \ KEPT_PACKAGES+=(libusb-1.0-0) && \ + KEPT_PACKAGES+=(libzmq5) && \ # install packages apt-get update && \ apt-get install -y --no-install-recommends \ @@ -124,6 +138,7 @@ RUN set -x && \ rm -rf /src/* /tmp/* /var/lib/apt/lists/* COPY rootfs/ / +COPY --from=builder /tmp/acars-bridge/target/release/acars-bridge /opt/acars-bridge # ENTRYPOINT [ "/init" ] diff --git a/README.md b/README.md index c071de9..c459627 100644 --- a/README.md +++ b/README.md @@ -52,18 +52,19 @@ services: ## Configuration options -| Variable | Description | Required | Default | -| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------ | -| `TZ` | Your timezone | No | UTC | -| `SOAPYSDR` | The SoapySDR device string that identifies your dongle. See below for supported soapy sdr types. | No | Blank | -| `FEED_ID` | Used by the decoder to insert a unique ID in to the output message | Yes | Blank | -| `FREQUENCIES` | Colon-separated list of frequencies, but to a maximum of 8, for the decoder to list to | Yes | Blank | -| `PPM` | Parts per million correction of the decoder | No | 0 | -| `GAIN` | The gain applied to the RTL-SDR dongle. Recommended to leave at the default autogain. To set manually, gain in in db (0 to 49.6; >52 and -10 will result in AGC; default is AGC) | No | `-10` for autogain | -| `SERVER` | The server where messages will be forwarded to. | No | Blank | -| `SERVER_PORT` | The port where the server will receive messages on. | No | `5550` | -| `MODE` | The output mode. `P` for planeplotter, `J` for JSON and `A` for acarsdec. | No | `J` | -| `QUIET_LOGS` | Mute log output to the bare minimum. Set to `false` to see all of the log messages. | No | `TRUE` | +| Variable | Description | Required | Default | +| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------ | +| `TZ` | Your timezone | No | UTC | +| `SOAPYSDR` | The SoapySDR device string that identifies your dongle. See below for supported soapy sdr types. | No | Blank | +| `FEED_ID` | Used by the decoder to insert a unique ID in to the output message | Yes | Blank | +| `FREQUENCIES` | Colon-separated list of frequencies, but to a maximum of 8, for the decoder to list to | Yes | Blank | +| `PPM` | Parts per million correction of the decoder | No | 0 | +| `GAIN` | The gain applied to the RTL-SDR dongle. Recommended to leave at the default autogain. To set manually, gain in in db (0 to 49.6; >52 and -10 will result in AGC; default is AGC) | No | `-10` for autogain | +| `SERVER` | The server where messages will be forwarded to. | No | Blank | +| `SERVER_PORT` | The port where the server will receive messages on. | No | `5550` | +| `MODE` | The output mode. `P` for planeplotter, `J` for JSON and `A` for acarsdec. | No | `J` | +| `QUIET_LOGS` | Mute log output to the bare minimum. Set to `false` to see all of the log messages. | No | `TRUE` | +| `ACARSDEC_COMMAND_EXTRA` | Additional arguments to pass to the decoder. | No | Blank | ## SoapySDR device string diff --git a/rootfs/etc/s6-overlay/s6-rc.d/acars_feeder/dependencies.d/01-acarsdec b/rootfs/etc/s6-overlay/s6-rc.d/acars_bridge/dependencies.d/01-acarsdec similarity index 100% rename from rootfs/etc/s6-overlay/s6-rc.d/acars_feeder/dependencies.d/01-acarsdec rename to rootfs/etc/s6-overlay/s6-rc.d/acars_bridge/dependencies.d/01-acarsdec diff --git a/rootfs/etc/s6-overlay/s6-rc.d/acars_feeder/dependencies.d/03-sdrplay-license b/rootfs/etc/s6-overlay/s6-rc.d/acars_bridge/dependencies.d/03-sdrplay-license similarity index 100% rename from rootfs/etc/s6-overlay/s6-rc.d/acars_feeder/dependencies.d/03-sdrplay-license rename to rootfs/etc/s6-overlay/s6-rc.d/acars_bridge/dependencies.d/03-sdrplay-license diff --git a/rootfs/etc/s6-overlay/s6-rc.d/acars_stats/run b/rootfs/etc/s6-overlay/s6-rc.d/acars_bridge/run similarity index 100% rename from rootfs/etc/s6-overlay/s6-rc.d/acars_stats/run rename to rootfs/etc/s6-overlay/s6-rc.d/acars_bridge/run diff --git a/rootfs/etc/s6-overlay/s6-rc.d/acars_feeder/type b/rootfs/etc/s6-overlay/s6-rc.d/acars_bridge/type similarity index 100% rename from rootfs/etc/s6-overlay/s6-rc.d/acars_feeder/type rename to rootfs/etc/s6-overlay/s6-rc.d/acars_bridge/type diff --git a/rootfs/etc/s6-overlay/s6-rc.d/acars_feeder/run b/rootfs/etc/s6-overlay/s6-rc.d/acars_feeder/run deleted file mode 100755 index 83de848..0000000 --- a/rootfs/etc/s6-overlay/s6-rc.d/acars_feeder/run +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exec /etc/s6-overlay/scripts/acars_feeder diff --git a/rootfs/etc/s6-overlay/s6-rc.d/acars_server/dependencies.d/03-sdrplay-license b/rootfs/etc/s6-overlay/s6-rc.d/acars_server/dependencies.d/03-sdrplay-license deleted file mode 100644 index e69de29..0000000 diff --git a/rootfs/etc/s6-overlay/s6-rc.d/acars_server/run b/rootfs/etc/s6-overlay/s6-rc.d/acars_server/run deleted file mode 100755 index 07118a0..0000000 --- a/rootfs/etc/s6-overlay/s6-rc.d/acars_server/run +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exec /etc/s6-overlay/scripts/acars_server diff --git a/rootfs/etc/s6-overlay/s6-rc.d/acars_server/type b/rootfs/etc/s6-overlay/s6-rc.d/acars_server/type deleted file mode 100644 index 5883cff..0000000 --- a/rootfs/etc/s6-overlay/s6-rc.d/acars_server/type +++ /dev/null @@ -1 +0,0 @@ -longrun diff --git a/rootfs/etc/s6-overlay/s6-rc.d/acars_stats/dependencies.d/01-acarsdec b/rootfs/etc/s6-overlay/s6-rc.d/acars_stats/dependencies.d/01-acarsdec deleted file mode 100644 index e69de29..0000000 diff --git a/rootfs/etc/s6-overlay/s6-rc.d/acars_stats/dependencies.d/03-sdrplay-license b/rootfs/etc/s6-overlay/s6-rc.d/acars_stats/dependencies.d/03-sdrplay-license deleted file mode 100644 index e69de29..0000000 diff --git a/rootfs/etc/s6-overlay/s6-rc.d/acars_stats/type b/rootfs/etc/s6-overlay/s6-rc.d/acars_stats/type deleted file mode 100644 index 5883cff..0000000 --- a/rootfs/etc/s6-overlay/s6-rc.d/acars_stats/type +++ /dev/null @@ -1 +0,0 @@ -longrun diff --git a/rootfs/etc/s6-overlay/s6-rc.d/acars_server/dependencies.d/01-acarsdec b/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/acars_bridge similarity index 100% rename from rootfs/etc/s6-overlay/s6-rc.d/acars_server/dependencies.d/01-acarsdec rename to rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/acars_bridge diff --git a/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/acars_feeder b/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/acars_feeder deleted file mode 100644 index e69de29..0000000 diff --git a/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/acars_server b/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/acars_server deleted file mode 100644 index e69de29..0000000 diff --git a/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/acars_stats b/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/acars_stats deleted file mode 100644 index e69de29..0000000 diff --git a/rootfs/etc/s6-overlay/scripts/acars_bridge b/rootfs/etc/s6-overlay/scripts/acars_bridge new file mode 100755 index 0000000..d2a2fa5 --- /dev/null +++ b/rootfs/etc/s6-overlay/scripts/acars_bridge @@ -0,0 +1,52 @@ +#!/command/with-contenv bash +# shellcheck shell=bash + +SCRIPT_NAME="$(basename "$0")" +SCRIPT_NAME="${SCRIPT_NAME%.*}" + +# shellcheck disable=SC2034 +s6wrap=(s6wrap --quiet --timestamps --prepend="$SCRIPT_NAME" --args) +SOURCE_PORT=5550 + +# lets see if legacy SERVER / SERVER_PORT are set + +if [[ -n "$SERVER" ]] || [[ -n "$SERVER_PORT" ]]; then + "${s6wrap[@]}" echo "[WARN] SERVER / SERVER_PORT are deprecated, please use OUTPUT_SERVER / OUTPUT_SERVER_PORT instead" + + if [[ -n "$SERVER" ]]; then + OUTPUT_SERVER="$SERVER" + fi + + if [[ -n "$SERVER_PORT" ]]; then + OUTPUT_SERVER_PORT="$SERVER_PORT" + fi +fi + +if [[ -z "$OUTPUT_SERVER_MODE" ]]; then + OUTPUT_SERVER_MODE="udp" +fi + +# detect legacy udp +if [[ "$OUTPUT_SERVER_MODE" == "udp" ]]; then + "${s6wrap[@]}" echo "[WARN] Using UDP mode to connect to $OUTPUT_SERVER:$OUTPUT_SERVER_PORT. Suggest switching to ZMQ Mode. Please see documentation for more information." +fi + +ACARS_BRIDGE_BIN="/opt/acars-bridge" +ACARS_BRIDGE_CMD=(--source-port "$SOURCE_PORT") +ACARS_BRIDGE_CMD=(--source-protocol "udp") +ACARS_BRIDGE_CMD+=(--source-host "127.0.0.1") + +if [[ -n "$OUTPUT_SERVER" ]]; then + ACARS_BRIDGE_CMD+=(--destination-host "$OUTPUT_SERVER") +fi + +if [[ -n "$OUTPUT_SERVER_PORT" ]]; then + ACARS_BRIDGE_CMD+=(--destination-port "$OUTPUT_SERVER_PORT") +fi + +if [[ -n "$OUTPUT_SERVER_MODE" ]]; then + ACARS_BRIDGE_CMD+=(--destination-protocol "$OUTPUT_SERVER_MODE") +fi + +"${s6wrap[@]}" echo "[INFO] Starting acars-bridge with command: $ACARS_BRIDGE_BIN ${ACARS_BRIDGE_CMD[*]}" +"${s6wrap[@]}" "$ACARS_BRIDGE_BIN" "${ACARS_BRIDGE_CMD[@]}" diff --git a/rootfs/etc/s6-overlay/scripts/acars_feeder b/rootfs/etc/s6-overlay/scripts/acars_feeder deleted file mode 100755 index 82a2442..0000000 --- a/rootfs/etc/s6-overlay/scripts/acars_feeder +++ /dev/null @@ -1,30 +0,0 @@ -#!/command/with-contenv bash -# shellcheck shell=bash - -SCRIPT_NAME="$(basename "$0")" -SCRIPT_NAME="${SCRIPT_NAME%.*}" - -# shellcheck disable=SC2034 -s6wrap=(s6wrap --quiet --timestamps --prepend="$SCRIPT_NAME" --args) - -# Require that acars_server is running -if ! netstat -an | grep -P '^\s*tcp\s+\d+\s+\d+\s+0\.0\.0\.0:15550\s+(?>\d{1,3}\.{0,1}){4}:\*\s+LISTEN\s*$' > /dev/null; then - sleep 1 - if [[ ! ${QUIET_LOGS,,} =~ true ]]; then - # shellcheck disable=SC2154 - "${s6wrap[@]}" echo "acars_server not running, exiting" - fi - exit -fi -set -e - -SERVER_ADDR="UDP:${SERVER}:${SERVER_PORT}" - -if [[ ! ${QUIET_LOGS,,} =~ true ]]; then - "${s6wrap[@]}" echo "Starting acars_feeder with ${SERVER_ADDR}" -fi - -# shellcheck disable=SC2016 -socat -d TCP:127.0.0.1:15550 "$SERVER_ADDR" - -sleep 5 diff --git a/rootfs/etc/s6-overlay/scripts/acars_server b/rootfs/etc/s6-overlay/scripts/acars_server deleted file mode 100755 index 2247c80..0000000 --- a/rootfs/etc/s6-overlay/scripts/acars_server +++ /dev/null @@ -1,8 +0,0 @@ -#!/command/with-contenv bash -#shellcheck shell=bash - -# Listens for the output of acarsdec (UDP), and makes it available for multiple processes at TCP port 15550 - -socat -u udp-listen:5550,fork stdout | ncat -4 --keep-open --listen 0.0.0.0 15550 - -sleep 5 diff --git a/rootfs/etc/s6-overlay/scripts/acars_stats b/rootfs/etc/s6-overlay/scripts/acars_stats deleted file mode 100755 index 5984690..0000000 --- a/rootfs/etc/s6-overlay/scripts/acars_stats +++ /dev/null @@ -1,45 +0,0 @@ -#!/command/with-contenv bash -#shellcheck shell=bash - -SCRIPT_NAME="$(basename "$0")" -SCRIPT_NAME="${SCRIPT_NAME%.*}" - -# shellcheck disable=SC2034 -s6wrap=(s6wrap --quiet --timestamps --prepend="$SCRIPT_NAME" --args) - -set -o pipefail - -# Require that acars_server is running -if ! netstat -an | grep -P '^\s*tcp\s+\d+\s+\d+\s+0\.0\.0\.0:15550\s+(?>\d{1,3}\.{0,1}){4}:\*\s+LISTEN\s*$' > /dev/null; then - sleep 1 - if [[ ! ${QUIET_LOGS,,} =~ true ]]; then - # shellcheck disable=SC2154 - "${s6wrap[@]}" echo "acars_server not running, exiting" - fi - exit -fi - -# Start our stats loop -while true; do - - # capture 5 mins of flows - timeout --foreground 300s socat -u TCP:127.0.0.1:15550 CREATE:/run/acars/acars.past5min.json - - # if the port isn't reachable, this file isn't created, either container is shutting down or acars_server isn't reachable - # in both cases let's exit, if this should still be running it will be restarted - if ! [[ -f /run/acars/acars.past5min.json ]]; then - exit - fi - - # shellcheck disable=SC2016 - "${s6wrap[@]}" echo "$(wc -l < /run/acars/acars.past5min.json) ACARS messages received in last 5 mins" - - # rotate files keeping last 2 hours - for i in {24..1}; do - mv "/run/acars/acars.$((i-1)).json" "/run/acars/acars.$i.json" > /dev/null 2>&1 || true - done - mv "/run/acars/acars.past5min.json" "/run/acars/acars.0.json" > /dev/null 2>&1 || true - -done - -sleep 5 diff --git a/rootfs/etc/s6-overlay/scripts/acarsdec b/rootfs/etc/s6-overlay/scripts/acarsdec index 1114d3d..3ff1f6d 100755 --- a/rootfs/etc/s6-overlay/scripts/acarsdec +++ b/rootfs/etc/s6-overlay/scripts/acarsdec @@ -69,6 +69,10 @@ if [ -n "${SOAPYSDR}" ]; then ACARS_CMD+=("-d" "$SOAPYSDR") fi +if [[ -n "$ACARSDEC_COMMAND_EXTRA" ]]; then + ACARS_CMD+=("$ACARSDEC_COMMAND_EXTRA") +fi + # shellcheck disable=SC2206 ACARS_CMD+=($FREQ_STRING) From 91725fb718d9fdd93b1d3da2a398c20bcad81014 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Mon, 1 Jan 2024 10:59:14 -0700 Subject: [PATCH 02/32] Update run --- rootfs/etc/s6-overlay/s6-rc.d/acars_bridge/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootfs/etc/s6-overlay/s6-rc.d/acars_bridge/run b/rootfs/etc/s6-overlay/s6-rc.d/acars_bridge/run index 5c4dc31..a600547 100755 --- a/rootfs/etc/s6-overlay/s6-rc.d/acars_bridge/run +++ b/rootfs/etc/s6-overlay/s6-rc.d/acars_bridge/run @@ -1,2 +1,2 @@ #!/bin/sh -exec /etc/s6-overlay/scripts/acars_stats +exec /etc/s6-overlay/scripts/acars_bridge From 4380486559509b6e3996c30187a28ece382ad27e Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Mon, 1 Jan 2024 11:02:19 -0700 Subject: [PATCH 03/32] Update acars_bridge --- rootfs/etc/s6-overlay/scripts/acars_bridge | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/rootfs/etc/s6-overlay/scripts/acars_bridge b/rootfs/etc/s6-overlay/scripts/acars_bridge index d2a2fa5..e1c7ef2 100755 --- a/rootfs/etc/s6-overlay/scripts/acars_bridge +++ b/rootfs/etc/s6-overlay/scripts/acars_bridge @@ -10,20 +10,14 @@ SOURCE_PORT=5550 # lets see if legacy SERVER / SERVER_PORT are set -if [[ -n "$SERVER" ]] || [[ -n "$SERVER_PORT" ]]; then - "${s6wrap[@]}" echo "[WARN] SERVER / SERVER_PORT are deprecated, please use OUTPUT_SERVER / OUTPUT_SERVER_PORT instead" - - if [[ -n "$SERVER" ]]; then - OUTPUT_SERVER="$SERVER" - fi - - if [[ -n "$SERVER_PORT" ]]; then - OUTPUT_SERVER_PORT="$SERVER_PORT" - fi +if [[ -n "$SERVER" ]]; then + "${s6wrap[@]}" echo "[WARN] SERVER is deprecated, please use OUTPUT_SERVER" + OUTPUT_SERVER="$SERVER" fi -if [[ -z "$OUTPUT_SERVER_MODE" ]]; then - OUTPUT_SERVER_MODE="udp" +if [[ -n "$SERVER_PORT" ]]; then + "${s6wrap[@]}" echo "[WARN] SERVER_PORT is deprecated, please use OUTPUT_SERVER_PORT" + OUTPUT_SERVER_PORT="$SERVER_PORT" fi # detect legacy udp From 3edd3ce8a6af562612df71562a96fcf212a02c0c Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Mon, 1 Jan 2024 11:04:25 -0700 Subject: [PATCH 04/32] Update acars_bridge --- rootfs/etc/s6-overlay/scripts/acars_bridge | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rootfs/etc/s6-overlay/scripts/acars_bridge b/rootfs/etc/s6-overlay/scripts/acars_bridge index e1c7ef2..6ba1df5 100755 --- a/rootfs/etc/s6-overlay/scripts/acars_bridge +++ b/rootfs/etc/s6-overlay/scripts/acars_bridge @@ -10,12 +10,12 @@ SOURCE_PORT=5550 # lets see if legacy SERVER / SERVER_PORT are set -if [[ -n "$SERVER" ]]; then +if [[ -n "$SERVER" ]] && [[ -z "$OUTPUT_SERVER" ]]; then "${s6wrap[@]}" echo "[WARN] SERVER is deprecated, please use OUTPUT_SERVER" OUTPUT_SERVER="$SERVER" fi -if [[ -n "$SERVER_PORT" ]]; then +if [[ -n "$SERVER_PORT" ]] && [[ -z "$OUTPUT_SERVER_PORT" ]]; then "${s6wrap[@]}" echo "[WARN] SERVER_PORT is deprecated, please use OUTPUT_SERVER_PORT" OUTPUT_SERVER_PORT="$SERVER_PORT" fi From 7de600b557b9e02e243466878dae00192192597e Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Mon, 1 Jan 2024 11:05:26 -0700 Subject: [PATCH 05/32] Update acars_bridge --- rootfs/etc/s6-overlay/scripts/acars_bridge | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootfs/etc/s6-overlay/scripts/acars_bridge b/rootfs/etc/s6-overlay/scripts/acars_bridge index 6ba1df5..161bf4b 100755 --- a/rootfs/etc/s6-overlay/scripts/acars_bridge +++ b/rootfs/etc/s6-overlay/scripts/acars_bridge @@ -27,7 +27,7 @@ fi ACARS_BRIDGE_BIN="/opt/acars-bridge" ACARS_BRIDGE_CMD=(--source-port "$SOURCE_PORT") -ACARS_BRIDGE_CMD=(--source-protocol "udp") +ACARS_BRIDGE_CMD+=(--source-protocol "udp") ACARS_BRIDGE_CMD+=(--source-host "127.0.0.1") if [[ -n "$OUTPUT_SERVER" ]]; then From c95e3e32f38e9c2397336c332d99e3fdfdfb2c9d Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Mon, 1 Jan 2024 11:10:41 -0700 Subject: [PATCH 06/32] Update acars_bridge --- rootfs/etc/s6-overlay/scripts/acars_bridge | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rootfs/etc/s6-overlay/scripts/acars_bridge b/rootfs/etc/s6-overlay/scripts/acars_bridge index 161bf4b..36ebb1b 100755 --- a/rootfs/etc/s6-overlay/scripts/acars_bridge +++ b/rootfs/etc/s6-overlay/scripts/acars_bridge @@ -10,12 +10,12 @@ SOURCE_PORT=5550 # lets see if legacy SERVER / SERVER_PORT are set -if [[ -n "$SERVER" ]] && [[ -z "$OUTPUT_SERVER" ]]; then +if [[ -n "$SERVER" ]]; then "${s6wrap[@]}" echo "[WARN] SERVER is deprecated, please use OUTPUT_SERVER" OUTPUT_SERVER="$SERVER" fi -if [[ -n "$SERVER_PORT" ]] && [[ -z "$OUTPUT_SERVER_PORT" ]]; then +if [[ -n "$SERVER_PORT" ]]; then "${s6wrap[@]}" echo "[WARN] SERVER_PORT is deprecated, please use OUTPUT_SERVER_PORT" OUTPUT_SERVER_PORT="$SERVER_PORT" fi From e37cc3c7dd30830e16795f03cc34a9b1d7c97d50 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Mon, 1 Jan 2024 11:13:44 -0700 Subject: [PATCH 07/32] Update acars_bridge --- rootfs/etc/s6-overlay/scripts/acars_bridge | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/rootfs/etc/s6-overlay/scripts/acars_bridge b/rootfs/etc/s6-overlay/scripts/acars_bridge index 36ebb1b..d2f2249 100755 --- a/rootfs/etc/s6-overlay/scripts/acars_bridge +++ b/rootfs/etc/s6-overlay/scripts/acars_bridge @@ -6,8 +6,6 @@ SCRIPT_NAME="${SCRIPT_NAME%.*}" # shellcheck disable=SC2034 s6wrap=(s6wrap --quiet --timestamps --prepend="$SCRIPT_NAME" --args) -SOURCE_PORT=5550 - # lets see if legacy SERVER / SERVER_PORT are set if [[ -n "$SERVER" ]]; then @@ -25,10 +23,11 @@ if [[ "$OUTPUT_SERVER_MODE" == "udp" ]]; then "${s6wrap[@]}" echo "[WARN] Using UDP mode to connect to $OUTPUT_SERVER:$OUTPUT_SERVER_PORT. Suggest switching to ZMQ Mode. Please see documentation for more information." fi +SOURCE_PORT=5550 ACARS_BRIDGE_BIN="/opt/acars-bridge" ACARS_BRIDGE_CMD=(--source-port "$SOURCE_PORT") ACARS_BRIDGE_CMD+=(--source-protocol "udp") -ACARS_BRIDGE_CMD+=(--source-host "127.0.0.1") +ACARS_BRIDGE_CMD+=(--source-host "0.0.0.0") if [[ -n "$OUTPUT_SERVER" ]]; then ACARS_BRIDGE_CMD+=(--destination-host "$OUTPUT_SERVER") From 94b6e0523231430949cf813a4ebe6ec66d66f5cd Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Mon, 1 Jan 2024 11:24:03 -0700 Subject: [PATCH 08/32] fix startup --- rootfs/etc/s6-overlay/scripts/acarsdec | 11 -------- rootfs/scripts/healthcheck.sh | 38 -------------------------- 2 files changed, 49 deletions(-) diff --git a/rootfs/etc/s6-overlay/scripts/acarsdec b/rootfs/etc/s6-overlay/scripts/acarsdec index 3ff1f6d..0c2f267 100755 --- a/rootfs/etc/s6-overlay/scripts/acarsdec +++ b/rootfs/etc/s6-overlay/scripts/acarsdec @@ -4,17 +4,6 @@ # shellcheck disable=SC1091 source /scripts/common -# Require that acars_server is running -if ! netstat -an | grep -P '^\s*tcp\s+\d+\s+\d+\s+0\.0\.0\.0:15550\s+(?>\d{1,3}\.{0,1}){4}:\*\s+LISTEN\s*$' > /dev/null; then - sleep 1 - if [[ ! ${QUIET_LOGS,,} =~ true ]]; then - # shellcheck disable=SC2154 - "${s6wrap[@]}" echo "acars_server not running, exiting" - fi - exit -fi -set -e - ACARS_BIN="/usr/local/bin/acarsdec" # shellcheck disable=SC2001 SOAPYSDR="" diff --git a/rootfs/scripts/healthcheck.sh b/rootfs/scripts/healthcheck.sh index 33296ba..33963fa 100755 --- a/rootfs/scripts/healthcheck.sh +++ b/rootfs/scripts/healthcheck.sh @@ -81,44 +81,6 @@ for service_dir in /etc/s6-overlay/scripts/*; do done -# ===== Check acars_server, acars_feeder, acars_stats processes ===== - -echo "==== Checking acars_server =====" - -# Check acars_server is listening for TCP on 127.0.0.1:15550 -acars_pidof_acars_tcp_server=$(pgrep -f 'ncat -4 --keep-open --listen 0.0.0.0 15550') -if ! check_tcp4_socket_listening_for_pid "0.0.0.0" "15550" "${acars_pidof_acars_tcp_server}"; then - echo "acars_server TCP not listening on port 15550 (pid $acars_pidof_acars_tcp_server): UNHEALTHY" - EXITCODE=1 -else - echo "acars_server TCP listening on port 15550 (pid $acars_pidof_acars_tcp_server): HEALTHY" -fi - -echo "==== Checking acars_stats =====" - -# Check acars_stats: -acars_pidof_acars_stats=$(pgrep -fx 'socat -u TCP:127.0.0.1:15550 CREATE:/run/acars/acars.past5min.json') - -# Ensure TCP connection to acars_server at 127.0.0.1:15550 -if ! check_tcp4_connection_established_for_pid "127.0.0.1" "ANY" "127.0.0.1" "15550" "${acars_pidof_acars_stats}"; then -echo "acars_stats (pid $acars_pidof_acars_stats) not connected to acars_server (pid $acars_pidof_acars_tcp_server) at 127.0.0.1:15550: UNHEALTHY" -EXITCODE=1 -else -echo "acars_stats (pid $acars_pidof_acars_stats) connected to acars_server (pid $acars_pidof_acars_tcp_server) at 127.0.0.1:15550: HEALTHY" -fi - -echo "==== Check for ACARS activity =====" - -# Check for activity -# read .json files, ensure messages received in past hour -acars_num_msgs_past_hour=$(find /run/acars -type f -name 'acars.*.json' -cmin -60 -exec cat {} \; | wc -l) -if [[ "$acars_num_msgs_past_hour" -gt 0 ]]; then - echo "$acars_num_msgs_past_hour ACARS messages received in past hour: HEALTHY" -else - echo "$acars_num_msgs_past_hour ACARS messages received in past hour: UNHEALTHY" - EXITCODE=1 -fi - echo "==== Check Service Death Tallies =====" # Check service death tally From f6af08db0ddbeb09a51332836dc5ffe9c0e316ed Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Mon, 1 Jan 2024 11:27:22 -0700 Subject: [PATCH 09/32] Update healthcheck.sh --- rootfs/scripts/healthcheck.sh | 73 ----------------------------------- 1 file changed, 73 deletions(-) diff --git a/rootfs/scripts/healthcheck.sh b/rootfs/scripts/healthcheck.sh index 33963fa..f24244a 100755 --- a/rootfs/scripts/healthcheck.sh +++ b/rootfs/scripts/healthcheck.sh @@ -8,79 +8,6 @@ source /opt/healthchecks-framework/healthchecks.sh # Default original codes EXITCODE=0 -# ===== Local Helper Functions ===== - -function get_pid_of_decoder { - - # $1: service_dir - service_dir="$1" - - # Ensure variables are unset - unset SOAPYSDR ACARS_BIN FREQ_STRING - - # Get SOAPYSDR - eval "$(grep "SOAPYSDR=\"" "$service_dir")" - - # Get FREQS_ACARS - eval "$(grep "FREQ_STRING=\"" "$service_dir")" - - # Get ACARS_BIN - eval "$(grep "ACARS_BIN=\"" "$service_dir")" - - # Get PS output for the relevant process - if [[ -n "$ACARS_BIN" ]]; then - if [[ -n "$SOAPYSDR" ]]; then - # shellcheck disable=SC2009 - ps_output=$(ps aux | grep "$ACARS_BIN" | grep " -d $SOAPYSDR " | grep "$FREQ_STRING") - fi - fi - - # Find the PID of the decoder based on command line - process_pid=$(echo "$ps_output" | tr -s " " | cut -d " " -f 2) - - # Return the process_pid - echo "$process_pid" - -} - -# ===== Check acarsdec processes ===== - -# For each service... -for service_dir in /etc/s6-overlay/scripts/*; do - service_name=$(basename "$service_dir") - - # If the service is acarsdec-*... - if [[ "$service_name" == acarsdec ]]; then - - decoder_pid=$(get_pid_of_decoder "$service_dir") - decoder_udp_port="5550" - decoder_server_prefix="acars" - - # If the server isn't acarsdec-. - else - # skip it! - continue - fi - - # If the process doesn't exists, then fail - - echo "==== Checking $service_name =====" - - if [[ -z "$decoder_pid" ]]; then - echo "Cannot find PID of decoder $service_name: UNHEALTHY" - EXITCODE=1 - else - # If the process does exist, then make sure it has made a connection to localhost on the relevant port. - if ! check_udp4_connection_established_for_pid "127.0.0.1" "ANY" "127.0.0.1" "$decoder_udp_port" "$decoder_pid"; then - echo "Decoder $service_name (pid $decoder_pid) not connected to ${decoder_server_prefix}_server at 127.0.0.1:$decoder_udp_port: UNHEALTHY" - EXITCODE=1 - else - echo "Decoder $service_name (pid $decoder_pid) is connected to ${decoder_server_prefix}_server at 127.0.0.1:$decoder_udp_port: HEALTHY" - fi - fi - -done - echo "==== Check Service Death Tallies =====" # Check service death tally From 001acc0ae5190289bb4bdf81ed881e13e8ed56c7 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Mon, 1 Jan 2024 11:33:45 -0700 Subject: [PATCH 10/32] shoosh stdout logging --- rootfs/etc/s6-overlay/scripts/acarsdec | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rootfs/etc/s6-overlay/scripts/acarsdec b/rootfs/etc/s6-overlay/scripts/acarsdec index 0c2f267..df70769 100755 --- a/rootfs/etc/s6-overlay/scripts/acarsdec +++ b/rootfs/etc/s6-overlay/scripts/acarsdec @@ -62,11 +62,16 @@ if [[ -n "$ACARSDEC_COMMAND_EXTRA" ]]; then ACARS_CMD+=("$ACARSDEC_COMMAND_EXTRA") fi +if [[ ${QUIET_LOGS,,} =~ true ]]; then + ACARS_CMD+=("-l" "/dev/null") +fi + # shellcheck disable=SC2206 ACARS_CMD+=($FREQ_STRING) set -eo pipefail +# shellcheck disable=SC2154 "${s6wrap[@]}" echo "Starting: '$ACARS_BIN" "${ACARS_CMD[*]}'" if [[ ${QUIET_LOGS,,} =~ true ]]; then From 18288480b0c12c922b9bb47111ee7a4dc4388dce Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Mon, 1 Jan 2024 11:43:07 -0700 Subject: [PATCH 11/32] updates --- rootfs/etc/s6-overlay/scripts/01-acarsdec | 12 ++++++++---- rootfs/etc/s6-overlay/scripts/acarsdec | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/rootfs/etc/s6-overlay/scripts/01-acarsdec b/rootfs/etc/s6-overlay/scripts/01-acarsdec index 4c72665..4842cd7 100755 --- a/rootfs/etc/s6-overlay/scripts/01-acarsdec +++ b/rootfs/etc/s6-overlay/scripts/01-acarsdec @@ -37,10 +37,14 @@ FREQ_STRING="" for i in "${SPLIT_FREQS[@]}" do : -if [[ $(echo "$i > 118.0" | bc) -eq 0 || $(echo "$i < 137.0" | bc) -eq 0 ]]; then - "${s6wrap[@]}" echo "FREQUENCY $i is not in the range of 118.0 - 137.0" -fi -FREQ_STRING+=" $i" + if [[ $(echo "$i > 118.0" | bc) -eq 0 || $(echo "$i < 137.0" | bc) -eq 0 ]]; then + "${s6wrap[@]}" echo "FREQUENCY $i is not in the range of 118.0 - 137.0" + fi + if [[ -z "${FREQ_STRING}" ]]; then + FREQ_STRING="$i" + else + FREQ_STRING+=" $i" + fi done # Make sure mode is valid diff --git a/rootfs/etc/s6-overlay/scripts/acarsdec b/rootfs/etc/s6-overlay/scripts/acarsdec index df70769..f96a00c 100755 --- a/rootfs/etc/s6-overlay/scripts/acarsdec +++ b/rootfs/etc/s6-overlay/scripts/acarsdec @@ -78,7 +78,7 @@ if [[ ${QUIET_LOGS,,} =~ true ]]; then # shellcheck disable=SC2016 "${s6wrap[@]}" "$ACARS_BIN" "${ACARS_CMD[@]}" 2>&1 | \ stdbuf -oL sed --unbuffered '/^$/d' | \ - stdbuf -oL awk '! /^dumpvdl2/' | \ + stdbuf -oL awk '! /^acarsdec/' | \ stdbuf -oL awk '! /^Sampling rate set/' | \ stdbuf -oL awk '! /^Found \[0-9]+ device(s):/' | \ stdbuf -oL awk '! /^ [0-9]+/' | \ From 236374339c56814b886ac318cfcfe8058230458f Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Mon, 1 Jan 2024 11:46:19 -0700 Subject: [PATCH 12/32] Update acarsdec --- rootfs/etc/s6-overlay/scripts/acarsdec | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/rootfs/etc/s6-overlay/scripts/acarsdec b/rootfs/etc/s6-overlay/scripts/acarsdec index f96a00c..4033422 100755 --- a/rootfs/etc/s6-overlay/scripts/acarsdec +++ b/rootfs/etc/s6-overlay/scripts/acarsdec @@ -26,7 +26,7 @@ if [ -n "${PPM}" ]; then ACARS_CMD+=("-p" "$PPM") fi -if [ -n "${SERVER}" ]; then +if [[ -n "${SERVER}" ]] || [[ -n "$OUTPUT_SERVER" ]]; then ACARS_CMD+=("-o" "0") ACARS_CMD+=("-l" "/dev/null") else @@ -62,10 +62,6 @@ if [[ -n "$ACARSDEC_COMMAND_EXTRA" ]]; then ACARS_CMD+=("$ACARSDEC_COMMAND_EXTRA") fi -if [[ ${QUIET_LOGS,,} =~ true ]]; then - ACARS_CMD+=("-l" "/dev/null") -fi - # shellcheck disable=SC2206 ACARS_CMD+=($FREQ_STRING) From d1f2435fe5941eca257aa8953e2b43290ff70371 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Mon, 1 Jan 2024 11:52:30 -0700 Subject: [PATCH 13/32] Update acarsdec --- rootfs/etc/s6-overlay/scripts/acarsdec | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/rootfs/etc/s6-overlay/scripts/acarsdec b/rootfs/etc/s6-overlay/scripts/acarsdec index 4033422..a01dfb1 100755 --- a/rootfs/etc/s6-overlay/scripts/acarsdec +++ b/rootfs/etc/s6-overlay/scripts/acarsdec @@ -42,17 +42,17 @@ if [ -n "${VERBOSE}" ]; then ACARS_CMD+=("-v") fi -# Send output JSON to acars_server -if [ -n "${SERVER}" ]; then - if [[ "${MODE}" == @(J|j) ]]; then - ACARS_CMD+=("-j" "127.0.0.1:5550") - elif [[ "${MODE}" == @(P|p) ]]; then - ACARS_CMD+=("-n" "127.0.0.1:5550") - elif [[ "${MODE}" == @(A|a) ]]; then - ACARS_CMD+=("-N" "127.0.0.1:5550") - fi +# Send output JSON to acars-bridge + +if [[ "${MODE}" == @(J|j) ]]; then + ACARS_CMD+=("-j" "127.0.0.1:5550") +elif [[ "${MODE}" == @(P|p) ]]; then + ACARS_CMD+=("-n" "127.0.0.1:5550") +elif [[ "${MODE}" == @(A|a) ]]; then + ACARS_CMD+=("-N" "127.0.0.1:5550") fi + # Specify SOAPYSDR if [ -n "${SOAPYSDR}" ]; then ACARS_CMD+=("-d" "$SOAPYSDR") From 30f7ffe04af3d99d957fb92632bae14ef84c27a6 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Mon, 1 Jan 2024 12:03:08 -0700 Subject: [PATCH 14/32] Update acars_bridge --- rootfs/etc/s6-overlay/scripts/acars_bridge | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootfs/etc/s6-overlay/scripts/acars_bridge b/rootfs/etc/s6-overlay/scripts/acars_bridge index d2f2249..d319a67 100755 --- a/rootfs/etc/s6-overlay/scripts/acars_bridge +++ b/rootfs/etc/s6-overlay/scripts/acars_bridge @@ -20,7 +20,7 @@ fi # detect legacy udp if [[ "$OUTPUT_SERVER_MODE" == "udp" ]]; then - "${s6wrap[@]}" echo "[WARN] Using UDP mode to connect to $OUTPUT_SERVER:$OUTPUT_SERVER_PORT. Suggest switching to ZMQ Mode. Please see documentation for more information." + "${s6wrap[@]}" echo "[WARN] Using UDP mode to connect to $OUTPUT_SERVER:$OUTPUT_SERVER_PORT. Suggest switching to TCP or ZMQ Mode. Please see documentation for more information." fi SOURCE_PORT=5550 From 95f2c7d4f74deb4892a4a1d90be70301067cebff Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Mon, 1 Jan 2024 14:08:47 -0700 Subject: [PATCH 15/32] create a test tag --- .github/workflows/deploy.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 1920f4a..74c07ca 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -12,6 +12,11 @@ on: type: boolean description: "Use base image testpr" default: false + build_latest_as_test: + required: false + type: boolean + description: "Build latest as test" + default: false # Build and deploy the image on pushes to main branch push: @@ -46,6 +51,9 @@ jobs: echo "Use test image: $INPUTS_USE_TEST_IMAGE" build_and_push: name: Image Build & Push + if: | + github.event.inputs.build_latest_as_test == 'false' || + github.event.inputs.build_latest_as_test == '' uses: sdr-enthusiasts/common-github-workflows/.github/workflows/build_and_push_image.yml@main with: push_enabled: true @@ -65,3 +73,28 @@ jobs: build_baseimage_url: :acars-decoder/:acars-decoder-test-pr secrets: ghcr_token: ${{ secrets.GITHUB_TOKEN }} + + deploy_test: + name: Deploy as test + if: | + github.event.inputs.build_latest_as_test == 'true' && + (github.event.inputs.use_test_image == 'false' || github.event.inputs.use_test_image == '') + uses: sdr-enthusiasts/common-github-workflows/.github/workflows/build_and_push_image.yml@main + with: + push_enabled: true + push_destinations: ghcr.io + ghcr_repo_owner: ${{ github.repository_owner }} + ghcr_repo: ${{ github.repository }} + build_with_tmpfs: true + get_version_method: git_commit_hash_short + # set build_latest to true if github.event.inputs.use_test_image is false + build_latest: true + docker_latest_tag: test + build_baseimage_test: false + # only build the entire stack if we are not using the test image + build_version_specific: false + build_platform_specific: false + build_nohealthcheck: false + build_baseimage_url: :acars-decoder/:acars-decoder-test-pr + secrets: + ghcr_token: ${{ secrets.GITHUB_TOKEN }} From b75b4cd1f9dee8fd8cb69a5d3a17a23ddd4ceeef Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Mon, 1 Jan 2024 14:12:59 -0700 Subject: [PATCH 16/32] Update deploy.yml --- .github/workflows/deploy.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 74c07ca..732554e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -86,7 +86,10 @@ jobs: ghcr_repo_owner: ${{ github.repository_owner }} ghcr_repo: ${{ github.repository }} build_with_tmpfs: true - get_version_method: git_commit_hash_short + get_version_method: cargo_toml_file_in_repo:file=/Cargo.toml + cache_enabled: true + cache_path: ./bin/ + cache_key: ${{ github.run_id }} # set build_latest to true if github.event.inputs.use_test_image is false build_latest: true docker_latest_tag: test From 1711f6a59c705521e63de78bd63d90c6a213b25e Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Mon, 1 Jan 2024 14:18:44 -0700 Subject: [PATCH 17/32] Update deploy.yml --- .github/workflows/deploy.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 732554e..98ff7c2 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -87,9 +87,6 @@ jobs: ghcr_repo: ${{ github.repository }} build_with_tmpfs: true get_version_method: cargo_toml_file_in_repo:file=/Cargo.toml - cache_enabled: true - cache_path: ./bin/ - cache_key: ${{ github.run_id }} # set build_latest to true if github.event.inputs.use_test_image is false build_latest: true docker_latest_tag: test From 990a1837004e97436a5d639eb7e37019537826a7 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Mon, 1 Jan 2024 14:31:00 -0700 Subject: [PATCH 18/32] clean up disk space as we build --- .github/workflows/deploy.yml | 2 +- Dockerfile | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 98ff7c2..74c07ca 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -86,7 +86,7 @@ jobs: ghcr_repo_owner: ${{ github.repository_owner }} ghcr_repo: ${{ github.repository }} build_with_tmpfs: true - get_version_method: cargo_toml_file_in_repo:file=/Cargo.toml + get_version_method: git_commit_hash_short # set build_latest to true if github.event.inputs.use_test_image is false build_latest: true docker_latest_tag: test diff --git a/Dockerfile b/Dockerfile index 82401bf..61476b8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,13 @@ RUN set -x && \ RUN set -x && \ git clone https://github.com/sdr-enthusiasts/acars-bridge.git . && \ - cargo build --release + cargo build --release && \ + # clean up the apt-cache + apt-get clean && \ + rm -rf /var/lib/apt/lists/* && \ + cp /tmp/acars-bridge/target/release/acars-bridge . && \ + cargo clean + FROM ghcr.io/sdr-enthusiasts/docker-baseimage:acars-decoder @@ -62,6 +68,8 @@ RUN set -x && \ make install && \ ldconfig && \ popd && popd && \ + # remove the source code + rm -rf /src/airspyone_host && \ # Deploy SoapySDR git clone https://github.com/pothosware/SoapySDR.git /src/SoapySDR && \ pushd /src/SoapySDR && \ @@ -75,6 +83,8 @@ RUN set -x && \ make install && \ popd && popd && \ ldconfig && \ + # remove the source code + rm -rf /src/SoapySDR && \ # Deploy SoapyRTLTCP git clone https://github.com/pothosware/SoapyRTLTCP.git /src/SoapyRTLTCP && \ pushd /src/SoapyRTLTCP && \ @@ -85,6 +95,8 @@ RUN set -x && \ make install && \ popd && popd && \ ldconfig && \ + # remove the source code + rm -rf /src/SoapyRTLTCP && \ # Deploy SoapyRTLSDR git clone https://github.com/pothosware/SoapyRTLSDR.git /src/SoapyRTLSDR && \ pushd /src/SoapyRTLSDR && \ @@ -97,6 +109,8 @@ RUN set -x && \ make install && \ popd && popd && \ ldconfig && \ + # remove the source code + rm -rf /src/SoapyRTLSDR && \ # install sdrplay support for soapy git clone https://github.com/pothosware/SoapySDRPlay.git /src/SoapySDRPlay && \ pushd /src/SoapySDRPlay && \ @@ -108,6 +122,8 @@ RUN set -x && \ popd && \ popd && \ ldconfig && \ + # remove the source code + rm -rf /src/SoapySDRPlay && \ # Deploy Airspy git clone https://github.com/pothosware/SoapyAirspy.git /src/SoapyAirspy && \ pushd /src/SoapyAirspy && \ @@ -119,6 +135,8 @@ RUN set -x && \ popd && \ popd && \ ldconfig && \ + # remove the source code + rm -rf /src/SoapyAirspy && \ # acarsdec #git clone --depth 1 --single-branch --branch master https://github.com/TLeconte/acarsdec /src/acarsdec && \ git clone --depth 1 --single-branch --branch master https://github.com/wiedehopf/acarsdec.git /src/acarsdec && \ @@ -138,7 +156,7 @@ RUN set -x && \ rm -rf /src/* /tmp/* /var/lib/apt/lists/* COPY rootfs/ / -COPY --from=builder /tmp/acars-bridge/target/release/acars-bridge /opt/acars-bridge +COPY --from=builder /tmp/acars-bridge/acars-bridge /opt/acars-bridge # ENTRYPOINT [ "/init" ] From c1cbf4e62199fee5495652b6370c9270123c3d05 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Mon, 1 Jan 2024 15:00:08 -0700 Subject: [PATCH 19/32] Update README.md --- README.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c459627..ee667d2 100644 --- a/README.md +++ b/README.md @@ -60,8 +60,9 @@ services: | `FREQUENCIES` | Colon-separated list of frequencies, but to a maximum of 8, for the decoder to list to | Yes | Blank | | `PPM` | Parts per million correction of the decoder | No | 0 | | `GAIN` | The gain applied to the RTL-SDR dongle. Recommended to leave at the default autogain. To set manually, gain in in db (0 to 49.6; >52 and -10 will result in AGC; default is AGC) | No | `-10` for autogain | -| `SERVER` | The server where messages will be forwarded to. | No | Blank | -| `SERVER_PORT` | The port where the server will receive messages on. | No | `5550` | +| `OUTPUT_SERVER` | The server where messages will be forwarded to. | No | `acars_router` | +| `OUTPUT_SERVER_PORT` | The port where the server will receive messages on. | No | `5550` | +| `OUTPUT_SERVER_MODE` | The output mode. `udp`, `tcp` and `zmq` are valid | No | `udp` | | `MODE` | The output mode. `P` for planeplotter, `J` for JSON and `A` for acarsdec. | No | `J` | | `QUIET_LOGS` | Mute log output to the bare minimum. Set to `false` to see all of the log messages. | No | `TRUE` | | `ACARSDEC_COMMAND_EXTRA` | Additional arguments to pass to the decoder. | No | Blank | @@ -76,3 +77,17 @@ Supported Soapy Drivers: - `rtltcp` - `airspy` - `sdrplay` + +## Output modes + +TL;DR: No change to your setup is necessary for continued functionality, but you should update your configuration to use the new variables and at least use TCP. + +A recent change in the container has meant we are migrating from `SERVER`/`SERVER_PORT` to `OUTPUT_SERVER`/`OUTPUT_SERVER_PORT`. The old variables will continue to work for the time being, but please update your configuration to use the new variables. Simply replace `SERVER` with `OUTPUT_SERVER` and `SERVER_PORT` with `OUTPUT_SERVER_PORT`. If you do not have `SERVER`/`SERVER_PORT` set, you do not need to do anything and it will work as it did before. + +Generally speaking for a proper migration, whatever your `SERVER` was before should be set in your compose as `OUTPUT_SERVER` and whatever your `SERVER_PORT` was before should be set as `OUTPUT_SERVER_PORT`. If `SERVER` was not set, you do not have to add in `OUTPUT_SERVER`. If you did not have `SERVER_PORT` set in your compose, you do not have to add in `OUTPUT_SERVER_PORT` unless you want to use `zmq`. + +Additionally, the `OUTPUT_SERVER_MODE` variable has been added to allow for the output mode to be set. The default is `udp` and the container will function as it did before. `tcp` and `zmq` are also valid options and recommended over `udp` for reliability. + +To use `tcp` with `acars_router` with the default ports it would have mapped, simply set `OUTPUT_SERVER_MODE=tcp` and leave the `OUTPUT_SERVER_PORT` as `5550` or unset. + +If you wish to use `zmq` with `acars_router` with the default ports it would have mapped, simply set `OUTPUT_SERVER_MODE=zmq` and set `OUTPUT_SERVER_PORT` as `35550`. From cf578959dcef970788d6df38862b4e91829b29b4 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Mon, 1 Jan 2024 15:04:02 -0700 Subject: [PATCH 20/32] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ee667d2..d716d0d 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ Supported Soapy Drivers: TL;DR: No change to your setup is necessary for continued functionality, but you should update your configuration to use the new variables and at least use TCP. -A recent change in the container has meant we are migrating from `SERVER`/`SERVER_PORT` to `OUTPUT_SERVER`/`OUTPUT_SERVER_PORT`. The old variables will continue to work for the time being, but please update your configuration to use the new variables. Simply replace `SERVER` with `OUTPUT_SERVER` and `SERVER_PORT` with `OUTPUT_SERVER_PORT`. If you do not have `SERVER`/`SERVER_PORT` set, you do not need to do anything and it will work as it did before. +A recent change in the container has meant we are migrating from `SERVER`/`SERVER_PORT` to `OUTPUT_SERVER`/`OUTPUT_SERVER_PORT` as a better name for what the variable is representing. The old variables will continue to work for the time being, but please update your configuration to use the new variables. Simply replace `SERVER` with `OUTPUT_SERVER` and `SERVER_PORT` with `OUTPUT_SERVER_PORT`. If you do not have `SERVER`/`SERVER_PORT` set, you do not need to do anything and it will work as it did before. Generally speaking for a proper migration, whatever your `SERVER` was before should be set in your compose as `OUTPUT_SERVER` and whatever your `SERVER_PORT` was before should be set as `OUTPUT_SERVER_PORT`. If `SERVER` was not set, you do not have to add in `OUTPUT_SERVER`. If you did not have `SERVER_PORT` set in your compose, you do not have to add in `OUTPUT_SERVER_PORT` unless you want to use `zmq`. From 97e70c95aadc602addea8b5e88a1e639c9178c1a Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Mon, 1 Jan 2024 15:07:00 -0700 Subject: [PATCH 21/32] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d716d0d..c5a9c21 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ services: - SERIAL=13305 - FEED_ID=ACARS - FREQUENCIES=130.025;130.450;131.125;131.550 + - OUTPUT_SERVER_MODE=tcp tmpfs: - /run:exec,size=64M - /var/log From 85fcd9d0e7bada14ebe4acc9787d31e662329f7c Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Sat, 6 Jan 2024 11:54:47 -0700 Subject: [PATCH 22/32] use cached binary for build --- .github/workflows/deploy.yml | 160 ++++++++++++++++++++++++++ Dockerfile | 35 +++--- Dockerfile.build_binary | 13 +++ Dockerfile.local | 164 +++++++++++++++++++++++++++ rootfs/rename_current_arch_binary.sh | 17 +++ 5 files changed, 368 insertions(+), 21 deletions(-) create mode 100644 Dockerfile.build_binary create mode 100644 Dockerfile.local create mode 100755 rootfs/rename_current_arch_binary.sh diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 74c07ca..4be0ecc 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -49,8 +49,161 @@ jobs: run: | echo "Workflow dispatch reason: $INPUTS_REASON" echo "Use test image: $INPUTS_USE_TEST_IMAGE" + binary_build_armv7: + name: Build Binary - armv7 + runs-on: ubuntu-latest + # needs: test_rust_functionality + + steps: + - name: Checkout + uses: actions/checkout@v4.1.1 + with: + fetch-depth: 0 + repository: https://github.com/sdr-enthusiasts/acars-bridge.git + + - name: Run Docker on tmpfs + uses: JonasAlfredsson/docker-on-tmpfs@v1 + with: + tmpfs_size: 5 + swap_size: 4 + swap_location: "/mnt/swapfile" + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build armv7 + uses: docker/build-push-action@v5 + with: + context: . + push: false + file: Dockerfile.build_binary + tags: acars-bridge:armv7 + platforms: linux/arm/v7 + outputs: type=local,dest=./image_armv7/ + + - name: Upload artifact armv7 binary + uses: actions/upload-artifact@v4.0.0 + with: + name: acars-bridge.armv7 + path: ./image_armv7/acars-bridge + + binary_build_arm64: + name: Build Binary - arm64 + runs-on: ubuntu-latest + # needs: test_rust_functionality + + steps: + - name: Checkout + uses: actions/checkout@v4.1.1 + with: + fetch-depth: 0 + repository: https://github.com/sdr-enthusiasts/acars-bridge.git + + - name: Run Docker on tmpfs + uses: JonasAlfredsson/docker-on-tmpfs@v1 + with: + tmpfs_size: 5 + swap_size: 4 + swap_location: "/mnt/swapfile" + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build arm64 + uses: docker/build-push-action@v5 + with: + context: . + push: false + file: Dockerfile.build_binary + tags: acars-bridge:arm64 + platforms: linux/arm64 + outputs: type=local,dest=./image_arm64/ + + - name: Upload artifact arm64 binary + uses: actions/upload-artifact@v4.0.0 + with: + name: acars-bridge.arm64 + path: ./image_arm64/acars-bridge + + binary_build_amd64: + name: Build Binary - amd64 + runs-on: ubuntu-latest + # needs: test_rust_functionality + + steps: + - name: Checkout + uses: actions/checkout@v4.1.1 + with: + fetch-depth: 0 + repository: https://github.com/sdr-enthusiasts/acars-bridge.git + + - name: Run Docker on tmpfs + uses: JonasAlfredsson/docker-on-tmpfs@v1 + with: + tmpfs_size: 5 + swap_size: 4 + swap_location: "/mnt/swapfile" + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build amd64 + uses: docker/build-push-action@v5 + with: + context: . + push: false + file: Dockerfile.build_binary + tags: acars-bridge:amd64 + platforms: linux/amd64 + outputs: type=local,dest=./image_amd64/ + + - name: Upload artifact amd64 binary + uses: actions/upload-artifact@v4.0.0 + with: + name: acars-bridge.amd64 + path: ./image_amd64/acars-bridge + + consolidate_binaries: + name: Consolidate & Cache Binaries + runs-on: ubuntu-latest + needs: [binary_build_amd64, binary_build_arm64, binary_build_armv7] + steps: + - run: mkdir -p ./bin + + - uses: actions/download-artifact@v4.0.0 + with: + name: acars-bridge.amd64 + path: ./bin/acars-bridge.amd64 + + - uses: actions/download-artifact@v4.0.0 + with: + name: acars-bridge.armv7 + path: ./bin/acars-bridge.armv7 + + - uses: actions/download-artifact@v4.0.0 + with: + name: acars-bridge.arm64 + path: ./bin/acars-bridge.arm64 + + - run: ls -la ./bin/* + + - name: Cache Binaries + uses: actions/cache@v3 + with: + path: ./bin/ + key: ${{ github.run_id }} build_and_push: name: Image Build & Push + needs: [consolidate_binaries] if: | github.event.inputs.build_latest_as_test == 'false' || github.event.inputs.build_latest_as_test == '' @@ -71,11 +224,15 @@ jobs: build_platform_specific: ${{ github.event.inputs.use_test_image == 'false' || github.event.inputs.use_test_image == '' }} build_nohealthcheck: ${{ github.event.inputs.use_test_image == 'false' || github.event.inputs.use_test_image == '' }} build_baseimage_url: :acars-decoder/:acars-decoder-test-pr + cache_enabled: true + cache_path: ./bin/ + cache_key: ${{ github.run_id }} secrets: ghcr_token: ${{ secrets.GITHUB_TOKEN }} deploy_test: name: Deploy as test + needs: [consolidate_binaries] if: | github.event.inputs.build_latest_as_test == 'true' && (github.event.inputs.use_test_image == 'false' || github.event.inputs.use_test_image == '') @@ -96,5 +253,8 @@ jobs: build_platform_specific: false build_nohealthcheck: false build_baseimage_url: :acars-decoder/:acars-decoder-test-pr + cache_enabled: true + cache_path: ./bin/ + cache_key: ${{ github.run_id }} secrets: ghcr_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/Dockerfile b/Dockerfile index 61476b8..1b45ced 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,3 @@ -#build acars-bridge -FROM rust:1.75.0 as builder -WORKDIR /tmp/acars-bridge -# hadolint ignore=DL3008,DL3003,SC1091 -RUN set -x && \ - apt-get update && \ - apt-get install -y --no-install-recommends libzmq3-dev - -RUN set -x && \ - git clone https://github.com/sdr-enthusiasts/acars-bridge.git . && \ - cargo build --release && \ - # clean up the apt-cache - apt-get clean && \ - rm -rf /var/lib/apt/lists/* && \ - cp /tmp/acars-bridge/target/release/acars-bridge . && \ - cargo clean - - FROM ghcr.io/sdr-enthusiasts/docker-baseimage:acars-decoder ENV DEVICE_INDEX="" \ @@ -33,6 +15,10 @@ ENV DEVICE_INDEX="" \ MODE="J" SHELL ["/bin/bash", "-o", "pipefail", "-c"] +COPY ./rootfs / +COPY ./bin/acars-bride.armv7/acars_router /opt/acars_bridge.armv7 +COPY ./bin/acars_bridge.arm64/acars_router /opt/acars_bridge.arm64 +COPY ./bin/acars_bridge.amd64/acars_router /opt/acars_bridge.amd64 # hadolint ignore=DL3008,SC2086,SC2039 RUN set -x && \ @@ -54,6 +40,16 @@ RUN set -x && \ apt-get install -y --no-install-recommends \ "${KEPT_PACKAGES[@]}" \ "${TEMP_PACKAGES[@]}" && \ + # ensure binaries are executable + chmod -v a+x \ + /opt/acars-bridge.armv7 \ + /opt/acars-bridge.arm64 \ + /opt/acars-bridge.amd64 \ + && \ + # remove foreign architecture binaries + /rename_current_arch_binary.sh && \ + rm -fv \ + /opt/acars-bridge.* \ # install sdrplay curl --location --output /tmp/install_sdrplay.sh https://raw.githubusercontent.com/sdr-enthusiasts/install-libsdrplay/main/install_sdrplay.sh && \ chmod +x /tmp/install_sdrplay.sh && \ @@ -155,9 +151,6 @@ RUN set -x && \ apt-get autoremove -y && \ rm -rf /src/* /tmp/* /var/lib/apt/lists/* -COPY rootfs/ / -COPY --from=builder /tmp/acars-bridge/acars-bridge /opt/acars-bridge - # ENTRYPOINT [ "/init" ] # Add healthcheck diff --git a/Dockerfile.build_binary b/Dockerfile.build_binary new file mode 100644 index 0000000..4c119ea --- /dev/null +++ b/Dockerfile.build_binary @@ -0,0 +1,13 @@ +FROM rust:1.74.1-bullseye as builder +ENV CARGO_NET_GIT_FETCH_WITH_CLI=true +WORKDIR /tmp/acars-bridge +# hadolint ignore=DL3008,DL3003,SC1091,DL3009 +RUN set -x && \ + apt-get update && \ + apt-get install -y --no-install-recommends libzmq3-dev +COPY . . + +RUN cargo build --release + +FROM scratch +COPY --from=builder /tmp/acars-bridge/target/release/acars-bridge /acars-bridge diff --git a/Dockerfile.local b/Dockerfile.local new file mode 100644 index 0000000..61476b8 --- /dev/null +++ b/Dockerfile.local @@ -0,0 +1,164 @@ +#build acars-bridge +FROM rust:1.75.0 as builder +WORKDIR /tmp/acars-bridge +# hadolint ignore=DL3008,DL3003,SC1091 +RUN set -x && \ + apt-get update && \ + apt-get install -y --no-install-recommends libzmq3-dev + +RUN set -x && \ + git clone https://github.com/sdr-enthusiasts/acars-bridge.git . && \ + cargo build --release && \ + # clean up the apt-cache + apt-get clean && \ + rm -rf /var/lib/apt/lists/* && \ + cp /tmp/acars-bridge/target/release/acars-bridge . && \ + cargo clean + + +FROM ghcr.io/sdr-enthusiasts/docker-baseimage:acars-decoder + +ENV DEVICE_INDEX="" \ + QUIET_LOGS="TRUE" \ + FREQUENCIES="" \ + FEED_ID="" \ + PPM="0"\ + GAIN="-10" \ + RTLMULT="160" \ + SERIAL="" \ + SOAPYSDR="" \ + OUTPUT_SERVER="acars_router" \ + OUTPUT_SERVER_PORT="5550" \ + OUTPUT_SERVER_MODE="udp" \ + MODE="J" + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +# hadolint ignore=DL3008,SC2086,SC2039 +RUN set -x && \ + TEMP_PACKAGES=() && \ + KEPT_PACKAGES=() && \ + # Required for building multiple packages. + TEMP_PACKAGES+=(build-essential) && \ + TEMP_PACKAGES+=(pkg-config) && \ + TEMP_PACKAGES+=(cmake) && \ + TEMP_PACKAGES+=(git) && \ + TEMP_PACKAGES+=(automake) && \ + TEMP_PACKAGES+=(autoconf) && \ + TEMP_PACKAGES+=(wget) && \ + TEMP_PACKAGES+=(libusb-1.0-0-dev) && \ + KEPT_PACKAGES+=(libusb-1.0-0) && \ + KEPT_PACKAGES+=(libzmq5) && \ + # install packages + apt-get update && \ + apt-get install -y --no-install-recommends \ + "${KEPT_PACKAGES[@]}" \ + "${TEMP_PACKAGES[@]}" && \ + # install sdrplay + curl --location --output /tmp/install_sdrplay.sh https://raw.githubusercontent.com/sdr-enthusiasts/install-libsdrplay/main/install_sdrplay.sh && \ + chmod +x /tmp/install_sdrplay.sh && \ + /tmp/install_sdrplay.sh && \ + # deploy airspyone host + git clone https://github.com/airspy/airspyone_host.git /src/airspyone_host && \ + pushd /src/airspyone_host && \ + mkdir -p /src/airspyone_host/build && \ + pushd /src/airspyone_host/build && \ + cmake ../ -DINSTALL_UDEV_RULES=ON && \ + make && \ + make install && \ + ldconfig && \ + popd && popd && \ + # remove the source code + rm -rf /src/airspyone_host && \ + # Deploy SoapySDR + git clone https://github.com/pothosware/SoapySDR.git /src/SoapySDR && \ + pushd /src/SoapySDR && \ + BRANCH_SOAPYSDR=$(git tag --sort="creatordate" | tail -1) && \ + git checkout "$BRANCH_SOAPYSDR" && \ + mkdir -p /src/SoapySDR/build && \ + pushd /src/SoapySDR/build && \ + cmake ../ -DCMAKE_BUILD_TYPE=Debug && \ + make all && \ + make test && \ + make install && \ + popd && popd && \ + ldconfig && \ + # remove the source code + rm -rf /src/SoapySDR && \ + # Deploy SoapyRTLTCP + git clone https://github.com/pothosware/SoapyRTLTCP.git /src/SoapyRTLTCP && \ + pushd /src/SoapyRTLTCP && \ + mkdir -p /src/SoapyRTLTCP/build && \ + pushd /src/SoapyRTLTCP/build && \ + cmake ../ -DCMAKE_BUILD_TYPE=Debug && \ + make all && \ + make install && \ + popd && popd && \ + ldconfig && \ + # remove the source code + rm -rf /src/SoapyRTLTCP && \ + # Deploy SoapyRTLSDR + git clone https://github.com/pothosware/SoapyRTLSDR.git /src/SoapyRTLSDR && \ + pushd /src/SoapyRTLSDR && \ + BRANCH_SOAPYRTLSDR=$(git tag --sort="creatordate" | tail -1) && \ + git checkout "$BRANCH_SOAPYRTLSDR" && \ + mkdir -p /src/SoapyRTLSDR/build && \ + pushd /src/SoapyRTLSDR/build && \ + cmake ../ -DCMAKE_BUILD_TYPE=Debug && \ + make all && \ + make install && \ + popd && popd && \ + ldconfig && \ + # remove the source code + rm -rf /src/SoapyRTLSDR && \ + # install sdrplay support for soapy + git clone https://github.com/pothosware/SoapySDRPlay.git /src/SoapySDRPlay && \ + pushd /src/SoapySDRPlay && \ + mkdir build && \ + pushd build && \ + cmake .. && \ + make && \ + make install && \ + popd && \ + popd && \ + ldconfig && \ + # remove the source code + rm -rf /src/SoapySDRPlay && \ + # Deploy Airspy + git clone https://github.com/pothosware/SoapyAirspy.git /src/SoapyAirspy && \ + pushd /src/SoapyAirspy && \ + mkdir build && \ + pushd build && \ + cmake .. && \ + make && \ + make install && \ + popd && \ + popd && \ + ldconfig && \ + # remove the source code + rm -rf /src/SoapyAirspy && \ + # acarsdec + #git clone --depth 1 --single-branch --branch master https://github.com/TLeconte/acarsdec /src/acarsdec && \ + git clone --depth 1 --single-branch --branch master https://github.com/wiedehopf/acarsdec.git /src/acarsdec && \ + pushd /src/acarsdec && \ + #git checkout master && \ + #git checkout testing && \ + sed -i -e 's/-march=native//' CMakeLists.txt && \ + mkdir build && \ + pushd build && \ + cmake ../ -DCMAKE_BUILD_TYPE=Debug -Drtl=OFF -Dsdrplay=OFF -Dairspy=OFF -Dsoapy=ON && \ + make && \ + make install && \ + popd && popd && \ + # Clean up + apt-get remove -y "${TEMP_PACKAGES[@]}" && \ + apt-get autoremove -y && \ + rm -rf /src/* /tmp/* /var/lib/apt/lists/* + +COPY rootfs/ / +COPY --from=builder /tmp/acars-bridge/acars-bridge /opt/acars-bridge + +# ENTRYPOINT [ "/init" ] + +# Add healthcheck +HEALTHCHECK --start-period=3600s --interval=600s CMD /scripts/healthcheck.sh diff --git a/rootfs/rename_current_arch_binary.sh b/rootfs/rename_current_arch_binary.sh new file mode 100755 index 0000000..0d666ef --- /dev/null +++ b/rootfs/rename_current_arch_binary.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +set -x + +ls -la /opt/ + +# determine which binary to keep +if /opt/acars-bridge.amd64 --version > /dev/null 2>&1; then + mv -v /opt/acars-bridge.amd64 /opt/acars-bridge +elif /opt/acars-bridge.arm64 --version > /dev/null 2>&1; then + mv -v /opt/acars-bridge.arm64 /opt/acars-bridge +elif /opt/acars-bridge.armv7 --version > /dev/null 2>&1; then + mv -v /opt/acars-bridge.armv7 /opt/acars-bridge +else + >&2 echo "ERROR: Unsupported architecture" + exit 1 +fi From 40f40a2a78860103ddbceebb964d24996c6c7bf3 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Sat, 6 Jan 2024 11:56:36 -0700 Subject: [PATCH 23/32] Update deploy.yml --- .github/workflows/deploy.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 4be0ecc..5a14a3a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -59,7 +59,7 @@ jobs: uses: actions/checkout@v4.1.1 with: fetch-depth: 0 - repository: https://github.com/sdr-enthusiasts/acars-bridge.git + repository: sdre-enthusiasts/acars-bridge - name: Run Docker on tmpfs uses: JonasAlfredsson/docker-on-tmpfs@v1 @@ -100,7 +100,7 @@ jobs: uses: actions/checkout@v4.1.1 with: fetch-depth: 0 - repository: https://github.com/sdr-enthusiasts/acars-bridge.git + repository: sdre-enthusiasts/acars-bridge - name: Run Docker on tmpfs uses: JonasAlfredsson/docker-on-tmpfs@v1 @@ -141,7 +141,7 @@ jobs: uses: actions/checkout@v4.1.1 with: fetch-depth: 0 - repository: https://github.com/sdr-enthusiasts/acars-bridge.git + repository: sdre-enthusiasts/acars-bridge - name: Run Docker on tmpfs uses: JonasAlfredsson/docker-on-tmpfs@v1 From edffafc6dae6ec19b0951b71b8ddf4e9c241bb3a Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Sat, 6 Jan 2024 11:57:45 -0700 Subject: [PATCH 24/32] Update deploy.yml --- .github/workflows/deploy.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 5a14a3a..4561bd2 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -59,7 +59,7 @@ jobs: uses: actions/checkout@v4.1.1 with: fetch-depth: 0 - repository: sdre-enthusiasts/acars-bridge + repository: sdr-enthusiasts/acars-bridge - name: Run Docker on tmpfs uses: JonasAlfredsson/docker-on-tmpfs@v1 @@ -100,7 +100,7 @@ jobs: uses: actions/checkout@v4.1.1 with: fetch-depth: 0 - repository: sdre-enthusiasts/acars-bridge + repository: sdr-enthusiasts/acars-bridge - name: Run Docker on tmpfs uses: JonasAlfredsson/docker-on-tmpfs@v1 @@ -141,7 +141,7 @@ jobs: uses: actions/checkout@v4.1.1 with: fetch-depth: 0 - repository: sdre-enthusiasts/acars-bridge + repository: sdr-enthusiasts/acars-bridge - name: Run Docker on tmpfs uses: JonasAlfredsson/docker-on-tmpfs@v1 From ace1e24c959d37d1aa81e239c11175a46e1bec7d Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Sat, 6 Jan 2024 11:58:54 -0700 Subject: [PATCH 25/32] Delete Dockerfile.build_binary --- Dockerfile.build_binary | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 Dockerfile.build_binary diff --git a/Dockerfile.build_binary b/Dockerfile.build_binary deleted file mode 100644 index 4c119ea..0000000 --- a/Dockerfile.build_binary +++ /dev/null @@ -1,13 +0,0 @@ -FROM rust:1.74.1-bullseye as builder -ENV CARGO_NET_GIT_FETCH_WITH_CLI=true -WORKDIR /tmp/acars-bridge -# hadolint ignore=DL3008,DL3003,SC1091,DL3009 -RUN set -x && \ - apt-get update && \ - apt-get install -y --no-install-recommends libzmq3-dev -COPY . . - -RUN cargo build --release - -FROM scratch -COPY --from=builder /tmp/acars-bridge/target/release/acars-bridge /acars-bridge From b809a4bb1c27cea96b85dd24624861c36505ec27 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Sat, 6 Jan 2024 12:22:20 -0700 Subject: [PATCH 26/32] Update Dockerfile --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1b45ced..3781344 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,9 +16,9 @@ ENV DEVICE_INDEX="" \ SHELL ["/bin/bash", "-o", "pipefail", "-c"] COPY ./rootfs / -COPY ./bin/acars-bride.armv7/acars_router /opt/acars_bridge.armv7 -COPY ./bin/acars_bridge.arm64/acars_router /opt/acars_bridge.arm64 -COPY ./bin/acars_bridge.amd64/acars_router /opt/acars_bridge.amd64 +COPY ./bin/acars-bride.armv7/acars-bridge /opt/acars_bridge.armv7 +COPY ./bin/acars_bridge.arm64/acars-bridge /opt/acars_bridge.arm64 +COPY ./bin/acars_bridge.amd64/acars-bridge /opt/acars_bridge.amd64 # hadolint ignore=DL3008,SC2086,SC2039 RUN set -x && \ From 3ad67f25825a7c94aa1b1e181346fa080f311fb0 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Sat, 6 Jan 2024 12:26:23 -0700 Subject: [PATCH 27/32] update test-pr to use the modern build --- .github/workflows/test-pr.yml | 202 ++++++++++++++++++++++++++++------ 1 file changed, 167 insertions(+), 35 deletions(-) diff --git a/.github/workflows/test-pr.yml b/.github/workflows/test-pr.yml index a784085..fce0557 100644 --- a/.github/workflows/test-pr.yml +++ b/.github/workflows/test-pr.yml @@ -1,64 +1,196 @@ -name: Test PR +name: Deploy -# FIXME: Can we not build either job if stuff has been unchanged since last commit for that job? -# FIXME: Use branch name for tagging docker build on: - pull_request: + # Build and deploy the image on pushes to main branch + push: branches: - main paths: - - rootfs/** - - .github/workflows/test-pr.yml + - "rust/**" + - "Dockerfile" + - "Dockerfile.build_binary" + - "rootfs/**" env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} jobs: - deploy_ghcr_latest: - name: Deploy Test to ghcr.io + binary_build_armv7: + name: Build Binary - armv7 runs-on: ubuntu-latest - permissions: - contents: read - packages: write + # needs: test_rust_functionality steps: - # Check out our code - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v4.1.1 + with: + fetch-depth: 0 + repository: sdr-enthusiasts/acars-bridge + + - name: Run Docker on tmpfs + uses: JonasAlfredsson/docker-on-tmpfs@v1 + with: + tmpfs_size: 5 + swap_size: 4 + swap_location: "/mnt/swapfile" - # Set up QEMU for multi-arch builds - name: Set up QEMU uses: docker/setup-qemu-action@v3 - # Log into ghcr (so we can push images) - - name: Login to ghcr.io - uses: docker/login-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build armv7 + uses: docker/build-push-action@v5 + with: + context: . + push: false + file: Dockerfile.build_binary + tags: acars-bridge:armv7 + platforms: linux/arm/v7 + outputs: type=local,dest=./image_armv7/ + + - name: Upload artifact armv7 binary + uses: actions/upload-artifact@v4.0.0 + with: + name: acars-bridge.armv7 + path: ./image_armv7/acars-bridge + + binary_build_arm64: + name: Build Binary - arm64 + runs-on: ubuntu-latest + # needs: test_rust_functionality + + steps: + - name: Checkout + uses: actions/checkout@v4.1.1 + with: + fetch-depth: 0 + repository: sdr-enthusiasts/acars-bridge + + - name: Run Docker on tmpfs + uses: JonasAlfredsson/docker-on-tmpfs@v1 + with: + tmpfs_size: 5 + swap_size: 4 + swap_location: "/mnt/swapfile" + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build arm64 + uses: docker/build-push-action@v5 + with: + context: . + push: false + file: Dockerfile.build_binary + tags: acars-bridge:arm64 + platforms: linux/arm64 + outputs: type=local,dest=./image_arm64/ + + - name: Upload artifact arm64 binary + uses: actions/upload-artifact@v4.0.0 + with: + name: acars-bridge.arm64 + path: ./image_arm64/acars-bridge + + binary_build_amd64: + name: Build Binary - amd64 + runs-on: ubuntu-latest + # needs: test_rust_functionality + + steps: + - name: Checkout + uses: actions/checkout@v4.1.1 with: - registry: ${{ env.REGISTRY }} - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} + fetch-depth: 0 + repository: sdr-enthusiasts/acars-bridge - # Get metadata from repo - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v5 + - name: Run Docker on tmpfs + uses: JonasAlfredsson/docker-on-tmpfs@v1 with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tmpfs_size: 5 + swap_size: 4 + swap_location: "/mnt/swapfile" + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 - # Set up buildx for multi platform builds - name: Set up Docker Buildx - id: buildx uses: docker/setup-buildx-action@v3 - # Build & Push Dockerfile (test) - - name: Build & Push ghcr.io/sdr-enthusiasts/docker-acarsdec:test + - name: Build amd64 uses: docker/build-push-action@v5 with: context: . - file: ./Dockerfile - no-cache: true - platforms: linux/386,linux/amd64,linux/arm/v7,linux/arm/v6,linux/arm64 - push: true - tags: ghcr.io/sdr-enthusiasts/docker-acarsdec:test - labels: ${{ steps.meta.outputs.labels }} + push: false + file: Dockerfile.build_binary + tags: acars-bridge:amd64 + platforms: linux/amd64 + outputs: type=local,dest=./image_amd64/ + + - name: Upload artifact amd64 binary + uses: actions/upload-artifact@v4.0.0 + with: + name: acars-bridge.amd64 + path: ./image_amd64/acars-bridge + + consolidate_binaries: + name: Consolidate & Cache Binaries + runs-on: ubuntu-latest + needs: [binary_build_amd64, binary_build_arm64, binary_build_armv7] + steps: + - run: mkdir -p ./bin + + - uses: actions/download-artifact@v4.0.0 + with: + name: acars-bridge.amd64 + path: ./bin/acars-bridge.amd64 + + - uses: actions/download-artifact@v4.0.0 + with: + name: acars-bridge.armv7 + path: ./bin/acars-bridge.armv7 + + - uses: actions/download-artifact@v4.0.0 + with: + name: acars-bridge.arm64 + path: ./bin/acars-bridge.arm64 + + - run: ls -la ./bin/* + + - name: Cache Binaries + uses: actions/cache@v3 + with: + path: ./bin/ + key: ${{ github.run_id }} + + deploy_test: + name: Deploy as test + needs: [consolidate_binaries] + uses: sdr-enthusiasts/common-github-workflows/.github/workflows/build_and_push_image.yml@main + with: + push_enabled: false + push_destinations: ghcr.io + ghcr_repo_owner: ${{ github.repository_owner }} + ghcr_repo: ${{ github.repository }} + build_with_tmpfs: true + get_version_method: git_commit_hash_short + # set build_latest to true if github.event.inputs.use_test_image is false + build_latest: true + docker_latest_tag: test + build_baseimage_test: false + # only build the entire stack if we are not using the test image + build_version_specific: false + build_platform_specific: false + build_nohealthcheck: false + build_baseimage_url: :acars-decoder/:acars-decoder-test-pr + cache_enabled: true + cache_path: ./bin/ + cache_key: ${{ github.run_id }} + secrets: + ghcr_token: ${{ secrets.GITHUB_TOKEN }} From 76d1bc558ae02107956cf6226b9b40ecf3015dea Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Sat, 6 Jan 2024 13:04:58 -0700 Subject: [PATCH 28/32] Update Dockerfile --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3781344..2518f50 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,9 +16,9 @@ ENV DEVICE_INDEX="" \ SHELL ["/bin/bash", "-o", "pipefail", "-c"] COPY ./rootfs / -COPY ./bin/acars-bride.armv7/acars-bridge /opt/acars_bridge.armv7 -COPY ./bin/acars_bridge.arm64/acars-bridge /opt/acars_bridge.arm64 -COPY ./bin/acars_bridge.amd64/acars-bridge /opt/acars_bridge.amd64 +COPY ./bin/acars-bride.armv7/acars-bridge /opt/acars-bridge.armv7 +COPY ./bin/acars-bridge.arm64/acars-bridge /opt/acars-bridge.arm64 +COPY ./bin/acars-bridge.amd64/acars-bridge /opt/acars-bridge.amd64 # hadolint ignore=DL3008,SC2086,SC2039 RUN set -x && \ From 55d631212a270f07699da1c6714fcb7a2b5268c4 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Sat, 6 Jan 2024 13:37:30 -0700 Subject: [PATCH 29/32] Update Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 2518f50..374f4b7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,7 @@ ENV DEVICE_INDEX="" \ SHELL ["/bin/bash", "-o", "pipefail", "-c"] COPY ./rootfs / -COPY ./bin/acars-bride.armv7/acars-bridge /opt/acars-bridge.armv7 +COPY ./bin/acars-bridge.armv7/acars-bridge /opt/acars-bridge.armv7 COPY ./bin/acars-bridge.arm64/acars-bridge /opt/acars-bridge.arm64 COPY ./bin/acars-bridge.amd64/acars-bridge /opt/acars-bridge.amd64 From 3327c9a2e1a8a4a8d40a0d38d8411cb405df9a6f Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Sat, 6 Jan 2024 14:00:05 -0700 Subject: [PATCH 30/32] Update Dockerfile --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 374f4b7..2fbbcb0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -50,6 +50,7 @@ RUN set -x && \ /rename_current_arch_binary.sh && \ rm -fv \ /opt/acars-bridge.* \ + && \ # install sdrplay curl --location --output /tmp/install_sdrplay.sh https://raw.githubusercontent.com/sdr-enthusiasts/install-libsdrplay/main/install_sdrplay.sh && \ chmod +x /tmp/install_sdrplay.sh && \ From fdee7fb99e97b25265f71cab0054d20fe4271fed Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Sun, 7 Jan 2024 08:47:35 -0700 Subject: [PATCH 31/32] Update 01-acarsdec --- rootfs/etc/s6-overlay/scripts/01-acarsdec | 5 ----- 1 file changed, 5 deletions(-) diff --git a/rootfs/etc/s6-overlay/scripts/01-acarsdec b/rootfs/etc/s6-overlay/scripts/01-acarsdec index 4842cd7..705d121 100755 --- a/rootfs/etc/s6-overlay/scripts/01-acarsdec +++ b/rootfs/etc/s6-overlay/scripts/01-acarsdec @@ -53,11 +53,6 @@ if [[ "${MODE}" != @(J|j|P|p|A|a) ]]; then exit 1 fi -if [[ -n "${SERVER}" && -z "${SERVER_PORT}" ]]; then - "${s6wrap[@]}" echo "SERVER is set but SERVER_PORT is not set, exiting" - exit 1 -fi - # Make sure GAIN is valid (if set) if [[ -n "${GAIN}" ]] && [[ "$(awk '{if ($1 > 0 && $1 < 100) printf "%i", $1 * 10; else printf "%i", $1;}' <<< "${GAIN}")" == "0" ]]; then "${s6wrap[@]}" echo "GAIN is not valid, exiting" From 4d0fc3a8327a4edfae698fa182ca11153903e156 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Sun, 7 Jan 2024 16:35:22 -0700 Subject: [PATCH 32/32] Update LICENSE --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 0c1ffcc..c506185 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 Fred Clausen +Copyright (C) 2022-2024 Fred Clausen Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal