Skip to content

Commit

Permalink
chore(build): do only one big RUN and one big COPY, to decrease image…
Browse files Browse the repository at this point in the history
… size (#76)

* chore(build): do only one big RUN and one big COPY, to decrease image size
* chore(build): remove unused packages
  • Loading branch information
Thom-x authored Mar 1, 2022
1 parent 8e2783a commit 31f3542
Showing 1 changed file with 39 additions and 24 deletions.
63 changes: 39 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,27 @@ RUN cd /thttpd \
&& ./configure \
&& make CCOPT='-O2 -s -static' thttpd

# CONFD
FROM debian:buster-slim as confd

ADD confd/confd.tar.gz /opt/confd/
RUN ARCH=$(dpkg --print-architecture) && \
cp "/opt/confd/bin/confd-$ARCH" /opt/confd/bin/confd && \
chmod +x /opt/confd/bin/confd && \
rm /opt/confd/bin/confd-*

# ONE STAGE COPY ALL
FROM debian:buster-slim as copyall

COPY --from=dump1090 /tmp/dump1090/dump1090 /copy_root/usr/lib/fr24/
COPY --from=dump1090 /tmp/dump1090/public_html_merged /copy_root/usr/lib/fr24/public_html
COPY --from=piaware /tmp/piaware_builder /copy_root/piaware_builder
RUN mv /copy_root/piaware_builder/piaware_*_*.deb /copy_root/piaware.deb && \
rm -rf /copy_root/piaware_builder
COPY --from=thttpd /thttpd/thttpd /copy_root/
COPY --from=confd /opt/confd/bin/confd /copy_root/opt/confd/bin/
ADD build /copy_root/build

FROM debian:buster-slim as serve

ENV DEBIAN_VERSION buster
Expand All @@ -99,6 +120,9 @@ ENV S6_OVERLAY_VERSION 3.0.0.2-2

LABEL maintainer="maugin.thomas@gmail.com"

# COPY ALL
COPY --from=copyall /copy_root/ /

RUN apt-get update && \
# rtl-sdr
apt-get install -y \
Expand Down Expand Up @@ -126,7 +150,6 @@ RUN apt-get update && \
pkg-config \
libncurses5-dev \
libbladerf-dev && \
rm -rf /var/lib/apt/lists/* && \
# RTL-SDR
cd /tmp && \
mkdir -p /etc/modprobe.d && \
Expand All @@ -144,13 +167,11 @@ RUN apt-get update && \
rm -rf /tmp/rtl-sdr && \
# Build & Install dependency tcl-tls from source code.
# Install dependencies
apt-get update && \
apt-get install -y \
libssl-dev \
tcl-dev \
chrpath \
netcat && \
rm -rf /var/lib/apt/lists/* && \
# Clone source code, build & Install tcl-tls
cd /tmp && \
git clone --depth 1 http://github.com/flightaware/tcltls-rebuild.git && \
Expand All @@ -160,40 +181,34 @@ RUN apt-get update && \
dpkg-buildpackage -b --no-sign && \
cd ../ && \
dpkg -i tcl-tls_*.deb && \
rm -rf /tmp/tcltls-rebuild

# COPY ALL
COPY --from=dump1090 /tmp/dump1090/dump1090 /usr/lib/fr24/
COPY --from=dump1090 /tmp/dump1090/public_html_merged /usr/lib/fr24/public_html
COPY --from=piaware /tmp/piaware_builder /tmp/piaware_builder
COPY --from=thttpd /thttpd/thttpd /
ADD build /build
ADD confd/confd.tar.gz /opt/confd/


rm -rf /tmp/tcltls-rebuild && \
# DUMP1090
RUN mkdir -p /usr/lib/fr24/public_html/data && \
mkdir -p /usr/lib/fr24/public_html/data && \
rm /usr/lib/fr24/public_html/config.js && \
rm /usr/lib/fr24/public_html/layers.js && \
# PIAWARE
cd /tmp/piaware_builder && \
dpkg -i piaware_*_*.deb && \
cd / && \
dpkg -i piaware.deb && \
rm /etc/piaware.conf && \
rm -rf /tmp/piaware_builder && \
rm /piaware.deb && \
# THTTPD
find /usr/lib/fr24/public_html -type d -print0 | xargs -0 chmod 0755 && \
find /usr/lib/fr24/public_html -type f -print0 | xargs -0 chmod 0644 && \
# FR24FEED
/build/fr24feed.sh && \
# CONFD
ARCH=$(dpkg --print-architecture) && \
cp "/opt/confd/bin/confd-$ARCH" /opt/confd/bin/confd && \
chmod +x /opt/confd/bin/confd && \
rm /opt/confd/bin/confd-* && \
# S6 OVERLAY
/build/s6-overlay.sh && \
# CLEAN
rm -rf /build
rm -rf /build && \
apt-get purge -y \
xz-utils \
devscripts \
pkg-config \
git-core \
cmake \
build-essential && \
apt autoremove -y && \
rm -rf /var/lib/apt/lists/*

COPY /root /

Expand Down

0 comments on commit 31f3542

Please sign in to comment.