Skip to content
This repository has been archived by the owner on Jul 3, 2024. It is now read-only.

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasreiser committed Apr 28, 2020
1 parent 8f7f151 commit a0f4437
Show file tree
Hide file tree
Showing 18 changed files with 44 additions and 120 deletions.
53 changes: 24 additions & 29 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ RUN git clone -b ${DUMP1090_VERSION} --depth 1 https://github.com/flightaware/du
## TEMPORARY DOCKER IMAGE TO BUILD TCL-TLS
##
##################################################################
FROM multiarch/debian-debootstrap:armhf-buster as tcltls
FROM multiarch/debian-debootstrap:armhf-buster-slim as tcltls

ENV DEBIAN_VERSION buster

Expand Down Expand Up @@ -63,7 +63,7 @@ RUN ./prepare-build.sh ${DEBIAN_VERSION} && \
## TEMPORARY DOCKER IMAGE TO BUILD PIAWARE
##
##################################################################
FROM multiarch/debian-debootstrap:armhf-buster as piaware
FROM multiarch/debian-debootstrap:armhf-buster-slim as piaware

ENV DEBIAN_VERSION buster
ENV PIAWARE_VERSION v3.8.1
Expand Down Expand Up @@ -111,7 +111,7 @@ RUN dpkg -i tcl-tls_*.deb && \
## TEMPORARY DOCKER IMAGE TO BUILD CONFD
##
##################################################################
FROM multiarch/debian-debootstrap:armhf-buster as confd
FROM multiarch/debian-debootstrap:armhf-buster-slim as confd

ENV CONFD_VERSION v0.16.0

Expand Down Expand Up @@ -141,7 +141,7 @@ RUN git clone -b ${CONFD_VERSION} --depth 1 https://github.com/kelseyhightower/c
## FINAL DOCKER IMAGE TO BE USED
##
##################################################################
FROM multiarch/debian-debootstrap:armhf-buster-slim as serve
FROM multiarch/debian-debootstrap:armhf-buster-slim as flightfeedr

ENV DEBIAN_VERSION buster
ENV RTL_SDR_VERSION 0.6.0
Expand All @@ -151,6 +151,8 @@ ENV S6_OVERLAY_VERSION v1.22.1.0

LABEL maintainer="[email protected]"

WORKDIR /tmp

RUN apt-get update -y && \
apt-get install -y \
nano \
Expand Down Expand Up @@ -184,7 +186,6 @@ RUN apt-get update -y && \
rm -rf /var/lib/apt/lists/*

# RTL-SDR
WORKDIR /tmp
RUN mkdir -p /etc/modprobe.d && \
echo 'blacklist r820t' >> /etc/modprobe.d/raspi-blacklist.conf && \
echo 'blacklist rtl2832' >> /etc/modprobe.d/raspi-blacklist.conf && \
Expand All @@ -200,55 +201,49 @@ RUN mkdir -p /etc/modprobe.d && \
rm -rf /tmp/rtl-sdr

# DUMP1090
WORKDIR /tmp
RUN mkdir -p /usr/lib/fr24/public_html/data
COPY --from=dump1090 /tmp/dump1090/dump1090 /usr/lib/fr24/
COPY --from=dump1090 /tmp/dump1090/public_html /usr/lib/fr24/public_html
RUN rm /usr/lib/fr24/public_html/config.js

# PIAWARE
WORKDIR /tmp
COPY --from=tcltls /tmp/tcltls-rebuild /tmp
COPY --from=piaware /tmp/piaware_builder /tmp
RUN dpkg -i tcl-tls_*.deb && \
dpkg -i piaware_*_*.deb && \
rm /etc/piaware.conf

# CONFD
COPY --from=confd /tmp/confd/bin/confd /opt/confd/bin/confd

# FR24FEED
WORKDIR /opt/fr24feed/bin
ADD https://repo-feed.flightradar24.com/rpi_binaries/fr24feed_${FR24FEED_VERSION}_armhf.tgz /opt/fr24feed/bin
RUN tar -xzf fr24feed_*_armhf.tgz && \
mv fr24feed_armhf/* . && \
rm -r fr24feed_armhf/ && \
rm fr24feed_*_armhf.tgz
RUN wget -U "Debian APT-HTTP/1.3" https://repo-feed.flightradar24.com/rpi_binaries/fr24feed_${FR24FEED_VERSION}_armhf.tgz && \
tar -xzf fr24feed_*_armhf.tgz && \
mkdir -p /opt/fr24feed/bin
mv fr24feed_armhf/fr24feed /opt/fr24feed/bin

# RBFEEDER
WORKDIR /tmp
RUN wget -U "Debian APT-HTTP/1.3" https://apt.rb24.com/pool/main/r/rbfeeder/rbfeeder_${RBFEEDER_VERSION}_armhf.deb && \
ar x rbfeeder_*_armhf.deb && \
rm rbfeeder_*_armhf.deb && \
rm control.tar* && \
rm debian-binary && \
tar -xf data.tar* && \
rm data.tar* && \
rm -r lib/ && \
rm -r etc/ && \
mkdir -p /opt/rbfeeder/bin && \
cp usr/bin/* /opt/rbfeeder/bin && \
rm -r usr/
mv usr/bin/* /opt/rbfeeder/bin

# OPENSKYD
RUN wget https://opensky-network.org/files/firmware/opensky-feeder_${OPENSKYD_VERSION}_armhf.deb && \
ar x openskyd.deb && \
tar -xf data.tar* && \
mkdir -p /opt/openskyd/bin && \
mv usr/bin/openskyd-dump1090 /opt/openskyd/bin/openskyd

# CONFD
COPY --from=confd /tmp/confd/bin/confd /opt/confd/bin/confd

# S6 OVERLAY
ADD https://github.com/just-containers/s6-overlay/releases/download/${S6_OVERLAY_VERSION}/s6-overlay-armhf.tar.gz /tmp/
RUN tar xzf /tmp/s6-overlay-armhf.tar.gz -C / && \
rm /tmp/s6-overlay-armhf.tar.gz
RUN wget https://github.com/just-containers/s6-overlay/releases/download/${S6_OVERLAY_VERSION}/s6-overlay-armhf.tar.gz && \
tar xzf s6-overlay-armhf.tar.gz -C / && \
COPY /root /

# CLEANUP
RUN rm -r /tmp/*

EXPOSE 8754 8080 30001 30002 30003 30004 30005 30104
EXPOSE 8754 8080

ENTRYPOINT ["/init"]
13 changes: 1 addition & 12 deletions root/etc/confd/fr24feed/templates/fr24feed.ini.tmpl
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
{{- range gets "/*" }}
{{base .Key }}="{{ .Value }}"
{{- end }}
{{- range gets "/*/dash/*" }}
{{base (dir (dir .Key))}}-{{base .Key }}="{{ .Value }}"
{{- end }}
{{- range gets "/*/dash/*/dash/*" }}
{{base (dir (dir (dir (dir .Key))))}}-{{base (dir (dir .Key))}}-{{base .Key }}="{{ .Value }}"
{{- end }}
{{- range gets "/*/dash/*/dash/*/dash/*" }}
{{base (dir (dir (dir (dir (dir (dir .Key))))))}}-{{base (dir (dir (dir (dir .Key))))}}-{{base (dir (dir .Key))}}-{{base .Key }}="{{ .Value }}"
{{- end }}
fr24key="{{getv "/key"}}"
receiver="beast-tcp"
host="127.0.0.1:30005"
bs="no"
Expand Down
19 changes: 1 addition & 18 deletions root/etc/confd/piaware/templates/piaware.conf.tmpl
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
# This file configures piaware and related software.
# You can edit it directly or use piaware-config from the command line
# to view and change settings.
#
# If /boot/piaware-config.txt also exists, then settings present in
# that file will override settings in this file.
{{- range gets "/*" }}
{{base .Key }} {{ .Value }}
{{- end }}
{{- range gets "/*/dash/*" }}
{{base (dir (dir .Key))}}-{{base .Key }} {{ .Value }}
{{- end }}
{{- range gets "/*/dash/*/dash/*" }}
{{base (dir (dir (dir (dir .Key))))}}-{{base (dir (dir .Key))}}-{{base .Key }} {{ .Value }}
{{- end }}
{{- range gets "/*/dash/*/dash/*/dash/*" }}
{{base (dir (dir (dir (dir (dir (dir .Key))))))}}-{{base (dir (dir (dir (dir .Key))))}}-{{base (dir (dir .Key))}}-{{base .Key }} {{ .Value }}
{{- end }}
feeder-id {{getv "/key"}}
receiver-host 127.0.0.1
receiver-port 30005
receiver-type other
11 changes: 0 additions & 11 deletions root/etc/cont-init.d/01-confd-fr24feed
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
#!/usr/bin/with-contenv bash

default_value()
{
key=${1//\-/_DASH_}
key=FR24FEED_${key^^}
eval "value=\${$key:-\$2}"
printf -v $key -- "$value"
export $key
}

default_value "fr24key" "YOUR_KEY_HERE"

if [ ! -f /etc/fr24feed.ini ]; then
/opt/confd/bin/confd -onetime -confdir "/etc/confd/fr24feed" -prefix "fr24feed" -backend env
fi
11 changes: 0 additions & 11 deletions root/etc/cont-init.d/02-confd-piaware
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
#!/usr/bin/with-contenv bash

default_value()
{
key=${1//\-/_DASH_}
key=PIAWARE_${key^^}
eval "value=\${$key:-\$2}"
printf -v $key -- "$value"
export $key
}

default_value "feeder-id" "YOUR_FEEDER_ID"

if [ ! -f /etc/piaware.conf ]; then
/opt/confd/bin/confd -onetime -confdir "/etc/confd/piaware" -prefix "piaware" -backend env
fi
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
#!/usr/bin/with-contenv bash

default_value()
{
key=${1//\-/_DASH_}
key=RBFEEDER_${key^^}
eval "value=\${$key:-\$2}"
printf -v $key -- "$value"
export $key
}

default_value "key" ""

if [ ! -f /etc/rbfeeder.ini ]; then
/opt/confd/bin/confd -onetime -confdir "/etc/confd/rbfeeder" -prefix "rbfeeder" -backend env
fi
20 changes: 0 additions & 20 deletions root/etc/cont-init.d/04-confd-upintheair

This file was deleted.

File renamed without changes.
3 changes: 2 additions & 1 deletion root/etc/services.d/dump1090/finish
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/usr/bin/execlineb -S0
s6-svscanctl -t /var/run/s6/services

#s6-svscanctl -t /var/run/s6/services
9 changes: 5 additions & 4 deletions root/etc/services.d/dump1090/run
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
#!/usr/bin/with-contenv bash

if [ "$SERVICE_ENABLE_DUMP1090" != "false" ]
then
default_value()
{
key=${1//\-/_DASH_}
key=HTML_${key^^}
key=SITE_${key^^}
eval "value=\${$key:-\$2}"
printf -v $key -- "$value"
export $key
}

default_value "site_lat" "45.0"
default_value "site_lon" "9.0"
default_value "lat" "45.0"
default_value "lon" "9.0"

/usr/lib/fr24/dump1090 --net --mlat --write-json /usr/lib/fr24/public_html/data --raw --quiet --lat ${HTML_SITE_LAT} --lon ${HTML_SITE_LON} --gain -10
/opt/dump1090/bin/dump1090 --net --mlat --write-json /usr/lib/fr24/public_html/data --raw --quiet --lat ${SITE_LAT} --lon ${SITE_LON} --gain -10
else
tail -f /dev/null
fi
3 changes: 2 additions & 1 deletion root/etc/services.d/fr24feed/finish
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/usr/bin/execlineb -S0
s6-svscanctl -t /var/run/s6/services

#s6-svscanctl -t /var/run/s6/services
1 change: 1 addition & 0 deletions root/etc/services.d/fr24feed/run
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/with-contenv bash

if [ "$SERVICE_ENABLE_FR24FEED" != "false" ]
then
/opt/fr24feed/bin/fr24feed
Expand Down
1 change: 1 addition & 0 deletions root/etc/services.d/http/finish
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/usr/bin/execlineb -S0

s6-svscanctl -t /var/run/s6/services
1 change: 1 addition & 0 deletions root/etc/services.d/http/run
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/with-contenv bash

if [ "$SERVICE_ENABLE_HTTP" != "false" ]
then
cd /usr/lib/fr24/public_html
Expand Down
3 changes: 2 additions & 1 deletion root/etc/services.d/piaware/finish
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/usr/bin/execlineb -S0
s6-svscanctl -t /var/run/s6/services

#s6-svscanctl -t /var/run/s6/services
1 change: 1 addition & 0 deletions root/etc/services.d/piaware/run
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/with-contenv bash

if [ "$SERVICE_ENABLE_PIAWARE" != "false" ]
then
/usr/bin/piaware -plainlog
Expand Down
3 changes: 2 additions & 1 deletion root/etc/services.d/rbfeeder/finish
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/usr/bin/execlineb -S0
s6-svscanctl -t /var/run/s6/services

#s6-svscanctl -t /var/run/s6/services
1 change: 1 addition & 0 deletions root/etc/services.d/rbfeeder/run
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/with-contenv bash

if [ "$SERVICE_ENABLE_RBFEEDER" != "false" ]
then
/opt/rbfeeder/bin/rbfeeder
Expand Down

0 comments on commit a0f4437

Please sign in to comment.