Open iot-root opened 1 year ago
Dockerfile
FROM python:3.9-slim
ENV VIRTUAL_ENV=/opt/venv
RUN python -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
WORKDIR /app
COPY requirements.txt .
RUN python -m pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt
COPY main.py .
# Run mqtt.py when the container launches
CMD ["python", "mqtt.py"]
docker-compose.yml
version: '3.8'
services:
gardyn:
build: .
volumes:
- .:/app
env_file:
- .env
command: ["python", "main.py"]
version: '3'
services:
pigpiod:
image: corbosman/pigpiod
privileged: true
ports:
- "8888:8888"
api:
build:
context: .
dockerfile: Dockerfile
privileged: true
env_file:
- .env
environment:
- GPIOZERO_PIN_FACTORY=pigpio
- PIGPIO_ADDR=pigpiod
depends_on:
- pigpiod
volumes:
- ./:/app
command: ["python", "main.py"]
@petercorrea FYI the one issue is dealing with pigpiod, I did have this working but did not test on a pi zero, just the pizero 2
see example docker files