11# # EMHASS-Add-On Docker
2-
32# build_version options are: addon (default), addon-git
43ARG build_version=addon
5- ARG BUILD_ARCH
4+ # see build.yaml for all docker images according to host architecture
5+ ARG BUILD_FROM
66
7+ FROM ${BUILD_FROM} AS base
8+
9+ # check if BUILD_ARCH passed by build-arg
10+ ARG BUILD_ARCH
11+ ENV BUILD_ARCH=${BUILD_ARCH}
712
8- FROM ghcr.io/home-assistant/$BUILD_ARCH-base-debian:bookworm AS base
913
1014WORKDIR /app
1115COPY requirements.txt /app/
1216
13- # Setup
17+ # apt package install
1418RUN apt-get update \
1519 && apt-get install -y --no-install-recommends \
1620 libffi-dev \
1721 python3 \
1822 python3-pip \
1923 python3-dev \
2024 git \
21- build-essential \
2225 gcc \
23- coinor-cbc \
24- coinor-libcbc-dev \
25- libglpk-dev \
26- glpk-utils \
26+ patchelf \
27+ cmake \
28+ meson \
29+ ninja-build \
30+ build-essential \
2731 libhdf5-dev \
2832 libhdf5-serial-dev \
29- netcdf-bin \
30- libnetcdf-dev \
3133 pkg-config \
3234 gfortran \
35+ netcdf-bin \
36+ libnetcdf-dev \
37+ coinor-cbc \
38+ coinor-libcbc-dev \
39+ libglpk-dev \
40+ glpk-utils \
3341 libatlas-base-dev \
34- && ln -s /usr/include/hdf5/serial /usr/include/hdf5/include \
35- && export HDF5_DIR=/usr/include/hdf5 \
36- && pip3 install --extra-index-url=https://www.piwheels.org/simple --no-cache-dir --break-system-packages -U setuptools wheel \
37- && pip3 install --extra-index-url=https://www.piwheels.org/simple --no-cache-dir --break-system-packages -r requirements.txt \
38- && apt-get purge -y --auto-remove \
42+ libopenblas-dev
43+ # specify hdf5
44+ RUN ln -s /usr/include/hdf5/serial /usr/include/hdf5/include && export HDF5_DIR=/usr/include/hdf5
45+
46+ # install packages from pip, use piwheels if arm 32bit
47+ RUN [[ "${BUILD_ARCH}" == "armhf" || "${BUILD_ARCH}" == "armv7" ]] && pip3 install --index-url=https://www.piwheels.org/simple --no-cache-dir --break-system-packages -r requirements.txt || pip3 install --no-cache-dir --break-system-packages -r requirements.txt
48+
49+ # try, symlink apt cbc, to pulp cbc, in python directory (for 32bit)
50+ RUN [[ "${BUILD_ARCH}" == "armhf" || "${BUILD_ARCH}" == "armv7" ]] && ln -sf /usr/bin/cbc /usr/local/lib/python3.11/dist-packages/pulp/solverdir/cbc/linux/32/cbc || echo "cbc symlink didnt work/not required"
51+
52+ # if armv7, try install libatomic1 to fix scipy issue
53+ RUN [[ "${BUILD_ARCH}" == "armv7" ]] && apt-get update && apt-get install libatomic1 || echo "libatomic1 cant be installed"
54+
55+ # remove build only packages
56+ RUN apt-get purge -y --auto-remove \
57+ git \
3958 gcc \
59+ patchelf \
60+ cmake \
61+ meson \
62+ ninja-build \
4063 build-essential \
41- libhdf5-dev \
42- libhdf5-serial-dev \
4364 pkg-config \
4465 gfortran \
66+ netcdf-bin \
67+ libnetcdf-dev \
4568 && rm -rf /var/lib/apt/lists/*
4669
4770
4871# copy config file (on all builds)
4972COPY config_emhass.yaml /app/
5073
5174# -------------------------
52- # EMHASS-ADDON Default
75+ # EMHASS-Add-on Default
5376FROM base as addon
5477
5578LABEL \
@@ -62,7 +85,7 @@ LABEL \
6285ENTRYPOINT python3 -m emhass.web_server --addon True --url http://supervisor/core/api --key $SUPERVISOR_TOKEN
6386
6487# -----------
65- # EMHASS-ADD-ON testing with git
88+ # EMHASS-Add-on testing with git
6689FROM addon as addon-git
6790ARG build_repo=https://github.com/davidusb-geek/emhass.git
6891ARG build_branch=master
@@ -79,7 +102,7 @@ RUN cp -r /tmp/emhass/src/emhass/. /app/src/emhass/
79102RUN cp /tmp/emhass/setup.py /app/
80103RUN cp /tmp/emhass/README.md /app/
81104WORKDIR /app
82- RUN python3 -m pip install --no-cache-dir --break-system-packages -U .
105+ RUN pip3 install --no-cache-dir --break-system-packages --no-deps --force-reinstall .
83106ENTRYPOINT python3 -m emhass.web_server --addon True --url http://supervisor/core/api --key $SUPERVISOR_TOKEN
84107
85108# check build arguments and build
0 commit comments