* make timestamp handling stateless * adapt tests for stateless timestamp handling * initial version * add more type annotations * add more type annotations * fix Generator annotation for ha_proxy_confs * fix names of issue branches * add more type annotations * don't use depricated varn anymore * don't mark all test as async * fix imports * fix solarman unit tests - fake Mqtt class * print image build time during proxy start * update changelog * fix pytest collect warning * cleanup msg_get_time handler * addapt unit test * label debug images with debug * dump droped packages * fix warnings * add systemtest with invalid start byte * update changelog * update changelog * add exposed ports and healthcheck * add wget for healthcheck * add aiohttp * use config validation for healthcheck * add http server for healthcheck * calculate msg prossesing time * add healthy check methods * fix typo * log ConfigErr with DEBUG level * Update async_stream.py - check if processing time is < 5 sec * add a close handler to release internal resources * call modbus close hanlder on a close call * add exception handling for forward handler * update changelog * isolate Modbus fix * cleanup * update changelog * add heaithy handler * log unrelease references * add healtcheck * complete exposed port list * add wget for healtcheck * add aiohttp * use Enum class for State * calc processing time for healthcheck * add HTTP server for healthcheck * cleanup * Update CHANGELOG.md * updat changelog * add docstrings to state enum * set new state State.received * add healthy method * log healthcheck infos with DEBUG level * update changelog * S allius/issue100 (#101) * detect dead connections - disconnect connection on Msg receive timeout - improve connection trace (add connection id) * update changelog * fix merge conflict * fix unittests * S allius/issue108 (#109) * add more data types * adapt unittests * improve test coverage * fix linter warning * update changelog * S allius/issue102 (#110) * hotfix: don't send two MODBUS commands together * fix unit tests * remove read loop * optional sleep between msg read and sending rsp * wait after read 0.5s before sending a response * add pending state * fix state definitions * determine the connection timeout by the conn state * avoid sending MODBUS cmds in the inverter's reporting phase * update changelog * S allius/issue111 (#112) Synchronize regular MODBUS commands with the status of the inverter to prevent the inverter from crashing due to unexpected packets. * inital checkin * remove crontab entry for regular MODBUS cmds * add timer for regular MODBUS polling * fix Stop method call for already stopped timer * optimize MB_START_TIMEOUT value * cleanup * update changelog * fix buildx warnings * fix timer cleanup * fix Config.class_init() - return error string or None - release Schema structure after building thr config * add quit flag to docker push * fix timout calculation * rename python to debugpy * add asyncio log * cleanup shutdown - stop webserver on shutdown - enable asyncio debug mode for debug versions * update changelog * update changelog * fix exception in MODBUS timeout callback * update changelog
80 lines
2.4 KiB
Docker
80 lines
2.4 KiB
Docker
ARG SERVICE_NAME="tsun-proxy"
|
|
ARG UID=1000
|
|
ARG GID=1000
|
|
|
|
#
|
|
# first stage for our base image
|
|
FROM python:3.12-alpine AS base
|
|
USER root
|
|
|
|
COPY --chmod=0700 ./hardening_base.sh .
|
|
RUN apk upgrade --no-cache && \
|
|
apk add --no-cache su-exec && \
|
|
./hardening_base.sh && \
|
|
rm ./hardening_base.sh
|
|
|
|
#
|
|
# second stage for building wheels packages
|
|
FROM base AS builder
|
|
|
|
# copy the dependencies file to the root dir and install requirements
|
|
COPY ./requirements.txt /root/
|
|
RUN apk add --no-cache build-base && \
|
|
python -m pip install --no-cache-dir -U pip wheel && \
|
|
python -OO -m pip wheel --no-cache-dir --wheel-dir=/root/wheels -r /root/requirements.txt
|
|
|
|
|
|
#
|
|
# third stage for our runtime image
|
|
FROM base AS runtime
|
|
ARG SERVICE_NAME
|
|
ARG VERSION
|
|
ARG UID
|
|
ARG GID
|
|
ARG LOG_LVL
|
|
ARG environment
|
|
|
|
ENV VERSION=$VERSION
|
|
ENV SERVICE_NAME=$SERVICE_NAME
|
|
ENV UID=$UID
|
|
ENV GID=$GID
|
|
ENV LOG_LVL=$LOG_LVL
|
|
ENV HOME=/home/$SERVICE_NAME
|
|
|
|
|
|
# set the working directory in the container
|
|
WORKDIR /home/$SERVICE_NAME
|
|
|
|
VOLUME ["/home/$SERVICE_NAME/log", "/home/$SERVICE_NAME/config"]
|
|
|
|
# install the requirements from the wheels packages from the builder stage
|
|
# and unistall python packages and alpine package manger to reduce attack surface
|
|
COPY --from=builder /root/wheels /root/wheels
|
|
COPY --chmod=0700 ./hardening_final.sh .
|
|
RUN python -m pip install --no-cache --no-index /root/wheels/* && \
|
|
rm -rf /root/wheels && \
|
|
python -m pip uninstall --yes setuptools wheel pip && \
|
|
apk --purge del apk-tools && \
|
|
./hardening_final.sh && \
|
|
rm ./hardening_final.sh
|
|
|
|
|
|
# copy the content of the local src and config directory to the working directory
|
|
COPY --chmod=0700 entrypoint.sh /root/entrypoint.sh
|
|
COPY config .
|
|
COPY src .
|
|
RUN date > /build-date.txt
|
|
EXPOSE 5005 8127 10000
|
|
|
|
# command to run on container start
|
|
ENTRYPOINT ["/root/entrypoint.sh"]
|
|
CMD [ "python3", "./server.py" ]
|
|
|
|
|
|
LABEL org.opencontainers.image.title="TSUN Gen3 Proxy"
|
|
LABEL org.opencontainers.image.authors="Stefan Allius"
|
|
LABEL org.opencontainers.image.source=https://github.com/s-allius/tsun-gen3-proxy
|
|
LABEL org.opencontainers.image.description='This proxy enables a reliable connection between TSUN third generation inverters (eg. TSOL MS600, MS800, MS2000) and an MQTT broker to integrate the inverter into typical home automations.'
|
|
LABEL org.opencontainers.image.licenses="BSD-3-Clause"
|
|
LABEL org.opencontainers.image.vendor="Stefan Allius"
|