Hallo, ich versuche mein System zu updaten. Wollte mal Docker ausprobieren. Vorab: Sieht schon gar nicht schlecht aus. Da das ganze auf ein RPi läuft, muss es ein ARM Image sein. Das von henfri im Docker-Hub scheint nicht zu gehen. Ich hab Dockerfile von Git geladen, auf Version 1.10 gestellt und kompiliert. Damit es lief, musste ich ein paar Sachen anpassen. Damit geht es zwar jetzt bei mir, aber ich dachte, vielleicht können wir das ja zusammen so einbauen, dass auch andere etwas davon haben. Änderungen:
1. Ich habe von hier begonnen :https://github.com/t3r/smarthome-doc...ter/Dockerfile
2. Basispaket von 3.8-slim auf 3.10-slim upgedated
3. Versionen (SHNG und Plugins) auf 1.10.0 gesetzt
4. Diese Zeilen ergänzt, weil er beim hochfahren versucht dort ein File zu schreiben, was sonst nicht geht (Permission)
5. (Hier istglaub ich ein Fehler, das ist nur ein Workaround)
Beim Hochfahren versucht er die Logging Configuration zu laden von /usr/smarthome/etc/logging.yaml, die existiert aber da nicht.
Daher ganz pragmatisch
Damit läuft das ganze. Könnte jemand das mal reviewen? Ich kann das in ein eigenes Repo ziehen oder wir pflegen das in das quell repo ein.
Vollständiges File
1. Ich habe von hier begonnen :https://github.com/t3r/smarthome-doc...ter/Dockerfile
2. Basispaket von 3.8-slim auf 3.10-slim upgedated
3. Versionen (SHNG und Plugins) auf 1.10.0 gesetzt
4. Diese Zeilen ergänzt, weil er beim hochfahren versucht dort ein File zu schreiben, was sonst nicht geht (Permission)
Code:
# chmod for check_cpu_speed to safe data chmod go+rw $PATH_SHNG/var; \
Beim Hochfahren versucht er die Logging Configuration zu laden von /usr/smarthome/etc/logging.yaml, die existiert aber da nicht.
Daher ganz pragmatisch
Code:
#Bug somewhere? RUN cp /usr/local/smarthome/etc/logging.yaml.default /usr/local/smarthome/etc/logging.yaml
Vollständiges File
Code:
### dockerfile for smarthomNG flavor "full"
### select python base image ####################################################
FROM python:3.10-slim As python-base
### Build Stage 1 - clone smarthome NG from Git #################################
FROM python-base As stage1
# install git
RUN set -eux; apt-get update; apt-get install -y --no-install-recommends \
ca-certificates git gcc python3-dev; \
rm -rf /var/lib/apt/lists/*
# prepare clone
ARG SHNG_VER_CORE="v1.10.0" \
SHNG_VER_PLGN="v1.10.0" \
PLGN_DEL="gpio"
# clone smarthomeNG from Git
WORKDIR /usr/local/smarthome
RUN set -eux; \
# clone SmarthomeNG
git -c advice.detachedHead=false clone --single-branch --branch $SHNG_VER_CORE \
https://github.com/smarthomeNG/smarthome.git .; \
git -c advice.detachedHead=false clone --single-branch --branch $SHNG_VER_PLGN \
https://github.com/smarthomeNG/plugins.git plugins; \
# remove git files - not usefull inside a container
find . -name ".git*" -print -exec rm -rf {} +; \
find . -name ".*" -type f -print -exec rm -rf {} +; \
# remove unneccessary files - no need for doc, dev and so on inside a container
rm -rf deprecated tests dev tools/* doc tox.ini setup.py; \
find . -name "*.md" -print -exec rm -rf {} +; \
# remove plugins if they are not running - for example GPIO is RasPi specific
if [ "$PLGN_DEL" ]; then \
for i in $PLGN_DEL; do rm -rf plugins/$i; done; \
fi
### Build Stage 11 - determine requirements for smarthomNG #######################
FROM stage1 As stage2
ARG PLGN_CONFLICT="appletv hue2"
WORKDIR /usr/local/smarthome
RUN set -eux; \
# remove some plugins to remove there requirements
if [ "$PLGN_CONFLICT" ]; then \
for i in $PLGN_CONFLICT; do rm -rf plugins/$i; done; \
fi; \
# necessary to run smarthome.py
python -m pip install --no-cache-dir "ruamel.yaml<=0.16.8"; \
# create requirement files
python3 bin/smarthome.py --stop || true
### Build Stage 3 - build requirements for smarthomNG ###########################
FROM python-base As stage3
COPY --from=stage2 /usr/local/smarthome/requirements/all.txt /requirements.txt
# install/update/build requirements
RUN set -eux; \
apt-get update; apt-get install -y --no-install-recommends \
#pyjq
automake \
#pyjq, openzwave
build-essential \
#bluepy
libglib2.0-dev \
#rrd
librrd-dev \
#pyjq
libtool \
#openzwave
libudev-dev \
openzwave; \
rm -rf /var/lib/apt/lists/*; \
# fix python requirements
echo "holidays<0.13" >>/requirements.txt; \
#sed -e 's/^\(holidays.*\)/\1,<=0.12;python_version==3.8/g' lib/requirements.txt; \
# install python requirements
python -m pip install --no-cache-dir -r requirements.txt
### Final Stage ##################################################################
FROM python-base
# copy files into place
COPY --from=stage1 /usr/local/smarthome /usr/local/smarthome
COPY --from=stage3 /usr/local/lib /usr/local/lib
RUN set -eux; \
# add user smarthome:smarthome respectively 1000:1000
adduser --disabled-password --gecos "" smarthome; \
# install needed tools
apt-get update; apt-get install -y --no-install-recommends \
gosu \
openzwave \
procps \
unzip; \
rm -rf /var/lib/apt/lists/*; \
#python -m pip install --no-cache-dir --upgrade pip; \
# prepare volumes
PATH_SHNG="/usr/local/smarthome"; \
PATH_CONF="/mnt/conf"; \
PATH_DATA="/mnt/data"; \
PATH_HTML="/mnt/html"; \
DIRS_CONF="etc items logics scenes functions"; \
DIRS_DATA="backup restore cache db log"; \
chmod go+rws $PATH_SHNG/requirements; \
# prepare conf
mkdir -p $PATH_CONF; \
for i in $DIRS_CONF; do \
cp -vlr $PATH_SHNG/$i $PATH_CONF; \
touch $PATH_CONF/$i/.not_mounted; \
done; \
chmod go+rw $PATH_CONF/etc; \
# prepare data
mkdir -p $PATH_SHNG/var/run; \
# chmod for check_cpu_speed to safe data
chmod go+rw $PATH_SHNG/var; \
chmod go+rw $PATH_SHNG/var/run; \
for i in $DIRS_DATA; do \
mkdir -p $PATH_DATA/$i; \
ln -vs $PATH_DATA/$i $PATH_SHNG/var/$i; \
touch $PATH_DATA/$i/.not_mounted; \
done; \
chmod go+rw $PATH_DATA/log; \
# fix for wrong log path
ln -vs $PATH_DATA/log $PATH_SHNG/log; \
# prepare smartvisu
mkdir -p $PATH_HTML /var/www; \
ln -vsf $PATH_HTML /var/www/html; \
# prepare legacy
chmod go+rw $PATH_SHNG/etc; \
touch $PATH_SHNG/etc/.not_mounted
# expose ports for cli, websocket, admin interface
EXPOSE 2323 2424 8383
#Bug somewhere?
RUN cp /usr/local/smarthome/etc/logging.yaml.default /usr/local/smarthome/etc/logging.yaml
# and finalize
#COPY ./entrypoint.sh ./shng_wrapper.sh /
COPY * /
ENTRYPOINT ["/entrypoint.sh"]
CMD ["--foreground"]


Kommentar