diff --git a/.github/workflows/build_images.yml b/.github/workflows/build_images.yml index 8570987..19e1a9f 100644 --- a/.github/workflows/build_images.yml +++ b/.github/workflows/build_images.yml @@ -61,9 +61,9 @@ jobs: uses: docker/build-push-action@v2 with: push: true - ile: Dockerfile.debian + file: Dockerfile tags: | - shneezin/breitbandmessung-node:dev + shneezin/breitbandmessung:dev platforms: linux/amd64 build-args: | COMMIT_SHA=${{ github.sha }} @@ -76,9 +76,9 @@ jobs: uses: docker/build-push-action@v2 with: push: true - ile: Dockerfile.debian + file: Dockerfile tags: | - shneezin/breitbandmessung-node:test + shneezin/breitbandmessung:test platforms: linux/amd64, linux/arm64/v8, linux/arm/v7 build-args: | COMMIT_SHA=${{ github.sha }} diff --git a/Dockerfile b/Dockerfile index 463dc1b..c30cff1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,27 +1,72 @@ FROM python:slim-bullseye -RUN apt-get update \ - && apt-get install --no-install-recommends -y firefox-esr tini cron curl build-essential libssl-dev libffi-dev python3-dev cargo \ - && rm -rf /var/lib/apt/lists/* +ENV RUSTUP_HOME=/usr/local/rustup \ + CARGO_HOME=/usr/local/cargo \ + PATH=/usr/local/cargo/bin:$PATH \ + RUST_VERSION=1.62.1 -RUN pip3 install --no-cache-dir \ - selenium \ - apprise \ - psutil \ - influxdb - WORKDIR /usr/src/app COPY speedtest.py config.shlib geckodriver.sh config.cfg.defaults ./ COPY entrypoint.sh /usr/local/bin/docker-entrypoint.sh -RUN chmod +x ./geckodriver.sh && ./geckodriver.sh +RUN set -eux; \ + apt-get update; \ + apt-get install --no-install-recommends -y firefox-esr \ + tini \ + cron \ + gcc \ + ca-certificates \ + wget \ + build-essential \ + libssl-dev \ + libffi-dev \ + python3-dev \ + cargo \ + curl \ + ; \ + chmod +x /usr/src/app/geckodriver.sh;\ + /bin/bash /usr/src/app/geckodriver.sh; \ + dpkgArch="$(dpkg --print-architecture)"; \ + case "${dpkgArch##*-}" in \ + amd64) rustArch='x86_64-unknown-linux-gnu'; rustupSha256='3dc5ef50861ee18657f9db2eeb7392f9c2a6c95c90ab41e45ab4ca71476b4338' ;; \ + armhf) rustArch='armv7-unknown-linux-gnueabihf'; rustupSha256='67777ac3bc17277102f2ed73fd5f14c51f4ca5963adadf7f174adf4ebc38747b' ;; \ + arm64) rustArch='aarch64-unknown-linux-gnu'; rustupSha256='32a1532f7cef072a667bac53f1a5542c99666c4071af0c9549795bbdb2069ec1' ;; \ + i386) rustArch='i686-unknown-linux-gnu'; rustupSha256='e50d1deb99048bc5782a0200aa33e4eea70747d49dffdc9d06812fd22a372515' ;; \ + *) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \ + esac; \ + url="https://static.rust-lang.org/rustup/archive/1.24.3/${rustArch}/rustup-init"; \ + wget "$url"; \ + echo "${rustupSha256} *rustup-init" | sha256sum -c -; \ + chmod +x rustup-init; \ + ./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION --default-host ${rustArch}; \ + rm rustup-init; \ + chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \ + rustup update; \ + rustup --version; \ + cargo --version; \ + rustc --version; \ + printf "deb http://ftp.debian.org/debian experimental main\ndeb http://ftp.debian.org/debian sid main" > /etc/apt/sources.list.d/experimental.list; \ + apt-get update ;\ + apt-get install --no-install-recommends -t experimental -y libc6-dev; \ + apt-get remove -y --auto-remove \ + wget \ + curl \ + ; \ + rm -rf /var/lib/apt/lists/*; \ + pip3 install --upgrade pip; \ + pip3 install --no-cache-dir --upgrade setuptools; \ + chmod +x /usr/src/app/speedtest.py; \ + mkdir /export; \ + chmod +x /usr/local/bin/docker-entrypoint.sh; -RUN chmod +x speedtest.py +RUN --mount=type=tmpfs,target=/usr/local/cargo pip3 install --no-cache-dir \ + cryptography; \ + pip3 install --no-cache-dir \ + selenium \ + apprise \ + psutil \ + influxdb; -RUN mkdir /export - -RUN chmod +x /usr/local/bin/docker-entrypoint.sh - -ENTRYPOINT ["tini", "--", "docker-entrypoint.sh"] +ENTRYPOINT ["tini", "--", "docker-entrypoint.sh"] \ No newline at end of file diff --git a/geckodriver-v0.31.0-linux-aarch64 .tar.gz b/geckodriver-v0.31.0-linux-aarch64 .tar.gz new file mode 100644 index 0000000..018fabf Binary files /dev/null and b/geckodriver-v0.31.0-linux-aarch64 .tar.gz differ diff --git a/geckodriver-v0.31.0-linuxarm32.tar.gz b/geckodriver-v0.31.0-linuxarm32.tar.gz new file mode 100644 index 0000000..d4befac Binary files /dev/null and b/geckodriver-v0.31.0-linuxarm32.tar.gz differ diff --git a/geckodriver.sh b/geckodriver.sh index 8d5a9db..004a3eb 100644 --- a/geckodriver.sh +++ b/geckodriver.sh @@ -10,7 +10,10 @@ if [ $os = "Linux" ] ; then url=https://github.com/mozilla/geckodriver/releases/download/v0.30.0/geckodriver-v0.30.0-linux64.tar.gz ;; xscale | arm | armv61 | armv71 | armv81 | aarch64 | armv7l ) - url=https://github.com/shneezin/breitbandmessung/raw/main/geckodriver-v0.30.0-linuxarm32.tar.gz + url=https://github.com/shneezin/breitbandmessung/raw/main/geckodriver-v0.31.0-linuxarm32.tar.gz + ;; + aarch64) + url=https://github.com/shneezin/breitbandmessung/raw/main/geckodriver-v0.31.0-linux-aarch64.tar.gz ;; *) echo Architecture not supported: $arch @@ -31,4 +34,4 @@ echo $arch curl -s -L "$url" | tar -xz chmod +x geckodriver -mv geckodriver /usr/bin +mv geckodriver /usr/bin \ No newline at end of file diff --git a/speedtest.py b/speedtest.py index 2033e8c..f52e495 100644 --- a/speedtest.py +++ b/speedtest.py @@ -173,6 +173,19 @@ db_client.write_points(json_body) db_client.close() break + except: + now = datetime.now() + current_time = now.strftime("%H_%M_%S") + current_date = now.strftime("%d_%m_%Y") + filename = ( + DOWNLOADED_PATH + + SCREENSHOTNAME + + current_date + + "_error_" + + current_time + + SCREENSHOTTEXT + ) + browser.save_screenshot(filename) finally: time.sleep(SLEEPTIME) @@ -247,4 +260,4 @@ ) browser.close() -exit() +exit() \ No newline at end of file