-
Raspberry pi 5 GPIO in Docker Python카테고리 없음 2024. 2. 6. 15:55
docker-compose.yml
version: '3.8' services: gpio: build: . privileged: true restart: always devices: - "/dev" command: python3 ./test.py
Dockerfile
FROM python:3.11 WORKDIR /usr/src/app RUN pip install --upgrade pip RUN apt update RUN apt -y install swig python3-dev RUN apt -y install python3-setuptools RUN wget http://abyz.me.uk/lg/lg.zip RUN unzip lg.zip \ && cd lg \ && make \ && make install RUN pip install gpiozero COPY test.py /usr/src/app/test.py
test.py
from gpiozero import LED from time import sleep led = LED(2) while True: led.on() sleep(1) led.off() sleep(1)