Skip to content

Commit 16c3ab9

Browse files
Merge pull request #81 from GeoDerp/removed-requirments
Docker copy from EMHASS#216
2 parents 07366be + f78eb1c commit 16c3ab9

File tree

4 files changed

+63
-83
lines changed

4 files changed

+63
-83
lines changed

.github/workflows/publish_docker.yaml

Lines changed: 9 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ on:
55
types: [published]
66

77
jobs:
8-
publish_amd64:
9-
name: Publish-amd64
8+
publish:
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
architecture: [amd64,aarch64,armhf,armv7]
13+
name: Publish-${{ matrix.architecture }}
1014
runs-on: ubuntu-latest
1115
steps:
1216
- name: Checkout the repository
13-
uses: actions/checkout@v2
17+
uses: actions/checkout@v4
1418
- name: Login to DockerHub
1519
uses: docker/login-action@v1
1620
with:
@@ -20,60 +24,6 @@ jobs:
2024
uses: home-assistant/builder@master
2125
with:
2226
args: |
23-
--amd64 \
27+
--${{ matrix.architecture }} \
2428
--target emhass \
25-
--docker-hub davidusb
26-
publish_aarch64:
27-
name: Publish-aarch64
28-
runs-on: ubuntu-latest
29-
steps:
30-
- name: Checkout the repository
31-
uses: actions/checkout@v2
32-
- name: Login to DockerHub
33-
uses: docker/login-action@v1
34-
with:
35-
username: ${{ secrets.DOCKERHUB_USERNAME }}
36-
password: ${{ secrets.DOCKERHUB_TOKEN }}
37-
- name: Publish
38-
uses: home-assistant/builder@master
39-
with:
40-
args: |
41-
--aarch64 \
42-
--target emhass \
43-
--docker-hub davidusb
44-
publish_armhf:
45-
name: Publish-armhf
46-
runs-on: ubuntu-latest
47-
steps:
48-
- name: Checkout the repository
49-
uses: actions/checkout@v2
50-
- name: Login to DockerHub
51-
uses: docker/login-action@v1
52-
with:
53-
username: ${{ secrets.DOCKERHUB_USERNAME }}
54-
password: ${{ secrets.DOCKERHUB_TOKEN }}
55-
- name: Publish
56-
uses: home-assistant/builder@master
57-
with:
58-
args: |
59-
--armhf \
60-
--target emhass \
61-
--docker-hub davidusb
62-
publish_armv7:
63-
name: Publish-armv7
64-
runs-on: ubuntu-latest
65-
steps:
66-
- name: Checkout the repository
67-
uses: actions/checkout@v2
68-
- name: Login to DockerHub
69-
uses: docker/login-action@v1
70-
with:
71-
username: ${{ secrets.DOCKERHUB_USERNAME }}
72-
password: ${{ secrets.DOCKERHUB_TOKEN }}
73-
- name: Publish
74-
uses: home-assistant/builder@master
75-
with:
76-
args: |
77-
--armv7 \
78-
--target emhass \
79-
--docker-hub davidusb
29+
--docker-hub davidusb

emhass/Dockerfile

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,78 @@
11
## EMHASS-Add-On Docker
2-
32
#build_version options are: addon (default), addon-git
43
ARG 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

1014
WORKDIR /app
1115
COPY requirements.txt /app/
1216

13-
# Setup
17+
#apt package install
1418
RUN 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)
4972
COPY config_emhass.yaml /app/
5073

5174
#-------------------------
52-
#EMHASS-ADDON Default
75+
#EMHASS-Add-on Default
5376
FROM base as addon
5477

5578
LABEL \
@@ -62,7 +85,7 @@ LABEL \
6285
ENTRYPOINT 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
6689
FROM addon as addon-git
6790
ARG build_repo=https://github.com/davidusb-geek/emhass.git
6891
ARG build_branch=master
@@ -79,7 +102,7 @@ RUN cp -r /tmp/emhass/src/emhass/. /app/src/emhass/
79102
RUN cp /tmp/emhass/setup.py /app/
80103
RUN cp /tmp/emhass/README.md /app/
81104
WORKDIR /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 .
83106
ENTRYPOINT python3 -m emhass.web_server --addon True --url http://supervisor/core/api --key $SUPERVISOR_TOKEN
84107

85108
#check build arguments and build

emhass/build.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
build_from: #choose between debian or raspbian images
2+
amd64: ghcr.io/home-assistant/amd64-base-debian:bookworm
3+
armhf: ghcr.io/home-assistant/armhf-base-raspbian:bookworm
4+
armv7: ghcr.io/home-assistant/armv7-base-debian:bookworm
5+
aarch64: ghcr.io/home-assistant/aarch64-base-debian:bookworm
16
args:
27
build_version: addon
38
build_repo: https://github.com/davidusb-geek/emhass.git #addon-git mode

emhass/requirements.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
numpy<=1.26.0
2-
scipy<=1.11.3
3-
pandas<=2.0.3
1+
numpy==1.26.4
2+
scipy==1.12.0
3+
pandas<=2.0.3
44
pvlib>=0.10.2
55
protobuf>=3.0.0
66
pytz>=2021.1
@@ -11,8 +11,10 @@ pulp>=2.4
1111
pyyaml>=5.4.1
1212
tables<=3.9.1
1313
skforecast==0.11.0
14+
# web server packages
1415
flask>=2.0.3
1516
waitress>=2.1.1
1617
plotly>=5.6.0
18+
#EMHASS
1719
emhass==0.8.1
1820
#git+https://github.com/davidusb-geek/emhass

0 commit comments

Comments
 (0)