-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix docker build and runtime config #296
Conversation
These changes look good to me however I've been developing sans docker. If I get some extra time in the near future I'll do some testing with these changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and seems to be working from what I can see
simple-pid==2.0.0 | ||
waitress==3.0.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah good catch, I must have missed that in one of my commits
docker-compose.yml
Outdated
# - /dev/gpiomem:/dev/gpiomem | ||
# /dev/ttyUSB0:/dev/ttyUSB0 | ||
# /dev/ttyUSB1:/dev/ttyUSB1 | ||
# /dev/ttyACM0:/dev/ttyACM0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change these lines to this:
# - "/dev/ttyUSB0:/dev/ttyUSB0"
# - "/dev/ttyUSB1:/dev/ttyUSB1"
# - "/dev/ttyACM0:/dev/ttyACM0"
# If using pi uncomment these lines:
# - "/dev/gpiomem:/dev/gpiomem"
# If using potato uncomment these lines:
# - "/dev/gpiochip0:/dev/gpiochip0"
# - "/dev/gpiochip1:/dev/gpiochip1"
For whatever reason when I tested this docker compose didn't like some of these fields not being enclosed in quotes, even though it worked for others. I don't know why, version difference maybe, but having them all quoted worked fine. The gpio devices are also different depending on which sbc you're using so that needs to be added and documented
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is weird - can you check if the reason is having each line hyphenated or is it both hyphenation and quotes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah brain fart, it does only need the hyphenation, quotes are unnecessary. Without either you get a confusing error message and I had tried quotes first which gives a more helpful error message about needing hyphenation, so I had assumed it was both.
Strangely having only two device lines, with only the first hyphenated and neither quoted does build and startup without error, but the devices don't get properly mapped. It's only 3 or more device lines with only the first hyphenated when errors start occurring for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird, maybe some yaml parser bug - anyway I updated to file to fix this list.
docker/api_dockerfile
Outdated
RUN apt-get update && apt-get install -y build-essential python3-libgpiod | ||
RUN apt-get update && apt-get install -y build-essential | ||
COPY backend/requirements.txt . | ||
|
||
RUN pip3 install -r requirements.txt | ||
|
||
# python-libgpiod does not work on docker images | ||
# as it targets python 3.7 (??) | ||
RUN pip3 install gpiod |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why the python3-libgpiod package isn't working anymore in docker, it isn't a python versioning issue since I'm using that with python 3.11 on my pi just fine, but just installing gpiod through pip also doesn't work because they updated the api of the library in version 2 so it just errors on trying to load the device. The old version 1.5.4 also doesn't work, though I can't remember exactly why.
Ultimately we probably just need to update the gpiod code to use the new version 2 of the library and move away from using the system package entirely, but that's outside of the scope of this PR and since I don't think there's a different quick fix for this best thing is just to add a note somewhere saying gpio doesn't work with docker and make an issue for upgrading gpiod.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it seems it is a clusterfuck of bugs. First of all it's about python docker image - for whatever reason python3-libgpiod available in apt repository for this image is built against python 3.7 and python 3.11 just does not even try to load those share libraries on start.
Also it seems python3-libgpiod was abandoned at version 1.5.4 and all development moved to v2. I'll add GH issue to fix compatibility but sadly I don't use any SBC as I think Raspberry Pi is a shit abomination of modern computing and electronics design.
TL;DR
Fix various docker issues:
What
What is affected by this PR?