Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build and Push Docker Image

on:
push:
branches: [ "main" ]
workflow_dispatch: # Allows you to run it manually if needed

jobs:
build:
runs-on: ubuntu-latest
# Added permissions for GHCR
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Metadata (Tags/Labels)
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/grott
tags: |
type=sha,format=short
type=raw,value=latest

- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: docker/dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Added caching to speed up subsequent builds
cache-from: type=gha
cache-to: type=gha,mode=max
29 changes: 13 additions & 16 deletions docker/dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
FROM python:3.7-slim
FROM python:3.12-slim

ENV LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8

# Run updates
RUN apt-get clean && apt-get update && apt-get upgrade -y

# Set the locale
RUN apt-get install -y locales && locale-gen en_US.UTF-8
RUN apt-get clean && apt-get update && apt-get upgrade -y && apt-get install -y locales && locale-gen en_US.UTF-8

#Install required python packages
RUN pip install paho-mqtt
RUN pip install requests
RUN pip install influxdb
RUN pip install influxdb-client
RUN pip install --no-cache-dir \
psutil \
paho-mqtt \
requests \
influxdb \
influxdb-client

COPY grott.py /app/grott.py
COPY grottconf.py /app/grottconf.py
COPY grottdata.py /app/grottdata.py
COPY grottproxy.py /app/grottproxy.py
COPY grottsniffer.py /app/grottsniffer.py
COPY grott.ini /app/grott.ini
COPY grott.py grottconf.py grottdata.py grottproxy.py \
grottsniffer.py grottserver.py examples/grott.ini \
examples/Extensions/grottext.py examples/Extensions/grotcsv.py \
/app/

WORKDIR /app
CMD ["python", "-u", "grott.py", "-v"]
CMD ["python", "-u", "grott.py", "-v"]
12 changes: 10 additions & 2 deletions grottserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,18 @@ def do_GET(self):
f.close()
return
except IOError:
responsetxt = b"<h2>Welcome to Grott the growatt inverter monitor: " + str.encode(vrmserver) + b"</h2><br><h3>Made by Ledidobe, Johan Meijer</h3>"
responsetxt = b"""<h2>Welcome to Grott the growatt inverter monitor: """ + str.encode(vrmserver) + b"""</h2>
<h3>Made by Ledidobe, Johan Meijer</h3>
<h3>Supported paths:</h3>
<ul>
<li><a href="/info">Server Info</a> - View server status and connection information</li>
<li><a href="/datalogger">Datalogger</a> - Datalogger operations and registry</li>
<li><a href="/inverter">Inverter</a> - Inverter operations and registry</li>
<li><a href="/help">Help</a> - Help documentation</li>
</ul>"""
responserc = 200
responseheader = "text/html"
htmlsendresp(self,responserc,responseheader,responsetxt)
htmlsendresp(self, responserc, responseheader, responsetxt)
return

elif self.path.startswith("info"):
Expand Down