pimoroni / blinkt

Python Library for Blinkt; 8 APA102 LEDs for your Raspberry Pi
https://shop.pimoroni.com/products/blinkt
MIT License
314 stars 103 forks source link

Docker blues #88

Closed StevePoling closed 1 year ago

StevePoling commented 4 years ago

The Dockerfile doesn't seem to work for me. So, I made some tweaks.

This allowed me to successfully build a docker image, but when I run it I get this unhappy message:

Traceback (most recent call last): File "larson.py", line 5, in import blinkt File "/usr/local/lib/python2.7/dist-packages/blinkt.py", line 5, in import RPi.GPIO as GPIO File "/usr/lib/python2.7/dist-packages/RPi/GPIO/init.py", line 23, in from RPi._GPIO import * RuntimeError: This module can only be run on a Raspberry Pi!

Is there something I'm missing to tell python-rpi, or docker that I'm running on an RPi4?

MacOS wouldn't let me attach my Dockerfile. So here it is inline:

FROM balenalib/rpi-raspbian:jessie RUN apt-get update -qy && apt-get install -qy \ git \ python \ python-rpi.gpio ENTRYPOINT []
RUN git clone https://github.com/pimoroni/blinkt.git /blinkt WORKDIR /blinkt/library RUN python setup.py install WORKDIR /blinkt/examples/ CMD ["python", "larson.py"]

Gadgetoid commented 4 years ago

I'm afraid the Dockerfile was contributed by @alexellis and I don't have the first clue how to get it working. I'm crossing fingers that invoking his good name will cause him to magically appear and fix all our woes, though!

alexellis commented 4 years ago

Hi there. I can take a look at getting this working again, but it's going to take me a few days to set up an RPi and find a Blinkt etc.

ptbw commented 4 years ago

Hi Definately not a regular docker user but I do have a Raspberry Pi 4 running Buster and Docker I did confirm that blinkt examples worked on the Pi before creating the docker image.

Note my pi user can execute docker commands $ sudo usermod -aG docker pi

Using the docker file below it worked for me.

FROM balenalib/rpi-raspbian:buster
RUN apt-get update -qy && apt-get install -qy \
git \
python \
python-rpi.gpio 
ENTRYPOINT []
RUN git clone https://github.com/pimoroni/blinkt.git /blinkt
WORKDIR /blinkt/library
RUN python setup.py install
WORKDIR /blinkt/examples/
CMD ["python", "larson.py"]

Built the container using: $ docker build -t blinkt .

Execute using: $ docker run --privileged -ti blinkt

Hope this helps.

StevePoling commented 4 years ago

Thank you! This helps a lot.

The distinctions that made the difference between failing and succeeding are:

On Fri, Aug 21, 2020 at 6:36 AM Phil Willis notifications@github.com wrote:

Hi Definately not a regular docker user but I do have a Raspberry Pi 4 running Buster and Docker I did confirm that blinkt examples worked on the Pi before creating the docker image.

Note my pi user can execute docker commands $ sudo usermod -aG docker pi

Using the docker file below it worked for me.

FROM balenalib/rpi-raspbian:buster RUN apt-get update -qy && apt-get install -qy \ git \ python \ python-rpi.gpio ENTRYPOINT [] RUN git clone https://github.com/pimoroni/blinkt.git /blinkt WORKDIR /blinkt/library RUN python setup.py install WORKDIR /blinkt/examples/ CMD ["python", "larson.py"]

Built the container using: $ docker build -t blinkt .

Execute using: $ docker run --privileged -ti blinkt

Hope this helps.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pimoroni/blinkt/issues/88#issuecomment-678209063, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFPNAZQHEGZTSEXTCLRQVMDSBZEZNANCNFSM4QGTC32Q .

Gadgetoid commented 4 years ago

Thanks fellow Phil @ptbw 😁

So it looks like this line in the Dockerfile should be replaced?

https://github.com/pimoroni/blinkt/blob/3969699c8c72d1699c237fd80141b5c037460277/Dockerfile#L1

And also some documentation tweaks to state it should be run privileged? In fact the README.md doesn't mention Docker at all.

ptbw commented 4 years ago

NP. @Gadgetoid

Would you like me to create a PR to update the Dockerfile and add some instructions to the readme? (Basically expand on my comments above).

StevePoling commented 4 years ago

i could do the PR write-up, i understand the problem, and what Alex did to fix it. tho i might not do as well as you. i'd feel i'm slacking if i don't at least volunteer

On Fri, Aug 21, 2020 at 5:41 PM Phil Willis notifications@github.com wrote:

NP. @Gadgetoid https://github.com/Gadgetoid

Would you like me to create a PR to update the Dockerfile and add some instructions to the readme? (Basically expand on my comments above).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pimoroni/blinkt/issues/88#issuecomment-678528841, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFPNAZTZHDC6Q5HJHJ66CYTSB3SZFANCNFSM4QGTC32Q .

ptbw commented 4 years ago

@StevePoling be my guest, expand on my comments and review the PR that included the original Dockerfile. It seems sensible to add a note about updating the image for the future.

Gadgetoid commented 1 year ago

Note: I am deleting the Dockerfile as part of #102 since I have changed a lot of things, and don't have the ability to fix it.

Once #102 is merged I would welcome a PR re-adding it, if it's useful. With any luck there wont be another big change like this down the road.

alexellis commented 11 months ago

I'd support that decision :smile: