pdreker / fritz_exporter

Prometheus exporter for Fritz!Box home routers
Other
155 stars 32 forks source link

Fix Dockerfile: Add Poetry config, add compiler for AARCH64 #128

Closed dpunkturban closed 1 year ago

dpunkturban commented 1 year ago

Hi,

I tried to run the latest version of fritz_exporter on an Odroid and Macbook (AARCH64), which didn't work because the requirements.txt and python compiler were missing.

This PR contains:

Tested on:

pdreker commented 1 year ago

Maybe I'm missing something, but there already is a working arm64/aarch64 image on Docker Hub which builds straight from the existing Dockerfile using buildx/qemu (cross-build, multiplatform) in the GitHub Pipeline. When I started writing this exporter, I was running it on several different Raspberry Pi, so building ARM (v6/v7 and 64 (v8) which covers all Raspis which can actually run Docker and coincidentally also Apple Silicon...) has always been there from Day 1.

This is running on a MacBook Pro (M2 Chip) natively - No Rosetta or qemu:

❯ uname -a
Darwin MacBook-Pro-3.fritz.box 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct  9 20:15:52 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T8112 arm64

❯ docker pull pdreker/fritz_exporter:2.2.1
2.2.1: Pulling from pdreker/fritz_exporter
[...]
Digest: sha256:61910deb0777f6fba697811dc30c1b035e763f560fa93fe1ac9da4ad87b37a92
Status: Downloaded newer image for pdreker/fritz_exporter:2.2.1
docker.io/pdreker/fritz_exporter:2.2.1

❯ docker images
REPOSITORY               TAG       IMAGE ID       CREATED        SIZE
pdreker/fritz_exporter   2.2.1     bcd07b520c4f   31 hours ago   75.3MB
❯ docker inspect bcd07b520c4f
[...]
        "Architecture": "arm64",
        "Os": "linux",
[...]

❯  docker run -v $(pwd)/fbe.yaml:/app/fritz-exporter.yaml --name fbe --rm -p 9787:9787 pdreker/fritz_exporter:2.2.1 --config fritz-exporter.yaml
2022-12-30 19:57:48,694     INFO fritzexporter.fritzdevice | Connection to fritz.box successful, reading capabilities
2022-12-30 19:57:48,695    DEBUG fritzexporter.fritzcapability | Capability DeviceInfo set to True on device fritz.box
2022-12-30 19:57:49,179    DEBUG fritzexporter.fritzcapability | Capability HostNumberOfEntries set to True on device fritz.box
2022-12-30 19:57:49,205    DEBUG fritzexporter.fritzcapability | Capability UserInterface set to True on device fritz.box
2022-12-30 19:57:49,281    DEBUG fritzexporter.fritzcapability | Capability LanInterfaceConfig set to True on device fritz.box
[...]

Also: not having poetry in the image is intentional as it does not add anything at runtime, the CI/CD Pipeline generates the requirements.txt dynamically at build time, so I don't need poetry which in turn saves space in the image. The Dockerfile also does not create a venv, it directly dumps the requirements into the "system" files in the container via pip.

I just checked, if the build instructions are correct and they work just fine on the MacBook from above. Obviously when building native (for the same platform) there is no need for buildx/qemu.

So... What am I missing?