diff --git a/Dockerfile b/Dockerfile index cad954b..7c41fb5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,23 @@ FROM ghcr.io/sdr-enthusiasts/docker-baseimage:mlatclient as downloader -FROM ghcr.io/sdr-enthusiasts/docker-baseimage:python +FROM ghcr.io/sdr-enthusiasts/docker-baseimage:base ENV PRIVATE_MLAT="false" \ MLAT_INPUT_TYPE="dump1090" -COPY --from=downloader /mlatclient.tgz /src/mlatclient.tgz +ARG VERSION_REPO="sdr-enthusiasts/docker-radarvirtuel" \ +VERSION_BRANCH="##BRANCH##" -# hadolint ignore=DL3008,SC2086,SC2039,SC2068,DL3003,DL3015,SC3054 -RUN set -x && \ +SHELL ["/bin/bash", "-x", "-o", "pipefail", "-c"] +RUN --mount=type=bind,from=downloader,source=/,target=/downloader/ \ # define packages needed for installation and general management of the container: TEMP_PACKAGES=() && \ KEPT_PACKAGES=() && \ - KEPT_PACKAGES+=(procps aptitude) && \ + KEPT_PACKAGES+=(procps) && \ KEPT_PACKAGES+=(psmisc) && \ - # Git and net-tools are needed to install and run @Mikenye's HealthCheck framework - # TEMP_PACKAGES+=(git) && \ - # These are needed to compile and install the mlat_client: - # TEMP_PACKAGES+=(build-essential) && \ - # TEMP_PACKAGES+=(debhelper) && \ - # TEMP_PACKAGES+=(python3-dev) && \ - # TEMP_PACKAGES+=(python3-distutils-extra) && \ + # Needed to run the mlat_client: + KEPT_PACKAGES+=(python3-minimal) && \ + KEPT_PACKAGES+=(python3-pkg-resources) && \ # # Install all these packages: apt-get update -q -y && \ @@ -28,18 +25,15 @@ RUN set -x && \ ${KEPT_PACKAGES[@]} \ ${TEMP_PACKAGES[@]} && \ # - # Compile and Install the mlat_client - # mkdir -p /git && \ - # pushd /git && \ - # git clone --depth 1 $URL_MLAT_CLIENT_REPO && \ - # cd mlat-client && \ - # ./setup.py install && \ - # ln -s /usr/local/bin/mlat-client /usr/bin/mlat-client && \ - # popd && \ - # rm -rf /git && \ - # - # New - install mlatclient that was copied in from downloader image - tar zxf /src/mlatclient.tgz -C / && \ + # Install mlatclient that was copied in from downloader image + tar zxf /downloader/mlatclient.tgz -C / && \ + # test mlat-client + /usr/bin/mlat-client --help > /dev/null && \ + # remove pycache introduced by testing mlat-client + find /usr | grep -E "/__pycache__$" | xargs rm -rf || true && \ + # Add Container Version + [[ "${VERSION_BRANCH:0:1}" == "#" ]] && VERSION_BRANCH="main" || true && \ + echo "$(TZ=UTC date +%Y%m%d-%H%M%S)_$(curl -ssL https://api.github.com/repos/$VERSION_REPO/commits/$VERSION_BRANCH | awk '{if ($1=="\"sha\":") {print substr($2,2,7); exit}}')_$VERSION_BRANCH" > /.CONTAINER_VERSION && \ # # Clean up # apt-get remove -q -y ${TEMP_PACKAGES[@]} && \ diff --git a/rootfs/etc/s6-overlay/s6-rc.d/01-print-container-version/type b/rootfs/etc/s6-overlay/s6-rc.d/01-print-container-version/type new file mode 100644 index 0000000..bdd22a1 --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/01-print-container-version/type @@ -0,0 +1 @@ +oneshot diff --git a/rootfs/etc/s6-overlay/s6-rc.d/01-print-container-version/up b/rootfs/etc/s6-overlay/s6-rc.d/01-print-container-version/up new file mode 100755 index 0000000..984224c --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/01-print-container-version/up @@ -0,0 +1,2 @@ +#!/bin/sh +exec /etc/s6-overlay/scripts/01-print-container-version diff --git a/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/01-print-container-version b/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/01-print-container-version new file mode 100644 index 0000000..e69de29 diff --git a/rootfs/etc/s6-overlay/scripts/01-print-container-version b/rootfs/etc/s6-overlay/scripts/01-print-container-version new file mode 100755 index 0000000..7611e06 --- /dev/null +++ b/rootfs/etc/s6-overlay/scripts/01-print-container-version @@ -0,0 +1,23 @@ +#!/command/with-contenv bash +# shellcheck shell=bash disable=SC1091,SC2015,SC2154 + +source /scripts/common + +# Print container version +#--------------------------------------------------------------------------------------------- +# Copyright (C) 2023-2024, Ramon F. Kolb (kx1t) and contributors +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with this program. +# If not, see . +#--------------------------------------------------------------------------------------------- + +[[ -f /.CONTAINER_VERSION ]] && "${s6wrap[@]}" echo "Container Version: $(