From 39b54f67880b2f5373cd115216213fa098a2a48d Mon Sep 17 00:00:00 2001 From: Katia Esposito Date: Wed, 6 Sep 2023 20:40:48 +0200 Subject: [PATCH 1/5] Build container in one shot --- Dockerfile | 213 +++++++++++++++++++++++++++++++++ Dockerfile.acarshub | 40 ------- Dockerfile.acarshub-typescript | 26 ---- Dockerfile.nextgen | 44 ------- rootfs/webapp/acarshub.py | 6 +- rootfs/webapp/requirements.txt | 2 +- 6 files changed, 218 insertions(+), 113 deletions(-) create mode 100644 Dockerfile delete mode 100644 Dockerfile.acarshub delete mode 100644 Dockerfile.acarshub-typescript delete mode 100644 Dockerfile.nextgen diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..ff1f9ee4e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,213 @@ +# From https://github.com/sdr-enthusiasts/docker-baseimage/blob/bace2830cbb6d6de4bfe05a3116bc74cf5fea658/Dockerfile.base +FROM debian:bookworm-20230814-slim AS sdr-enthusiasts-baseimage + +ENV S6_BEHAVIOUR_IF_STAGE2_FAILS=2 \ + S6OVERLAY_VERSION="v3.1.5.0" \ + # Fix for any issues with the S6 overlay. We have quite a few legacy services + # that worked fine under v2, but v3 is more strict and will kill a startup process + # if it takes more than 5 seconds. tar1090 and rtlsdrairband are the hardest hit + # but we may have others. + S6_CMD_WAIT_FOR_SERVICES_MAXTIME="0" + +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +# hadolint ignore=DL3008,SC2086 +RUN set -x && \ + TEMP_PACKAGES=() && \ + KEPT_PACKAGES=() && \ + # packages needed to install + TEMP_PACKAGES+=(git) && \ + # logging + KEPT_PACKAGES+=(gawk) && \ + KEPT_PACKAGES+=(pv) && \ + # required for S6 overlay + # curl kept for healthcheck + TEMP_PACKAGES+=(file) && \ + KEPT_PACKAGES+=(curl) && \ + TEMP_PACKAGES+=(xz-utils) && \ + KEPT_PACKAGES+=(ca-certificates) && \ + # bc for scripts and healthchecks + KEPT_PACKAGES+=(bc) && \ + # packages for network stuff + KEPT_PACKAGES+=(socat) && \ + KEPT_PACKAGES+=(ncat) && \ + KEPT_PACKAGES+=(net-tools) && \ + KEPT_PACKAGES+=(wget) && \ + # process management + KEPT_PACKAGES+=(procps) && \ + # needed to compile s6wrap: + TEMP_PACKAGES+=(gcc) && \ + TEMP_PACKAGES+=(build-essential) && \ + # install packages + ## Builder fixes... + mkdir -p /usr/sbin/ && \ + ln -s /usr/bin/dpkg-split /usr/sbin/dpkg-split && \ + ln -s /usr/bin/dpkg-deb /usr/sbin/dpkg-deb && \ + ln -s /bin/tar /usr/sbin/tar && \ + apt-get update && \ + apt-get install -y --no-install-recommends \ + "${KEPT_PACKAGES[@]}" \ + "${TEMP_PACKAGES[@]}" \ + && \ + # install S6 Overlay + curl --location --output /tmp/deploy-s6-overlay.sh https://raw.githubusercontent.com/mikenye/deploy-s6-overlay/master/deploy-s6-overlay-v3.sh && \ + sh /tmp/deploy-s6-overlay.sh && \ + rm -f /tmp/deploy-s6-overlay.sh && \ + # deploy healthchecks framework + git clone \ + --depth=1 \ + https://github.com/mikenye/docker-healthchecks-framework.git \ + /opt/healthchecks-framework \ + && \ + rm -rf \ + /opt/healthchecks-framework/.git* \ + /opt/healthchecks-framework/*.md \ + /opt/healthchecks-framework/tests \ + && \ + # fix healthchecks framework pathing + sed -i 's/S6_SERVICE_PATH="\/run\/s6\/services"/S6_SERVICE_PATH="\/run\/s6\/legacy-services"/g' /opt/healthchecks-framework/checks/check_s6_service_abnormal_death_tally.sh && \ + # Add s6wrap + pushd /tmp && \ + git clone --depth=1 https://github.com/wiedehopf/s6wrap.git && \ + cd s6wrap && \ + make && \ + mv s6wrap /usr/local/bin && \ + popd && \ + # Add additional stuff + mkdir -p /scripts /etc/cont-init.d && \ + curl -sSL https://raw.githubusercontent.com/sdr-enthusiasts/Buster-Docker-Fixes/main/install_libseccomp2.sh | bash && \ + chmod +x /etc/s6-overlay/s6-rc.d/libseccomp2/up && \ + chmod +x /etc/s6-overlay/scripts/libseccomp2_check.sh && \ + curl -sSL https://raw.githubusercontent.com/sdr-enthusiasts/docker-baseimage/main/scripts/common -o /scripts/common && \ + # Clean up + apt-get remove -y "${TEMP_PACKAGES[@]}" && \ + apt-get autoremove -y && \ + rm -rf /src/* /tmp/* /var/lib/apt/lists/* + +ENTRYPOINT [ "/init" ] + + +FROM node:slim AS acarshub-typescript-builder +# pushd/popd +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +ENV DOCKER_BUILD="true" + +#hadolint ignore=DL3008 +RUN set -xe && \ + apt-get update && \ + apt-get install -y --no-install-recommends make python3 g++ && \ + rm -rf /src/* /tmp/* /var/lib/apt/lists/* + +COPY acarshub-typescript/package.json /acarshub-typescript/package.json +COPY acarshub-typescript/package-lock.json /acarshub-typescript/package-lock.json + +RUN set -xe && \ + pushd /acarshub-typescript && \ + npm install + +COPY acarshub-typescript/ /acarshub-typescript/ + +RUN set -xe && \ + pushd /acarshub-typescript && \ + mkdir -p /webapp/static/images && \ + mkdir -p /webapp/static/js && \ + mkdir -p /webapp/static/sounds && \ + mkdir -p /webapp/templates && \ + npm run build && \ + cp -r ./dist/static/images /webapp/static/ && \ + cp -r ./dist/static/sounds /webapp/static/ && \ + cp -r ./dist/static/js /webapp/static/ && \ + mv ./dist/static/index.html /webapp/templates/ + +FROM sdr-enthusiasts-baseimage +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +COPY rootfs/webapp/requirements.txt /src/requirements.txt + +# hadolint ignore=DL3008,SC2086,DL3042,DL3013,SC1091 +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+=(automake) && \ + TEMP_PACKAGES+=(autoconf) && \ + TEMP_PACKAGES+=(git) && \ + # Packages for nginx+python + KEPT_PACKAGES+=(nginx-light) && \ + TEMP_PACKAGES+=(python3-dev) && \ + KEPT_PACKAGES+=(python3-cryptography) && \ + KEPT_PACKAGES+=(python3) && \ + KEPT_PACKAGES+=(python3-pip) && \ + KEPT_PACKAGES+=(python3-setuptools) && \ + KEPT_PACKAGES+=(python3-wheel) && \ + # stats + KEPT_PACKAGES+=(rrdtool) && \ + TEMP_PACKAGES+=(librrd-dev) && \ + apt-get update && \ + apt-get install -y --no-install-recommends \ + "${KEPT_PACKAGES[@]}" \ + "${TEMP_PACKAGES[@]}"\ + && \ + pushd /src/ && \ + python3 -m pip install --no-cache-dir --break-system-packages \ + -r /src/requirements.txt \ + && \ + # Fix for Eventlet issues + apt-get \ + -o Dpkg::Options::='--force-confmiss' \ + install --reinstall --no-install-recommends -y \ + netbase \ + && \ + popd && \ + # Clean up + apt-get remove -y "${TEMP_PACKAGES[@]}" && \ + apt-get autoremove -y && \ + rm -rf /src/* /tmp/* /var/lib/apt/lists/* && \ + rm -rf /root/.cargo + +COPY --from=acarshub-typescript-builder /webapp/static/ /webapp/static/ +COPY --from=acarshub-typescript-builder /webapp/templates/ /webapp/templates/ + +RUN set -x && \ + mkdir -p /run/acars && \ + # grab the ground stations and other data from airframes + mkdir -p /webapp/data/ && \ + # Download the airframes Ground Station and ACARS Label data + pushd /webapp/data/ && \ + curl -O https://raw.githubusercontent.com/airframesio/data/master/json/vdl/ground-stations.json&& \ + curl -O https://raw.githubusercontent.com/airframesio/data/master/json/acars/metadata.json && \ + # Clean up + rm -rf /src/* /tmp/* /var/lib/apt/lists/* + +COPY rootfs/ / +COPY version-nextgen /acarshub-version + +EXPOSE 80 +EXPOSE 5550 +EXPOSE 5555 +EXPOSE 15550 +EXPOSE 15555 + +ENV FEED="" \ + ENABLE_ACARS="false" \ + ENABLE_VDLM="false" \ + ENABLE_ADSB="false" \ + ENABLE_WEB="true" \ + MIN_LOG_LEVEL=3 \ + QUIET_MESSAGES="true" \ + DB_SAVEALL="true" \ + ENABLE_RANGE_RINGS="true" \ + ADSB_URL="http://tar1090/data/aircraft.json" + + +# Add healthcheck +HEALTHCHECK --start-period=3600s --interval=600s CMD /scripts/healthcheck.sh + +ARG BUILD_EXTRA="Build git" +# append BUILD_EXTRA to the only line in /acarshub-version +RUN set -x && \ + echo "$(cat /acarshub-version) ${BUILD_EXTRA}" > /acarshub-version diff --git a/Dockerfile.acarshub b/Dockerfile.acarshub deleted file mode 100644 index e32aa68a3..000000000 --- a/Dockerfile.acarshub +++ /dev/null @@ -1,40 +0,0 @@ -# hadolint ignore=DL3007 -FROM ghcr.io/sdr-enthusiasts/docker-acarshub:nextgen - -ENV FEED="" \ - ENABLE_ACARS="false" \ - ENABLE_VDLM="false" \ - ENABLE_ADSB="false" \ - ENABLE_WEB="true" \ - MIN_LOG_LEVEL=3 \ - QUIET_MESSAGES="true" \ - DB_SAVEALL="true" \ - ENABLE_RANGE_RINGS="true" \ - ADSB_URL="http://tar1090/data/aircraft.json" - -SHELL ["/bin/bash", "-o", "pipefail", "-c"] - -# Copy needs to be prior to any curl/wget so SSL certs from GitHub runner are loaded -# Using the ADD commands makes it so we don't have to untar the archive in the RUN step -COPY rootfs/ / -ADD webapp.tar.gz / - -RUN set -x && \ - mkdir -p /run/acars && \ - # grab the ground stations and other data from airframes - mkdir -p /webapp/data/ && \ - # Download the airframes Ground Station and ACARS Label data - pushd /webapp/data/ && \ - curl -O https://raw.githubusercontent.com/airframesio/data/master/json/vdl/ground-stations.json&& \ - curl -O https://raw.githubusercontent.com/airframesio/data/master/json/acars/metadata.json && \ - # Clean up - rm -rf /src/* /tmp/* /var/lib/apt/lists/* - -EXPOSE 80 -EXPOSE 5550 -EXPOSE 5555 -EXPOSE 15550 -EXPOSE 15555 - -# Add healthcheck -HEALTHCHECK --start-period=3600s --interval=600s CMD /scripts/healthcheck.sh diff --git a/Dockerfile.acarshub-typescript b/Dockerfile.acarshub-typescript deleted file mode 100644 index 19f786eed..000000000 --- a/Dockerfile.acarshub-typescript +++ /dev/null @@ -1,26 +0,0 @@ -FROM node:20.5.1-slim AS acarshub-typescript-builder - -ENV DOCKER_BUILD="true" - -SHELL ["/bin/bash", "-o", "pipefail", "-c"] - -#hadolint ignore=DL3008 -RUN set -xe && \ - apt-get update && \ - apt-get install -y --no-install-recommends make python3 g++ && \ - rm -rf /src/* /tmp/* /var/lib/apt/lists/* - -COPY acarshub-typescript/package.json /acarshub-typescript/package.json -COPY acarshub-typescript/package-lock.json /acarshub-typescript/package-lock.json - -RUN set -xe && \ - pushd /acarshub-typescript && \ - npm install - -COPY acarshub-typescript/ /acarshub-typescript/ - -RUN set -xe && \ - pushd /acarshub-typescript && \ - mkdir -p ../rootfs/webapp/static/js/ && \ - npm run build && \ - npm run installer diff --git a/Dockerfile.nextgen b/Dockerfile.nextgen deleted file mode 100644 index a1300db1b..000000000 --- a/Dockerfile.nextgen +++ /dev/null @@ -1,44 +0,0 @@ -FROM ghcr.io/sdr-enthusiasts/docker-baseimage:python -SHELL ["/bin/bash", "-o", "pipefail", "-c"] - -COPY rootfs/webapp/requirements.txt /src/requirements.txt - -# hadolint ignore=DL3008,SC2086,DL3042,DL3013,SC1091 -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+=(automake) && \ - TEMP_PACKAGES+=(autoconf) && \ - TEMP_PACKAGES+=(git) && \ - # Packages for nginx - KEPT_PACKAGES+=(nginx-light) && \ - TEMP_PACKAGES+=(python3-dev) && \ - KEPT_PACKAGES+=(python3-cryptography) && \ - # stats - KEPT_PACKAGES+=(rrdtool) && \ - TEMP_PACKAGES+=(librrd-dev) && \ - apt-get update && \ - apt-get install -y --no-install-recommends \ - "${KEPT_PACKAGES[@]}" \ - "${TEMP_PACKAGES[@]}"\ - && \ - pushd /src/ && \ - python3 -m pip install --no-cache-dir --break-system-packages \ - -r /src/requirements.txt \ - && \ - # Fix for Eventlet issues - apt-get \ - -o Dpkg::Options::='--force-confmiss' \ - install --reinstall --no-install-recommends -y \ - netbase \ - && \ - popd && \ - # Clean up - apt-get remove -y "${TEMP_PACKAGES[@]}" && \ - apt-get autoremove -y && \ - rm -rf /src/* /tmp/* /var/lib/apt/lists/* && \ - rm -rf /root/.cargo diff --git a/rootfs/webapp/acarshub.py b/rootfs/webapp/acarshub.py index 9edbb79a6..ce27eff3e 100755 --- a/rootfs/webapp/acarshub.py +++ b/rootfs/webapp/acarshub.py @@ -447,7 +447,9 @@ def init_listeners(special_message=""): ) thread_scheduler = Thread(target=scheduled_tasks) thread_scheduler.start() - if not thread_html_generator.is_alive(): + + # check if 'g' is not in thread_html_generator + if not hasattr(thread_html_generator, "g"): acarshub_logging.log( f"{special_message}Starting htmlListener", "init", @@ -736,7 +738,7 @@ def main_connect(): acarshub_logging.acars_traceback(e, "webapp") # Start the htmlGenerator thread only if the thread has not been started before. - if not thread_html_generator.is_alive(): + if not hasattr(thread_html_generator, "g"): sys.stdout.flush() thread_html_generator_event.clear() thread_html_generator = socketio.start_background_task(htmlListener) diff --git a/rootfs/webapp/requirements.txt b/rootfs/webapp/requirements.txt index e7d6c6f85..380284c15 100644 --- a/rootfs/webapp/requirements.txt +++ b/rootfs/webapp/requirements.txt @@ -1,7 +1,7 @@ eventlet==0.33.3 Flask==2.3.3 Flask-SocketIO==5.3.5 -gunicorn[eventlet] @ git+https://github.com/benoitc/gunicorn.git@48eda22a4b3399b0a65677619b4938503cc207cb +gunicorn[eventlet]==21.2.0 pyrtlsdr==0.3.0 requests==2.31.0 rrdtool==0.1.16 From 3ae230296ba4801466c30c4c3b994f56da68750c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 1 Oct 2023 15:46:38 +0000 Subject: [PATCH 2/5] chore(deps): Bump flask from 2.3.3 to 3.0.0 in /rootfs/webapp Bumps [flask](https://github.com/pallets/flask) from 2.3.3 to 3.0.0. - [Release notes](https://github.com/pallets/flask/releases) - [Changelog](https://github.com/pallets/flask/blob/main/CHANGES.rst) - [Commits](https://github.com/pallets/flask/compare/2.3.3...3.0.0) --- updated-dependencies: - dependency-name: flask dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- rootfs/webapp/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootfs/webapp/requirements.txt b/rootfs/webapp/requirements.txt index c9ce7f745..ec6d9dd97 100644 --- a/rootfs/webapp/requirements.txt +++ b/rootfs/webapp/requirements.txt @@ -1,5 +1,5 @@ eventlet==0.33.3 -Flask==2.3.3 +Flask==3.0.0 Flask-SocketIO==5.3.6 gunicorn[eventlet]==21.2.0 requests==2.31.0 From 6fffd740fed77da6da5fecb727fbe3f3304b1a59 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Sun, 1 Oct 2023 10:10:17 -0600 Subject: [PATCH 3/5] cleaning up old unneeded files --- build-test-no-cluster.sh | 40 ------------------------------------ generate_local_dockerfile.sh | 15 -------------- 2 files changed, 55 deletions(-) delete mode 100755 build-test-no-cluster.sh delete mode 100755 generate_local_dockerfile.sh diff --git a/build-test-no-cluster.sh b/build-test-no-cluster.sh deleted file mode 100755 index cf5483dfe..000000000 --- a/build-test-no-cluster.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -REPO=ghcr.io/sdr-enthusiasts -IMAGE=docker-acarshub - -# # Generate local dockerfile -# ./generate_local_dockerfile.sh - -set -xe - -cleanup() { - echo "Cleaning up" - rm -rf ./webapp - echo "Done. Exiting." - exit 0 -} - -# build the acarshub typescript -echo "Building the typescript" -docker build --file ./Dockerfile.acarshub-typescript -t acarshub-typescript:latest . || cleanup -echo "Done building the typescript, grabbing the files from the container" -id=$(docker create acarshub-typescript:latest) || cleanup -docker cp "$id":/rootfs/webapp ./ || cleanup -echo "Done grabbing the files from the container, removing the container" -docker rm -v "$id" || cleanup -echo "Done removing the container" -sleep 3 - -# Generate local dockerfile -echo "Generating the local dockerfile" -./generate_local_dockerfile.sh || cleanup -echo "Done generating the local dockerfile" - -# Build & push latest -echo "Building the docker image" -docker build -f Dockerfile.acarshub.local -t "${REPO}/${IMAGE}:test-local" . || cleanup -echo "Done building the docker image, pushing the docker image" - -# Clean up -cleanup diff --git a/generate_local_dockerfile.sh b/generate_local_dockerfile.sh deleted file mode 100755 index 45680badf..000000000 --- a/generate_local_dockerfile.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -# generate a local dockerfile for local test builds - -rm -rf Dockerfile.acarshub.local -cp Dockerfile.acarshub Dockerfile.acarshub.local - -# Delete the copy line necessary for github actions -# This is a nice convenience for using cached builds - -sed -i '/COPY rootfs\/ \//d' Dockerfile.acarshub.local -sed -i '/ADD webapp.tar.gz \//d' Dockerfile.acarshub.local - -# move the COPY FS line back to the bottom so that we can use cached builds -sed -i 's/EXPOSE 15555/EXPOSE 15555\nCOPY version \/acarshub-version\nCOPY rootfs\/ \/\nCOPY webapp\/ \/webapp\//g' Dockerfile.acarshub.local From cdd77ad82f6d2ce58dffc910c9a3de8ee77003ed Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Sun, 1 Oct 2023 10:10:32 -0600 Subject: [PATCH 4/5] Moving back to base image building --- Dockerfile | 95 +----------------------------------------------------- 1 file changed, 1 insertion(+), 94 deletions(-) diff --git a/Dockerfile b/Dockerfile index ff1f9ee4e..5c2ea0786 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,92 +1,3 @@ -# From https://github.com/sdr-enthusiasts/docker-baseimage/blob/bace2830cbb6d6de4bfe05a3116bc74cf5fea658/Dockerfile.base -FROM debian:bookworm-20230814-slim AS sdr-enthusiasts-baseimage - -ENV S6_BEHAVIOUR_IF_STAGE2_FAILS=2 \ - S6OVERLAY_VERSION="v3.1.5.0" \ - # Fix for any issues with the S6 overlay. We have quite a few legacy services - # that worked fine under v2, but v3 is more strict and will kill a startup process - # if it takes more than 5 seconds. tar1090 and rtlsdrairband are the hardest hit - # but we may have others. - S6_CMD_WAIT_FOR_SERVICES_MAXTIME="0" - -SHELL ["/bin/bash", "-o", "pipefail", "-c"] - -# hadolint ignore=DL3008,SC2086 -RUN set -x && \ - TEMP_PACKAGES=() && \ - KEPT_PACKAGES=() && \ - # packages needed to install - TEMP_PACKAGES+=(git) && \ - # logging - KEPT_PACKAGES+=(gawk) && \ - KEPT_PACKAGES+=(pv) && \ - # required for S6 overlay - # curl kept for healthcheck - TEMP_PACKAGES+=(file) && \ - KEPT_PACKAGES+=(curl) && \ - TEMP_PACKAGES+=(xz-utils) && \ - KEPT_PACKAGES+=(ca-certificates) && \ - # bc for scripts and healthchecks - KEPT_PACKAGES+=(bc) && \ - # packages for network stuff - KEPT_PACKAGES+=(socat) && \ - KEPT_PACKAGES+=(ncat) && \ - KEPT_PACKAGES+=(net-tools) && \ - KEPT_PACKAGES+=(wget) && \ - # process management - KEPT_PACKAGES+=(procps) && \ - # needed to compile s6wrap: - TEMP_PACKAGES+=(gcc) && \ - TEMP_PACKAGES+=(build-essential) && \ - # install packages - ## Builder fixes... - mkdir -p /usr/sbin/ && \ - ln -s /usr/bin/dpkg-split /usr/sbin/dpkg-split && \ - ln -s /usr/bin/dpkg-deb /usr/sbin/dpkg-deb && \ - ln -s /bin/tar /usr/sbin/tar && \ - apt-get update && \ - apt-get install -y --no-install-recommends \ - "${KEPT_PACKAGES[@]}" \ - "${TEMP_PACKAGES[@]}" \ - && \ - # install S6 Overlay - curl --location --output /tmp/deploy-s6-overlay.sh https://raw.githubusercontent.com/mikenye/deploy-s6-overlay/master/deploy-s6-overlay-v3.sh && \ - sh /tmp/deploy-s6-overlay.sh && \ - rm -f /tmp/deploy-s6-overlay.sh && \ - # deploy healthchecks framework - git clone \ - --depth=1 \ - https://github.com/mikenye/docker-healthchecks-framework.git \ - /opt/healthchecks-framework \ - && \ - rm -rf \ - /opt/healthchecks-framework/.git* \ - /opt/healthchecks-framework/*.md \ - /opt/healthchecks-framework/tests \ - && \ - # fix healthchecks framework pathing - sed -i 's/S6_SERVICE_PATH="\/run\/s6\/services"/S6_SERVICE_PATH="\/run\/s6\/legacy-services"/g' /opt/healthchecks-framework/checks/check_s6_service_abnormal_death_tally.sh && \ - # Add s6wrap - pushd /tmp && \ - git clone --depth=1 https://github.com/wiedehopf/s6wrap.git && \ - cd s6wrap && \ - make && \ - mv s6wrap /usr/local/bin && \ - popd && \ - # Add additional stuff - mkdir -p /scripts /etc/cont-init.d && \ - curl -sSL https://raw.githubusercontent.com/sdr-enthusiasts/Buster-Docker-Fixes/main/install_libseccomp2.sh | bash && \ - chmod +x /etc/s6-overlay/s6-rc.d/libseccomp2/up && \ - chmod +x /etc/s6-overlay/scripts/libseccomp2_check.sh && \ - curl -sSL https://raw.githubusercontent.com/sdr-enthusiasts/docker-baseimage/main/scripts/common -o /scripts/common && \ - # Clean up - apt-get remove -y "${TEMP_PACKAGES[@]}" && \ - apt-get autoremove -y && \ - rm -rf /src/* /tmp/* /var/lib/apt/lists/* - -ENTRYPOINT [ "/init" ] - - FROM node:slim AS acarshub-typescript-builder # pushd/popd SHELL ["/bin/bash", "-o", "pipefail", "-c"] @@ -120,7 +31,7 @@ RUN set -xe && \ cp -r ./dist/static/js /webapp/static/ && \ mv ./dist/static/index.html /webapp/templates/ -FROM sdr-enthusiasts-baseimage +FROM ghcr.io/sdr-enthusiasts/docker-baseimage:python SHELL ["/bin/bash", "-o", "pipefail", "-c"] COPY rootfs/webapp/requirements.txt /src/requirements.txt @@ -140,10 +51,6 @@ RUN set -x && \ KEPT_PACKAGES+=(nginx-light) && \ TEMP_PACKAGES+=(python3-dev) && \ KEPT_PACKAGES+=(python3-cryptography) && \ - KEPT_PACKAGES+=(python3) && \ - KEPT_PACKAGES+=(python3-pip) && \ - KEPT_PACKAGES+=(python3-setuptools) && \ - KEPT_PACKAGES+=(python3-wheel) && \ # stats KEPT_PACKAGES+=(rrdtool) && \ TEMP_PACKAGES+=(librrd-dev) && \ From 448ffac25742da36f47f71bc31ee382b1643e573 Mon Sep 17 00:00:00 2001 From: Fred Clausen <43556888+fredclausen@users.noreply.github.com> Date: Sun, 1 Oct 2023 10:24:12 -0600 Subject: [PATCH 5/5] move to common github action for build --- .github/workflows/deploy.yml | 570 +--------------------------- .github/workflows/test-pr build.yml | 182 +-------- 2 files changed, 35 insertions(+), 717 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 94711bb1a..d583f9593 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -45,555 +45,21 @@ jobs: echo "Workflow dispatch reason: $INPUTS_REASON" echo "Use test image: $INPUTS_USE_TEST_IMAGE" - acarshub_typescript: - runs-on: ubuntu-latest - steps: - # Check out our code - - name: Checkout - uses: actions/checkout@v4.1.0 - - - name: Get version - run: | - echo "VERSION=$(sed '1!d' ./version-nextgen)" >> $GITHUB_ENV - - # Show version tag - - name: Show version tag - run: | - echo "ACARS Hub Version: ${{ env.VERSION }}" - echo "ACARS Hub Build: ${{ github.run_number }}" - - - name: Build ACARSHub typescript test - working-directory: ./acarshub-typescript - run: | - set -xe - npm install - sed -i 's/Pre-Release/ACARS Hub NextGen: ${{ env.VERSION }} Build ${{ github.run_number }}/' ./src/helpers/menu.ts - npm run build - mkdir -p ./webapp/static/images - mkdir -p ./webapp/static/js - mkdir -p ./webapp/static/sounds - mkdir -p ./webapp/templates - cp -r ./dist/static/images ./webapp/static/ - cp -r ./dist/static/sounds ./webapp/static/ - cp -r ./dist/static/js ./webapp/static/ - mv ./dist/static/index.html ./webapp/templates/ - tar cvfz webapp.tar.gz ./webapp - cp webapp.tar.gz ../webapp.tar.gz - - - name: Save webapp.tar.gz - uses: actions/upload-artifact@v3 - with: - name: webapp - path: | - ./webapp.tar.gz - - deploy_ghcr_nextgen: - name: Deploy ACARS Hub Next Gen Base Image - runs-on: ubuntu-latest - - steps: - # Check out our code - - name: Checkout - uses: actions/checkout@v4.1.0 - with: - fetch-depth: 2 - - - name: Get specific changed files - id: changed-files-specific - uses: tj-actions/changed-files@v39.2.0 - with: - files: | - Dockerfile.nextgen - .github/workflows/deploy.yml - - - name: Login to ghcr.io - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - # Get metadata from repo - - name: Extract metadata (tags, labels) for Docker - id: meta - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - # Set up QEMU for multi-arch builds - - name: Set up QEMU - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - uses: docker/setup-qemu-action@v3 - - # Set up buildx for multi platform builds - - name: Set up Docker Buildx - id: buildx - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - uses: docker/setup-buildx-action@v3 - - # Change the dockerfile to use the test image if we've been triggered as a test - - - name: Change dockerfile if under baseimage test - id: change_dockerfile - if: ${{ github.event.inputs.use_test_image == 'true' }} - run: | - sed -i "s/:python/:python-test-pr/g" Dockerfile.nextgen - - - name: Set output tag - id: set-output - run: | - # if we're using the test image, set an env variable to ghcr.io/sdr-enthusiasts/docker-acarshub:nextgen-test-pr - if [ "${{ github.event.inputs.use_test_image == 'true' }}" = "true" ]; then - echo "dockertag=ghcr.io/sdr-enthusiasts/docker-acarshub:nextgen-test-pr" >> $GITHUB_ENV - else - echo "dockertag=ghcr.io/sdr-enthusiasts/docker-acarshub:nextgen" >> $GITHUB_ENV - fi - - # Build & Push Dockerfile (only push if this action was NOT triggered by a PR) - - name: Build & Push ghcr.io/sdr-enthusiasts/docker-acarshub:nextgen - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - uses: docker/build-push-action@v5 - with: - context: . - file: ./Dockerfile.nextgen - no-cache: true - platforms: linux/amd64,linux/arm/v7,linux/arm/v6,linux/arm64 - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ env.dockertag }} - labels: ${{ steps.meta.outputs.labels }} - - deploy_ghcr_latest: - name: Deploy to latest to dockerhub - runs-on: ubuntu-latest - needs: [deploy_ghcr_nextgen, acarshub_typescript] - steps: - # Check out our code - - name: Checkout - uses: actions/checkout@v4.1.0 - with: - fetch-depth: 2 - - - name: Get specific changed files - id: changed-files-specific - uses: tj-actions/changed-files@v39.2.0 - with: - files: | - Dockerfile.nextgen - Dockerfile.acarshub - acarshub-typescript/** - rootfs/** - .github/workflows/deploy.yml - version-nextgen - - - name: Download webapp - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - uses: actions/download-artifact@v3 - with: - name: webapp - - - name: Get version - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - run: | - echo "VERSION=$(sed '1!d' ./version-nextgen)" >> $GITHUB_ENV - - # Show version tag - - name: Show version tag - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - run: | - echo "ACARS Hub Version: ${{ env.VERSION }}" - echo "ACARS Hub Build: ${{ github.run_number }}" - - - name: Create ACARS Hub Version file - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - run: | - echo "${{ env.VERSION }} Build ${{ github.run_number }}" > ./rootfs/version - - - name: Create version file - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - run: | - rm ./rootfs/version - echo "${{ env.VERSION }} Build ${{ github.run_number }}" >> ./rootfs/acarshub-version - - - name: Login to ghcr.io - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - # Change the dockerfile to use the test image if we've been triggered as a test - - - name: Change dockerfile if under baseimage test - id: change_dockerfile - if: ${{ github.event.inputs.use_test_image == 'true' }} - run: | - sed -i "s/:nextgen/:nextgen-test-pr/g" Dockerfile.acarshub - - - name: Set output tag - id: set-output - run: | - # if we're using the test image, set an env variable to ghcr.io/sdr-enthusiasts/docker-acarshub:nextgen-test-pr - if [ "${{ github.event.inputs.use_test_image == 'true' }}" = "true" ]; then - echo "dockertag=ghcr.io/sdr-enthusiasts/docker-acarshub:baseimage-test" >> $GITHUB_ENV - else - echo "dockertag=ghcr.io/sdr-enthusiasts/docker-acarshub:latest" >> $GITHUB_ENV - fi - # Get metadata from repo - - name: Extract metadata (tags, labels) for Docker - id: meta - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - # Set up QEMU for multi-arch builds - - name: Set up QEMU - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - uses: docker/setup-qemu-action@v3 - - # Set up buildx for multi platform builds - - name: Set up Docker Buildx - id: buildx - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - uses: docker/setup-buildx-action@v3 - - # Build & Push Dockerfile (only push if this action was NOT triggered by a PR) - - name: Build & Push ghcr.io/sdr-enthusiasts/docker-acarshub:latest - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - uses: docker/build-push-action@v5 - with: - context: . - file: ./Dockerfile.acarshub - no-cache: true - platforms: linux/amd64,linux/arm/v7,linux/arm/v6,linux/arm64 - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ env.dockertag }} - labels: ${{ steps.meta.outputs.labels }} - - deploy_ghcr_version_specific: - name: Deploy version to dockerhub - runs-on: ubuntu-latest - needs: [deploy_ghcr_nextgen, acarshub_typescript] - if: ${{ github.event.inputs.use_test_image == 'false' || github.event.inputs.use_test_image == '' }} - steps: - # Check out our code - - name: Checkout - uses: actions/checkout@v4.1.0 - with: - fetch-depth: 2 - - - name: Get specific changed files - id: changed-files-specific - uses: tj-actions/changed-files@v39.2.0 - with: - files: | - Dockerfile.nextgen - Dockerfile.acarshub - acarshub-typescript/** - rootfs/** - .github/deploy.yml - version - - - name: Download webapp - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - uses: actions/download-artifact@v3 - with: - name: webapp - - - name: Get version - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - run: | - echo "VERSION=$(sed '1!d' ./version-nextgen)" >> $GITHUB_ENV - - # Show version tag - - name: Show version tag - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - run: | - echo "ACARS Hub Version: ${{ env.VERSION }}" - echo "ACARS Hub Build: ${{ github.run_number }}" - - - name: Create ACARS Hub Version file - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - run: | - echo "${{ env.VERSION }} Build ${{ github.run_number }}" > ./rootfs/version - - - name: Create version file - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - run: | - rm ./rootfs/version - echo "${{ env.VERSION }} Build ${{ github.run_number }}" >> ./rootfs/acarshub-version - - - name: Login to ghcr.io - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - # Get metadata from repo - - name: Extract metadata (tags, labels) for Docker - id: meta - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - # Set up QEMU for multi-arch builds - - name: Set up QEMU - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - uses: docker/setup-qemu-action@v3 - - # Set up buildx for multi platform builds - - name: Set up Docker Buildx - id: buildx - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - uses: docker/setup-buildx-action@v3 - - # Build & Push Dockerfile (only push if this action was NOT triggered by a PR) - - name: Build & Push ghcr.io/sdr-enthusiasts/docker-acarshub:version specific - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - uses: docker/build-push-action@v5 - with: - context: . - file: ./Dockerfile.acarshub - no-cache: true - platforms: linux/amd64,linux/arm/v7,linux/arm/v6,linux/arm64 - push: ${{ github.event_name != 'pull_request' }} - tags: ghcr.io/sdr-enthusiasts/docker-acarshub:${{ env.VERSION }}Build${{ github.run_number }} - labels: ${{ steps.meta.outputs.labels }} - - deploy_ghcr_latest_no_healthcheck: - name: Deploy to latest/no healthcheck - runs-on: ubuntu-latest - needs: [deploy_ghcr_nextgen, acarshub_typescript] - if: ${{ github.event.inputs.use_test_image == 'false' || github.event.inputs.use_test_image == '' }} - steps: - # Check out our code - - name: Checkout - uses: actions/checkout@v4.1.0 - with: - fetch-depth: 2 - - - name: Get specific changed files - id: changed-files-specific - uses: tj-actions/changed-files@v39.2.0 - with: - files: | - Dockerfile.nextgen - Dockerfile.acarshub - acarshub-typescript/** - rootfs/** - .github/deploy.yml - version - - - name: Download webapp - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - uses: actions/download-artifact@v3 - with: - name: webapp - - - name: Get version - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - run: | - echo "VERSION=$(sed '1!d' ./version-nextgen)" >> $GITHUB_ENV - - # Show version tag - - name: Show version tag - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - run: | - echo "ACARS Hub Version: ${{ env.VERSION }}" - echo "ACARS Hub Build: ${{ github.run_number }}" - - - name: Create ACARS Hub Version file - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - run: | - echo "${{ env.VERSION }} Build ${{ github.run_number }}" > ./rootfs/version - - - name: Create version file - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - run: | - rm ./rootfs/version - echo "${{ env.VERSION }} Build ${{ github.run_number }}" >> ./rootfs/acarshub-version - - - name: Login to ghcr.io - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - # Get metadata from repo - - name: Extract metadata (tags, labels) for Docker - id: meta - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - # Set up QEMU for multi-arch builds - - name: Set up QEMU - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - uses: docker/setup-qemu-action@v3 - - # Set up buildx for multi platform builds - - name: Set up Docker Buildx - id: buildx - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - uses: docker/setup-buildx-action@v3 - - # Patch dockerfile to remove healthcheck - - name: Patch Dockerfile to remove healthcheck - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - run: sed '/^HEALTHCHECK /d' < Dockerfile.acarshub > Dockerfile.acarshub.nohealthcheck - - # Build & Push Dockerfile (only push if this action was NOT triggered by a PR) - - name: Build & Push ghcr.io/sdr-enthusiasts/docker-acarshub:latest_nohealthcheck - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - uses: docker/build-push-action@v5 - with: - context: . - file: ./Dockerfile.acarshub.nohealthcheck - no-cache: true - platforms: linux/amd64,linux/arm/v7,linux/arm/v6,linux/arm64 - push: ${{ github.event_name != 'pull_request' }} - tags: ghcr.io/sdr-enthusiasts/docker-acarshub:latest_nohealthcheck - labels: ${{ steps.meta.outputs.labels }} - - deploy_ghcr_version_specific_no_healthcheck: - name: Deploy version specific no healthcheck to dockerhub - runs-on: ubuntu-latest - needs: [deploy_ghcr_nextgen, acarshub_typescript] - if: ${{ github.event.inputs.use_test_image == 'false' || github.event.inputs.use_test_image == '' }} - outputs: - cleanupinfo: ${{ steps.set-output.outputs.do_release }} - steps: - # Check out our code - - name: Checkout - uses: actions/checkout@v4.1.0 - with: - fetch-depth: 2 - - - name: Get specific changed files - id: changed-files-specific - uses: tj-actions/changed-files@v39.2.0 - with: - files: | - Dockerfile.nextgen - Dockerfile.acarshub - acarshub-typescript/** - rootfs/** - .github/deploy.yml - version - - - name: Download webapp - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - uses: actions/download-artifact@v3 - with: - name: webapp - - - name: Get version - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - run: | - echo "VERSION=$(sed '1!d' ./version-nextgen)" >> $GITHUB_ENV - - # Show version tag - - name: Show version tag - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - run: | - echo "ACARS Hub Version: ${{ env.VERSION }}" - echo "ACARS Hub Build: ${{ github.run_number }}" - - - name: Create ACARS Hub Version file - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - run: | - echo "${{ env.VERSION }} Build ${{ github.run_number }}" > ./rootfs/version - - - name: Create version file - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - run: | - rm ./rootfs/version - echo "${{ env.VERSION }} Build ${{ github.run_number }}" >> ./rootfs/acarshub-version - - - name: Login to ghcr.io - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - # Get metadata from repo - - name: Extract metadata (tags, labels) for Docker - id: meta - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - # Set up QEMU for multi-arch builds - - name: Set up QEMU - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - uses: docker/setup-qemu-action@v3 - - # Set up buildx for multi platform builds - - name: Set up Docker Buildx - id: buildx - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - uses: docker/setup-buildx-action@v3 - - # Patch dockerfile to remove healthcheck - - name: Patch Dockerfile to remove healthcheck - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - run: sed '/^HEALTHCHECK /d' < Dockerfile.acarshub > Dockerfile.acarshub.nohealthcheck - - # Build & Push Dockerfile (only push if this action was NOT triggered by a PR) - - name: Build & Push ghcr.io/sdr-enthusiasts/docker-acarshub:version_nohealthcheck - if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.reason != '') - uses: docker/build-push-action@v5 - with: - context: . - file: ./Dockerfile.acarshub.nohealthcheck - no-cache: true - platforms: linux/amd64,linux/arm/v7,linux/arm/v6,linux/arm64 - push: ${{ github.event_name != 'pull_request' }} - tags: ghcr.io/sdr-enthusiasts/docker-acarshub:${{ env.VERSION }}Build${{ github.run_number }}_nohealthcheck - labels: ${{ steps.meta.outputs.labels }} - - create_release: - name: Create Release - runs-on: ubuntu-latest - if: ${{ github.event.inputs.use_test_image == 'false' || github.event.inputs.use_test_image == '' }} - needs: - - deploy_ghcr_nextgen - - acarshub_typescript - - deploy_ghcr_latest - - deploy_ghcr_version_specific - - deploy_ghcr_latest_no_healthcheck - - deploy_ghcr_version_specific_no_healthcheck - steps: - - name: Checkout code - uses: actions/checkout@v4.1.0 - - - name: Get version - run: | - echo "VERSION=$(sed '1!d' ./version-nextgen)" >> $GITHUB_ENV - - # Show version tag - - name: Show version tag - run: | - echo "ACARS Hub Version: ${{ env.VERSION }}" - echo "ACARS Hub Build: ${{ github.run_number }}" - - - name: Create Release - uses: ncipollo/release-action@v1 - with: - body: "See Commits" - allowUpdates: true - commit: ${{ github.ref }} - name: ${{ env.VERSION }} Build ${{ github.run_number }} - tag: ${{ env.VERSION }} - token: ${{ secrets.GITHUB_TOKEN }} + deploy: + name: Deploy + 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 }} + # set build_latest to true if github.event.inputs.use_test_image is false + build_latest: ${{ github.event.inputs.use_test_image == 'false' || github.event.inputs.use_test_image == '' }} + build_baseimage_test: ${{ github.event.inputs.use_test_image == 'true' }} + # only build the entire stack if we are not using the test image + build_version_specific: ${{ github.event.inputs.use_test_image == 'false' || github.event.inputs.use_test_image == '' }} + 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: :python/:python-test-pr + secrets: + ghcr_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test-pr build.yml b/.github/workflows/test-pr build.yml index 251a96690..6e2d72f04 100644 --- a/.github/workflows/test-pr build.yml +++ b/.github/workflows/test-pr build.yml @@ -69,168 +69,20 @@ jobs: - name: Run hadolint against Dockerfiles run: docker run --rm -i -v "$PWD":/workdir --workdir /workdir --entrypoint hadolint hadolint/hadolint $(find . -type f -iname "Dockerfile*") - deploy_ghcr_nextgen_test: - name: Deploy ACARS Hub Next Gen Base Image - runs-on: ubuntu-latest - steps: - # Check out our code - - name: Checkout - uses: actions/checkout@v4.1.0 - with: - fetch-depth: 0 - - - name: Get specific changed files - id: changed-files-specific - uses: tj-actions/changed-files@v39.2.0 - with: - files: | - Dockerfile.nextgen - .github/workflows/test-pr.yml - rootfs/webapp/requirements.txt - - - name: Login to ghcr.io - if: steps.changed-files-specific.outputs.any_changed == 'true' - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - # Get metadata from repo - - name: Extract metadata (tags, labels) for Docker - id: meta - if: steps.changed-files-specific.outputs.any_changed == 'true' - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - # Set up QEMU for multi-arch builds - - name: Set up QEMU - if: steps.changed-files-specific.outputs.any_changed == 'true' - uses: docker/setup-qemu-action@v3 - - # Set up buildx for multi platform builds - - name: Set up Docker Buildx - id: buildx - if: steps.changed-files-specific.outputs.any_changed == 'true' - uses: docker/setup-buildx-action@v3 - - # Build & Push Dockerfile (only push if this action was NOT triggered by a PR) - - name: Build & Push ghcr.io/sdr-enthusiasts/docker-acarshub:nextgen-test - if: steps.changed-files-specific.outputs.any_changed == 'true' - uses: docker/build-push-action@v5 - with: - context: . - file: ./Dockerfile.nextgen - no-cache: true - platforms: linux/386,linux/amd64,linux/arm/v7,linux/arm/v6,linux/arm64 - push: true - tags: ghcr.io/sdr-enthusiasts/docker-acarshub:nextgen-test - labels: ${{ steps.meta.outputs.labels }} - - deploy_ghcr_latest_test: - name: Deploy test to GHCR - runs-on: ubuntu-latest - needs: - - acarshub-typescript - - deploy_ghcr_nextgen_test - - steps: - # Check out our code - - name: Checkout - uses: actions/checkout@v4.1.0 - with: - fetch-depth: 0 - - - name: Get specific changed files - id: changed-files-specific - uses: tj-actions/changed-files@v39.2.0 - with: - files: | - Dockerfile.nextgen - Dockerfile.acarshub - acarshub-typescript/** - rootfs/** - .github/workflows/test-pr.yml - version - - - name: Get status of next file - id: changed-file-nextgen - uses: tj-actions/changed-files@v39.2.0 - with: - files: | - Dockerfile.nextgen - - - name: Download webapp - if: steps.changed-files-specific.outputs.any_changed == 'true' - uses: actions/download-artifact@v3 - with: - name: webapp - - - name: Get version - if: steps.changed-files-specific.outputs.any_changed == 'true' - run: | - echo "VERSION=$(sed '1!d' ./version-nextgen)" >> $GITHUB_ENV - - # Show version tag - - name: Show version tag - if: steps.changed-files-specific.outputs.any_changed == 'true' - run: | - echo "ACARS Hub Version: ${{ env.VERSION }}" - echo "ACARS Hub Build: ${{ github.run_number }}" - - - name: Create ACARS Hub Version file - if: steps.changed-files-specific.outputs.any_changed == 'true' - run: | - echo "${{ env.VERSION }} Build ${{ github.run_number }}" > ./rootfs/version - - - name: Create version file - if: steps.changed-files-specific.outputs.any_changed == 'true' - run: | - rm ./rootfs/version - echo "${{ env.VERSION }} Build ${{ github.run_number }}" >> ./rootfs/acarshub-version - - - name: Login to ghcr.io - if: steps.changed-files-specific.outputs.any_changed == 'true' - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - # Get metadata from repo - - name: Extract metadata (tags, labels) for Docker - id: meta - if: steps.changed-files-specific.outputs.any_changed == 'true' - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - # Set up QEMU for multi-arch builds - - name: Set up QEMU - if: steps.changed-files-specific.outputs.any_changed == 'true' - uses: docker/setup-qemu-action@v3 - - # Set up buildx for multi platform builds - - name: Set up Docker Buildx - id: buildx - if: steps.changed-files-specific.outputs.any_changed == 'true' - uses: docker/setup-buildx-action@v3 - - - name: Patch Dockerfile if Nextgen was built for this branch - if: steps.changed-file-nextgen.outputs.any_changed == 'true' - run: sed -i "s/^FROM ghcr.io\/sdr-enthusiasts\/docker-acarshub:nextgen/FROM ghcr.io\/sdr-enthusiasts\/docker-acarshub:nextgen-test/g" Dockerfile.acarshub - - # Build & Push Dockerfile (only push if this action was NOT triggered by a PR) - - name: Build & Push ghcr.io/sdr-enthusiasts/docker-acarshub:test - if: steps.changed-files-specific.outputs.any_changed == 'true' - uses: docker/build-push-action@v5 - with: - context: . - file: ./Dockerfile.acarshub - no-cache: true - platforms: linux/386,linux/amd64,linux/arm/v7,linux/arm/v6,linux/arm64 - push: true - tags: ghcr.io/sdr-enthusiasts/docker-acarshub:test - #tags: ghcr.io/sdr-enthusiasts/docker-acarshub:test-${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} - labels: ${{ steps.meta.outputs.labels }} + deploy: + name: Deploy + 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 }} + # set build_latest to true if github.event.inputs.use_test_image is false + build_latest: true + 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 + secrets: + ghcr_token: ${{ secrets.GITHUB_TOKEN }}