From ccf152bd2545a99f22dbfe22965e55fee8052df9 Mon Sep 17 00:00:00 2001 From: BlueFox Date: Mon, 16 Jun 2025 11:17:57 +0200 Subject: [PATCH] Added Dockerfile and instructions to build it --- Dockerfile | 7 +++++++ README.md | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ab41221 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.13-slim +RUN useradd --create-home --shell /bin/bash solarcontrol +WORKDIR /script +COPY solarcontrol.py ./ +RUN pip install --upgrade pip && pip3 install --no-cache-dir paho-mqtt python-dotenv requests +USER solarcontrol +ENTRYPOINT ["/usr/bin/python3", "solarcontrol.py"] diff --git a/README.md b/README.md index 2649eec..1fd4cee 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,14 @@ Enforce a zero export (or whatever consumption you like) policy with an OpenDTU- ## Configuring and usage + +### Docker + +Todo + + +### Bare-bone + The script can be configured using the .env file where you can adjust it (hopefully perfect) to your needs. After that, just run the script: ```bash @@ -14,6 +22,18 @@ python3 lge320reader.py Please note: the .env file needs to be in the same folder or any other folder higher up in the directory structure as the script (more specifically, the WORKDIR). It is just a help, actually, the script searches for specific variables in its environment variables. It only loads the .env file so that you do not need to `export` all the files before running (see https://pypi.org/project/python-dotenv/ for more details). This also means that when using it in docker, you can set the docker containers environment file to that .env file and it will be accepted too. +## Building docker + +To build the image for docker, simply use the following commands: + +```bash +docker login # login to docker hub +docker buildx create --name buildx-multi-arch +docker buildx use buildx-multi-arch +docker buildx build --no-cache --platform linux/amd64,linux/386,linux/arm/v5,linux/arm/v7,linux/arm64/v8,linux/ppc64le,linux/s390x -t bluefox42/solarcontrol:v0.2 . --push +``` + + ## License This project is licensed under the terms of the GNU General Public License v3.0 or later, see [COPYING](COPYING).