Skip to content

Commit

Permalink
add nginx to serve stats.json (sdr-enthusiasts#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
wiedehopf committed May 9, 2024
1 parent aed7c7d commit 841cc5b
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
FROM ghcr.io/sdr-enthusiasts/docker-baseimage:base

COPY rootfs/ /

# hadolint ignore=DL3008,DL3003,SC1091
RUN set -x && \
#
# Install libusb
KEPT_PACKAGES=() && \
KEPT_PACKAGES+=(nginx-light) && \
KEPT_PACKAGES+=(libusb-1.0.0) && \
apt-get update -y && \
apt-get install --no-install-recommends -y libusb-1.0-0 && \
apt-get install --no-install-recommends -y \
${KEPT_PACKAGES[@]} \
&& \
#
# Download airspy_adsb arm binary
curl \
Expand Down Expand Up @@ -88,6 +90,8 @@ RUN set -x && \
apt-get -v clean && \
rm -rfv /tmp/* /var/lib/apt/lists/*

COPY rootfs/ /

EXPOSE 30005

HEALTHCHECK --interval=60s --timeout=60s --start-period=30s --retries=3 CMD [ "/scripts/healthcheck.sh" ]
34 changes: 34 additions & 0 deletions rootfs/etc/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
user www-data;
worker_processes 1;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
daemon off;

events {
use epoll;
worker_connections 32;
}

error_log off;

http {
server_tokens off;
include mime.types;
charset utf-8;

access_log off;

server {
server_name _;
listen 80 default_server;
root /var/www/html

error_page 500 502 503 504 /50x.html;

location / {
alias /run/airspy_adsb;
}

}

}
Empty file.
2 changes: 2 additions & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/nginx/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec /etc/s6-overlay/scripts/nginx
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/s6-rc.d/nginx/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
1 change: 1 addition & 0 deletions rootfs/etc/s6-overlay/scripts/airspy_adsb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ fi

# Handle "-S"
if chk_enabled "${AIRSPY_ADSB_STATS}"; then
mkdir -p /run/airspy_adsb
AIRSPY_ADSB_CMD+=("-S" "/run/airspy_adsb/stats.json")
fi

Expand Down
10 changes: 10 additions & 0 deletions rootfs/etc/s6-overlay/scripts/nginx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/command/with-contenv bash
# shellcheck shell=bash disable=SC1091

source /scripts/common

if ! chk_enabled "${AIRSPY_ADSB_STATS}"; then
exec sleep infinity
fi

exec s6wrap --quiet --prepend=nginx --timestamps --args /usr/sbin/nginx

0 comments on commit 841cc5b

Please sign in to comment.