From ba82abe5f373a1b12ad6a020f4625ba2a3b79215 Mon Sep 17 00:00:00 2001 From: Trenton Holmes <797416+stumpylog@users.noreply.github.com> Date: Sun, 23 Apr 2023 20:09:31 -0700 Subject: [PATCH] Updates the install of cloudflared to utilize the Cloudflare Package Repository --- docker/debian-base.dockerfile | 20 +++++++-------- extra/download-cloudflared.js | 48 ----------------------------------- 2 files changed, 10 insertions(+), 58 deletions(-) delete mode 100644 extra/download-cloudflared.js diff --git a/docker/debian-base.dockerfile b/docker/debian-base.dockerfile index e7c51ded4..fbb568faa 100644 --- a/docker/debian-base.dockerfile +++ b/docker/debian-base.dockerfile @@ -8,21 +8,21 @@ WORKDIR /app # Install Curl # Install Apprise, add sqlite3 cli for debugging in the future, iputils-ping for ping, util-linux for setpriv # Stupid python3 and python3-pip actually install a lot of useless things into Debian, specify --no-install-recommends to skip them, make the base even smaller than alpine! -RUN apt update && \ - apt --yes --no-install-recommends install python3 python3-pip python3-cryptography python3-six python3-yaml python3-click python3-markdown python3-requests python3-requests-oauthlib \ - sqlite3 iputils-ping util-linux dumb-init git && \ +RUN apt-get update && \ + apt-get --yes --no-install-recommends install python3 python3-pip python3-cryptography python3-six python3-yaml python3-click python3-markdown python3-requests python3-requests-oauthlib \ + sqlite3 iputils-ping util-linux dumb-init git curl ca-certificates && \ pip3 --no-cache-dir install apprise==1.3.0 && \ rm -rf /var/lib/apt/lists/* && \ apt --yes autoremove # Install cloudflared -# dpkg --add-architecture arm: cloudflared do not provide armhf, this is workaround. Read more: https://github.com/cloudflare/cloudflared/issues/583 -COPY extra/download-cloudflared.js ./extra/download-cloudflared.js -RUN node ./extra/download-cloudflared.js $TARGETPLATFORM && \ - dpkg --add-architecture arm && \ - apt update && \ - apt --yes --no-install-recommends install ./cloudflared.deb && \ +RUN set -eux && \ + mkdir -p --mode=0755 /usr/share/keyrings && \ + curl --fail --show-error --silent --location --insecure https://pkg.cloudflare.com/cloudflare-main.gpg --output /usr/share/keyrings/cloudflare-main.gpg && \ + echo 'deb [signed-by=/usr/share/keyrings/cloudflare-main.gpg] https://pkg.cloudflare.com/cloudflared buster main' | tee /etc/apt/sources.list.d/cloudflared.list && \ + apt-get update && \ + apt-get install --yes --no-install-recommends cloudflared && \ + cloudflared version && \ rm -rf /var/lib/apt/lists/* && \ - rm -f cloudflared.deb && \ apt --yes autoremove diff --git a/extra/download-cloudflared.js b/extra/download-cloudflared.js deleted file mode 100644 index 74b9bad2a..000000000 --- a/extra/download-cloudflared.js +++ /dev/null @@ -1,48 +0,0 @@ -// - -const http = require("https"); // or 'https' for https:// URLs -const fs = require("fs"); - -const platform = process.argv[2]; - -if (!platform) { - console.error("No platform??"); - process.exit(1); -} - -let arch = null; - -if (platform === "linux/amd64") { - arch = "amd64"; -} else if (platform === "linux/arm64") { - arch = "arm64"; -} else if (platform === "linux/arm/v7") { - arch = "arm"; -} else { - console.error("Invalid platform?? " + platform); -} - -const file = fs.createWriteStream("cloudflared.deb"); -get("https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-" + arch + ".deb"); - -/** - * Download specified file - * @param {string} url URL to request - */ -function get(url) { - http.get(url, function (res) { - if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) { - console.log("Redirect to " + res.headers.location); - get(res.headers.location); - } else if (res.statusCode >= 200 && res.statusCode < 300) { - res.pipe(file); - - res.on("end", function () { - console.log("Downloaded"); - }); - } else { - console.error(res.statusCode); - process.exit(1); - } - }); -}