Refactored and updated dsmr_parser

This commit is contained in:
Ard Kuijpers
2025-03-22 17:20:52 +01:00
parent 53022aebb8
commit ccb31cbdc1
21 changed files with 731 additions and 69 deletions

View File

@@ -1,31 +1,31 @@
FROM python:3.12 AS build
RUN pip install poetry
# For more information, please refer to https://aka.ms/vscode-docker-python
FROM python:3.11-slim as base
FROM base as builder
RUN apt-get update \
&& apt-get install gcc=4:10.* git=1:2.* -y \
&& apt-get clean
COPY requirements.txt /app/requirements.txt
WORKDIR /app
ENV PATH=/root/.local/bin:$PATH
RUN pip install --user -r requirements.txt
COPY . /app
FROM base as app
COPY . /app
COPY --from=builder /root/.local /root/.local
# # Keeps Python from generating .pyc files in the container
# ENV PYTHONDONTWRITEBYTECODE 1
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED 1
# Access local binaries
ENV PATH=/root/.local/bin:$PATH
ENV POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=1 \
POETRY_VIRTUALENVS_CREATE=1 \
POETRY_CACHE_DIR=/tmp/poetry_cache
WORKDIR /app
COPY pyproject.toml poetry.lock ./
COPY packages ./packages
RUN apt update && apt install -y build-essential
RUN if [ $(dpkg --print-architecture) = "armhf" ]; then \
printf "[global]\nextra-index-url=https://www.piwheels.org/simple\n" > /etc/pip.conf ; \
fi
RUN --mount=type=cache,target=$POETRY_CACHE_DIR poetry -v install --without dev --no-root
FROM python:3.12-slim AS final
WORKDIR /app
ENV VIRTUAL_ENV=/app/.venv \
PATH="/app/.venv/bin:$PATH" \
PYTHONUNBUFFERED=1
COPY --from=build ${VIRTUAL_ENV} ${VIRTUAL_ENV}
COPY dsmr2mqtt ./dsmr2mqtt
# During debugging, this entry point will be overridden. For more information, refer to https://aka.ms/vscode-docker-python-debug
CMD ["python", "app.py"]
CMD ["python", "-m", "dsmr2mqtt"]