diff --git a/Dockerfile b/Dockerfile index b253fa9..dbb4729 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,18 @@ FROM arm32v7/python:alpine +WORKDIR /code + +# linux-headers fix the issue of "spidev_module.c:33:10: fatal error: linux/spi/spidev.h: No such file or directory + #include " RUN apk update \ - && apk add --update --no-cache alpine-sdk py-pip libusb-dev\ - && pip install RPi.GPIO pyusb + && apk add --update --no-cache alpine-sdk build-base linux-headers py-pip libusb-dev python-dev \ + py3-setuptools zlib-dev -VOLUME [ "/code" ] +RUN python -m pip install --upgrade pip setuptools \ + && pip install RPi.GPIO pyusb smbus2 Adafruit-SSD1306 -CMD python code/x.py +RUN pip install pillow --global-option="build_ext" --global-option="--disable-jpeg" + +ADD x.py /code + +CMD python x.py diff --git a/x.py b/x.py index 40a35ff..18b4ea9 100644 --- a/x.py +++ b/x.py @@ -107,7 +107,7 @@ def draw_stats(disp, draw, image): draw.rectangle((0, 0, width, height), outline=0, fill=0) # Shell scripts for system monitoring from here : https://unix.stackexchange.com/questions/119126/command-to-display-memory-usage-disk-usage-and-cpu-load - cmd = "hostname -I | cut -d' ' -f1" + cmd = "hostname -i | cut -d' ' -f1" IP = subprocess.check_output(cmd, shell=True) cmd = "top -bn1 | grep load | awk '{printf \"CPU Load: %.2f\", $(NF-2)}'" CPU = subprocess.check_output(cmd, shell=True)