diff --git a/sbfspot/Dockerfile b/sbfspot/Dockerfile index 2573fac..d89eebe 100644 --- a/sbfspot/Dockerfile +++ b/sbfspot/Dockerfile @@ -1,6 +1,6 @@ -# https://developers.home-assistant.io/docs/add-ons/configuration#add-on-dockerfile +## https://developers.home-assistant.io/docs/add-ons/configuration#add-on-dockerfile ARG BUILD_FROM -FROM $BUILD_FROM AS builder +FROM $BUILD_FROM AS builder-base # Execute during the build of the image ARG TEMPIO_VERSION BUILD_ARCH @@ -8,29 +8,35 @@ RUN \ curl -sSLf -o /usr/bin/tempio \ "https://github.com/home-assistant/tempio/releases/download/${TEMPIO_VERSION}/tempio_${BUILD_ARCH}" -ENV LANG C.UTF-8 -ENV MQTT_ENABLE 1 - # Copy root filesystem COPY rootfs / # Set shell SHELL ["/bin/bash", "-o", "pipefail", "-c"] # install requirements -RUN apk update && apk upgrade && apk add --no-cache git g++ make mysql-dev bluez-dev boost-dev curl-dev tzdata mosquitto-clients mariadb-dev - +RUN apk update && apk add --no-cache \ + bluez=5.65-r0 \ + bluez-dev=5.65-r0 \ + boost-dev=1.78.0-r1 \ + curl-dev=7.83.1-r2 \ + git=2.36.2-r0 \ + g++=11.2.1_git20220219-r2 \ + make=4.3-r0 \ + mariadb-dev=10.6.8-r0 \ + mosquitto-clients=2.0.14-r1 \ + nginx=1.22.0-r1 \ + tzdata=2022a-r0 + # download and build SBFspot +WORKDIR /tmp RUN \ - cd /tmp \ - && git clone https://github.com/sbfspot/SBFspot.git . \ - && cd SBFspot \ - && sed -i s/mariadbclient/mariadb/ makefile \ - && make mariadb \ - && cd .. \ - && cd SBFspotUploadDaemon \ - &&sed -i s/mariadbclient/mariadb/ makefile \ - && make mariadb - + git clone https://github.com/sbfspot/SBFspot.git . \ + && sed -i s/mariadbclient/mariadb/ ./SBFspot/makefile \ + && make -C ./SBFspot mariadb \ + && sed -i s/mariadbclient/mariadb/ ./SBFspotUploadDaemon/makefile \ + && make -C ./SBFspotUploadDaemon mariadb + + # runtinme container FROM $BUILD_FROM @@ -41,27 +47,43 @@ RUN \ SHELL ["/bin/bash", "-o", "pipefail", "-c"] -RUN apk update && apk upgrade && apk add --no-cache boost-date_time bluez-libs libstdc++ tzdata mariadb-common mariadb-connector-c ncurses-libs libcurl mosquitto-clients -COPY rootfs / + +RUN apk update && apk add --no-cache \ + bluez=5.65-r0 \ + nano=6.3-r0 \ + bluez-libs=5.65-r0 \ + libstdc++=11.2.1_git20220219-r2 \ + mariadb-common=10.6.8-r0 \ + mariadb-connector-c=3.1.13-r4 \ + ncurses-libs=6.3_p20220521-r0 \ + libcurl=7.83.1-r2 \ + mosquitto-clients=2.0.14-r1 \ + nginx=1.22.0-r1 + + #tzdata=2022a-r0 + #boost-date_time1.78 + + # Copy data for add-on +WORKDIR /usr/bin/sbfspot -RUN mkdir -p /usr/bin/sbfspot - -COPY --from=builder /tmp/SBFspot/mariadb/bin/SBFspot /tmp/SBFspot/mariadb/bin/SBFspot -COPY --from=builder /tmp/SBFspotUploadDaemon/mariadb/bin/SBFspotUploadDaemon /tmp/SBFspotUploadDaemon/mariadb/bin/SBFspotUploadDaemon -COPY --from=builder /tmp/SBFspot/date_time_zonespec.csv /tmp/SBFspot/date_time_zonespec.csv -COPY --from=builder /tmp/SBFspot/TagList* /tmp/SBFspot/ +COPY --from=builder-base /tmp/SBFspot/mariadb/bin/SBFspot /usr/bin/sbfspot/SBFspot +COPY --from=builder-base /tmp/SBFspotUploadDaemon/mariadb/bin/SBFspotUploadDaemon /usr/bin/sbfspot/SBFspotUploadDaemon +COPY --from=builder-base /tmp/SBFspot/date_time_zonespec.csv /usr/bin/sbfspot/date_time_zonespec.csv +COPY --from=builder-base /tmp/SBFspot/TagList* /usr/bin/sbfspot/ -RUN cp /tmp/SBFspot/mariadb/bin/SBFspot /usr/bin/sbfspot -RUN cp /tmp/SBFspotUploadDaemon/mariadb/bin/SBFspotUploadDaemon /usr/bin/sbfspot -RUN cp /tmp/SBFspot/date_time_zonespec.csv /usr/bin/sbfspot -RUN cp /tmp/SBFspot/TagList* /usr/bin/sbfspot -RUN chmod a+x etc/services.d/sbfspot/run etc/services.d/sbfspot/finish /usr/bin/sbfspot/taillog.sh /usr/bin/sbfspot/generateConfig.sh /usr/bin/sbfspot/SBFspot /usr/bin/sbfspot/SBFspotUploadDaemon /usr/bin/sbfspot/SBFspot.default.cfg /usr/bin/sbfspot/SBFspotUpload.default.cfg +#RUN cp /tmp/SBFspot/mariadb/bin/SBFspot /usr/bin/sbfspot \ +# && cp /tmp/SBFspotUploadDaemon/mariadb/bin/SBFspotUploadDaemon /usr/bin/sbfspot \ +# && cp /tmp/SBFspot/date_time_zonespec.csv /usr/bin/sbfspot \ +# && cp /tmp/SBFspot/TagList* /usr/bin/sbfspot +COPY rootfs / +RUN chmod a+x /etc/services.d/sbfspot/run /etc/services.d/sbfspot/finish /usr/bin/sbfspot/taillog.sh /usr/bin/sbfspot/generateConfig.sh /usr/bin/sbfspot/genBluetoothConfig.sh /usr/bin/sbfspot/genEthernetConfig.sh /usr/bin/sbfspot/SBFspot /usr/bin/sbfspot/SBFspotUploadDaemon /usr/bin/sbfspot/SBFspot.default.cfg /usr/bin/sbfspot/SBFspotUpload.default.cfg + # --- install cron --- # set shell RUN echo 'SHELL=/bin/bash' > /etc/crontabs/root @@ -72,19 +94,19 @@ RUN echo '*/5 6-22 * * * /usr/bin/sbfspot/SBFspot -v -ad1 -am0 -ae0 -mqtt > / # monthly data SBFspot RUN echo '55 05 * * * /usr/bin/sbfspot/SBFspot -v -sp0 -ad0 -am1 -ae1 -finq > /dev/stdout' >> /etc/crontabs/root # start SBFspotUpload 1 min after boot -RUN echo '@reboot sleep 60 && /usr/bin/sbfspot/SBFspotUploadDaemon -c /usr/bin/sbfspot/SBFspotUpload.cfg' >> /etc/crontabs/root +RUN echo '@reboot sleep 60 && /usr/bin/sbfspot/SBFspotUploadDaemon -c /usr/bin/sbfspot/SBFspotUpload.cfg > /dev/stdout' >> /etc/crontabs/root # Log SBFspotUpload to HA logging window RUN echo '*/5 6-22 * * * /usr/bin/sbfspot/taillog.sh > /dev/stdout' >> /etc/crontabs/root # Labels LABEL \ io.hass.name="SBFspot" \ - io.hass.description="Home Assitant addon for Bluetooth SBFspot, is an open source project to get actual and archive data out of an SMA® inverter over Bluetooth or Ethernet (Speedwire®)" \ + io.hass.description="Home Assistant addon for Bluetooth SBFspot, is an open source project to get actual and archive data out of an SMA® inverter over Bluetooth or Ethernet (Speedwire®)" \ io.hass.arch="${BUILD_ARCH}" \ io.hass.type="addon" \ io.hass.version=${BUILD_VERSION} \ maintainer="Hasqt " \ - org.label-schema.description="Home Assitant addon for Bluetooth SBFspot, is an open source project to get actual and archive data out of an SMA® inverter over Bluetooth or Ethernet (Speedwire®)" \ + org.label-schema.description="Home Assistant wrapper addon for Bluetooth SBFspot." \ org.label-schema.build-date=${BUILD_DATE} \ org.label-schema.name="SBFspot" \ org.label-schema.schema-version="1.0" \ @@ -95,4 +117,5 @@ LABEL \ org.label-schema.vendor="Hasqt" -##CMD [ "/run.sh" ] not needed with rootfs/etc/init.d/{slug}run +#Launch nginx with debug options. not working yet +#CMD [ "nginx","-g","daemon off;error_log /dev/stdout debug;" ]