How do I make an addon based on debian

I would like to make an addon with Python, hassio, mariadb-client etc on my RP4
For my project I must use the python mip module, but that module makes use of a binary and there is only a binary (libCbcSolver.so) shipped with the module for amd64 architecture.
I tried to compile that binary on in a Alpine container on my RP4, but that didn’t succeed because a number of the necessary libraries are not available in the apk-store.
I succeeded in compilation of the library in a debian container.
So i must make an addon based on an debian image (preferable with Python 3.10 already present)
I tried it with this.
Docker

ARG BUILD_FROM
FROM ${BUILD_FROM}

# Set shell
SHELL ["/bin/bash", "-o", "pipefail", "-c"]

RUN \
    apt-get update -y \
    apt-get upgrade -y 
    
RUN \    
    apt-get install python3 -y \
    apt-get install python3-pip -y\
    \
    pip3 install mip
    
# Copy data for add-on
COPY run.sh /
RUN chmod a+x /run.sh
CMD [ "/run.sh" ]

build.yaml

---
build_from:
  aarch64: ghcr.io/hassio-addons/debian-base/aarch64:latest
  amd64: ghcr.io/hassio-addons/debiab-base/amd64:latest
  armhf: ghcr.io/hassio-addons/debian-base/armhf:latest
  armv7: ghcr.io/hassio-addons/debian-base/armv7:latest
  i386: ghcr.io/hassio-addons/debian-base/i386:latest

config.yaml:

---
name: Day Ahead Test 
version: "1.0.1"
slug: day-ahead-test
description: Docker used by Home Assistant Community Add-ons for day ahead optimalisations
arch:
  - aarch64
  - amd64
  - armhf
  - armv7
  - i386

During Install I get the error : “manifest unknown”
I have two questions:

  1. What did I do wrong?
  2. Can all this been done in a better way?

Thank you in advance.

1 Like

I am a little bit further
I changed the build.yaml:

build_from:
  aarch64: ghcr.io/hassio-addons/debian-base/aarch64:stable
  amd64: ghcr.io/hassio-addons/debiab-base/amd64:stable
  armhf: ghcr.io/hassio-addons/debian-base/armhf:stable
  armv7: ghcr.io/hassio-addons/debian-base/armv7:stable
  i386: ghcr.io/hassio-addons/debian-base/i386:stable

Now I going to install all the necessary packages.

1 Like

Hi, I would like to thank you very much for your question and your answer. You have helped me a lot on my way to a first (debain) addon

Now that I’ve read more about the topic and looked at the “build.yaml” from for example the https://github.com/hassio-addons/addon-vscode project, I know how to set up the “Dockerfile” and the “build.yaml”.
I will also use “stable” instead of a fixed version. I had hoped that there would simply be “latest”, but “stable” is also okay :smiley:

(fun fact: I only created an account for this comment :smiley: )

How did you get pip to run? me it refuses if i run the dockerfile on the HA system. Cheers

Hey Matthew,
From version 3.11 and up of Pyhton pip only works well when you set it up in a virtual environment.
This is how I got it working (a pice of my Dockerfile):

#install python en pip
RUN apt-get install python3 -y\
    python3-pip -y\
    python3-venv -y

WORKDIR /root
ENV VIRTUAL_ENV=/root/venv/day_ahead
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

COPY requirements.txt /tmp/
RUN pip3 install -r /tmp/requirements.txt

Succes!!,
Cheers Cees

Hello,

Found out what the issue was → PEP668
Saying that, using a venv inside a docker container isn’t that usefull but I can understand why.

I used the following:

# Install Python packages on system level --> PEP668
ENV PIP_BREAK_SYSTEM_PACKAGES=1

Thanks for your input though.

Cheers