hassio-addons / addon-prometheus

Prometheus - Home Assistant Community Add-ons
https://addons.community
MIT License
21 stars 32 forks source link

docker build fails #60

Open lupino3 opened 1 year ago

lupino3 commented 1 year ago

Problem/Motivation

Running docker build on the current main branch generates the following errors:

Trying to install the add-on also generates the same errors, since docker build is part of the installation process.

❯ docker build .
[+] Building 23.5s (7/7) FINISHED                                                                        docker:default
 => [internal] load build definition from Dockerfile                                                               0.0s
 => => transferring dockerfile: 3.00kB                                                                             0.0s
 => [internal] load .dockerignore                                                                                  0.0s
 => => transferring context: 2B                                                                                    0.0s
 => [internal] load metadata for ghcr.io/hassio-addons/base:12.2.6                                                17.7s
 => [internal] load build context                                                                                  0.0s
 => => transferring context: 937B                                                                                  0.0s
 => [1/3] FROM ghcr.io/hassio-addons/base:12.2.6@sha256:478d369f77adffb8f54f2e66c8f474fc46715ffa3a513e53e6b317d43  0.0s
 => CACHED [2/3] COPY rootfs /                                                                                     0.0s
 => ERROR [3/3] RUN     ARCH="amd64"     && if [ "amd64" = "aarch64" ]; then ARCH="arm64"; fi         && apk --no  5.7s
------
 > [3/3] RUN     ARCH="amd64"     && if [ "amd64" = "aarch64" ]; then ARCH="arm64"; fi         && apk --no-cache add         python3=3.10.5-r0         py3-idna=3.3-r2         py3-certifi=2021.10.8-r0         py3-chardet=4.0.0-r3         py3-yaml=6.0-r0         py3-urllib3=1.26.9-r0         py3-requests=2.27.1-r0     && apk --no-cache add --virtual .builddeps         py-pip=22.1.1-r0         && curl -J -L -o /tmp/prometheus.tar.gz         "https://github.com/prometheus/prometheus/releases/download/v2.40.1/prometheus-2.40.1.linux-${ARCH}.tar.gz"     && adduser -s /bin/false -D -H prometheus     && cd /tmp     && tar -xvf /tmp/prometheus.tar.gz     && mkdir -p /etc/prometheus     && cp prometheus-2.40.1.linux-${ARCH}/promtool /usr/local/bin/     && cp prometheus-2.40.1.linux-${ARCH}/prometheus /usr/local/bin/     && cp -R prometheus-2.40.1.linux-${ARCH}/console_libraries/ /etc/prometheus/     && cp -R prometheus-2.40.1.linux-${ARCH}/consoles/ /etc/prometheus/     && rm -r prometheus-2.40.1.linux-${ARCH}     && chown -R prometheus:prometheus /etc/prometheus     && pip3 install         --no-cache-dir         --prefer-binary         --find-links "https://wheels.home-assistant.io/alpine-3.15/amd64/"         -r /opt/prometheus-configgen/requirements.txt         && apk --no-cache del .builddeps     && rm -f -r         /tmp/*:
0.353 fetch https://dl-cdn.alpinelinux.org/alpine/v3.16/main/x86_64/APKINDEX.tar.gz
1.965 fetch https://dl-cdn.alpinelinux.org/alpine/v3.16/community/x86_64/APKINDEX.tar.gz
5.660 ERROR: unable to select packages:
5.713   python3-3.10.12-r0:
5.713     breaks: world[python3=3.10.5-r0]
5.713     satisfies: py3-charset-normalizer-2.0.10-r0[python3]
5.713                py3-urllib3-1.26.9-r0[python3]
5.713                py3-requests-2.27.1-r0[python3]
5.713                py3-yaml-6.0-r0[python3]
5.713                py3-idna-3.3-r2[python3]
5.713                py3-chardet-4.0.0-r3[python3]
5.713                py3-certifi-2021.10.8-r0[python3]
------
Dockerfile:16
--------------------
  15 |     # hadolint ignore=DL3003
  16 | >>> RUN \
  17 | >>>     ARCH="${BUILD_ARCH}" \
  18 | >>>     && if [ "${BUILD_ARCH}" = "aarch64" ]; then ARCH="arm64"; fi \
  19 | >>>     \
  20 | >>>     && apk --no-cache add \
  21 | >>>         python3=3.10.5-r0 \
  22 | >>>         py3-idna=3.3-r2 \
  23 | >>>         py3-certifi=2021.10.8-r0 \
  24 | >>>         py3-chardet=4.0.0-r3 \
  25 | >>>         py3-yaml=6.0-r0 \
  26 | >>>         py3-urllib3=1.26.9-r0 \
  27 | >>>         py3-requests=2.27.1-r0 \
  28 | >>>     && apk --no-cache add --virtual .builddeps \
  29 | >>>         py-pip=22.1.1-r0 \
  30 | >>>     \
  31 | >>>     && curl -J -L -o /tmp/prometheus.tar.gz \
  32 | >>>         "https://github.com/prometheus/prometheus/releases/download/v${PROMETHEUS_VERSION}/prometheus-${PROMETHEUS_VERSION}.linux-${ARCH}.tar.gz" \
  33 | >>>     && adduser -s /bin/false -D -H prometheus \
  34 | >>>     && cd /tmp \
  35 | >>>     && tar -xvf /tmp/prometheus.tar.gz \
  36 | >>>     && mkdir -p /etc/prometheus \
  37 | >>>     && cp prometheus-${PROMETHEUS_VERSION}.linux-${ARCH}/promtool /usr/local/bin/ \
  38 | >>>     && cp prometheus-${PROMETHEUS_VERSION}.linux-${ARCH}/prometheus /usr/local/bin/ \
  39 | >>>     && cp -R prometheus-${PROMETHEUS_VERSION}.linux-${ARCH}/console_libraries/ /etc/prometheus/ \
  40 | >>>     && cp -R prometheus-${PROMETHEUS_VERSION}.linux-${ARCH}/consoles/ /etc/prometheus/ \
  41 | >>>     && rm -r prometheus-${PROMETHEUS_VERSION}.linux-${ARCH} \
  42 | >>>     && chown -R prometheus:prometheus /etc/prometheus \
  43 | >>>     && pip3 install \
  44 | >>>         --no-cache-dir \
  45 | >>>         --prefer-binary \
  46 | >>>         --find-links "https://wheels.home-assistant.io/alpine-3.15/${BUILD_ARCH}/" \
  47 | >>>         -r /opt/prometheus-configgen/requirements.txt \
  48 | >>>     \
  49 | >>>     && apk --no-cache del .builddeps \
  50 | >>>     && rm -f -r \
  51 | >>>         /tmp/*
  52 |
--------------------
ERROR: failed to solve: process "/bin/bash -o pipefail -c ARCH=\"${BUILD_ARCH}\"     && if [ \"${BUILD_ARCH}\" = \"aarch64\" ]; then ARCH=\"arm64\"; fi         && apk --no-cache add         python3=3.10.5-r0         py3-idna=3.3-r2
py3-certifi=2021.10.8-r0         py3-chardet=4.0.0-r3         py3-yaml=6.0-r0         py3-urllib3=1.26.9-r0         py3-requests=2.27.1-r0     && apk --no-cache add --virtual .builddeps         py-pip=22.1.1-r0         && curl -J -L -o /tmp/prometheus.tar.gz         \"https://github.com/prometheus/prometheus/releases/download/v${PROMETHEUS_VERSION}/prometheus-${PROMETHEUS_VERSION}.linux-${ARCH}.tar.gz\"     && adduser -s /bin/false -D -H prometheus     && cd /tmp     && tar -xvf /tmp/prometheus.tar.gz     && mkdir -p /etc/prometheus     && cp prometheus-${PROMETHEUS_VERSION}.linux-${ARCH}/promtool /usr/local/bin/     && cp prometheus-${PROMETHEUS_VERSION}.linux-${ARCH}/prometheus /usr/local/bin/     && cp -R prometheus-${PROMETHEUS_VERSION}.linux-${ARCH}/console_libraries/ /etc/prometheus/     && cp -R prometheus-${PROMETHEUS_VERSION}.linux-${ARCH}/consoles/ /etc/prometheus/     && rm -r prometheus-${PROMETHEUS_VERSION}.linux-${ARCH}     && chown -R prometheus:prometheus /etc/prometheus     && pip3 install         --no-cache-dir         --prefer-binary         --find-links \"https://wheels.home-assistant.io/alpine-3.15/${BUILD_ARCH}/\"         -r /opt/prometheus-configgen/requirements.txt         && apk --no-cache del .builddeps     && rm -f -r         /tmp/*" did not complete successfully: exit code: 8

The key part seems to be:

5.660 ERROR: unable to select packages:
5.713   python3-3.10.12-r0:
5.713     breaks: world[python3=3.10.5-r0]
5.713     satisfies: py3-charset-normalizer-2.0.10-r0[python3]
5.713                py3-urllib3-1.26.9-r0[python3]
5.713                py3-requests-2.27.1-r0[python3]
5.713                py3-yaml-6.0-r0[python3]
5.713                py3-idna-3.3-r2[python3]
5.713                py3-chardet-4.0.0-r3[python3]
5.713                py3-certifi-2021.10.8-r0[python3]

There is a Python version conflict.

Expected behavior

The docker container image should be built.

Actual behavior

The image is not built.

Steps to reproduce

Clone the repository and run docker build.

Proposed changes

I got it to build by patching the Python version in the Dockerfile, and I'll send a PR with this change:

diff --git a/prometheus/Dockerfile b/prometheus/Dockerfile
index 99f4800..804ac52 100755
--- a/prometheus/Dockerfile
+++ b/prometheus/Dockerfile
@@ -18,7 +18,7 @@ RUN \
     && if [ "${BUILD_ARCH}" = "aarch64" ]; then ARCH="arm64"; fi \
     \
     && apk --no-cache add \
-        python3=3.10.5-r0 \
+        python3=3.10.12-r0 \
         py3-idna=3.3-r2 \
         py3-certifi=2021.10.8-r0 \
         py3-chardet=4.0.0-r3 \

Not sure if there is a systemic fix there: why do we have such a conflict here and how can it be avoided?

lupino3 commented 1 year ago

Note: I can reproduce the issue in the following environments:

lupino3 commented 1 year ago

Note that currently the CI GitHub action is failing because of this problem: https://github.com/hassio-addons/addon-prometheus/actions/workflows/ci.yaml.

It would be useful to run CI on a daily or weekly basis to catch these conflicts as they crop up.