iot-root / garden-of-eden

Truly own that which is yours!
GNU General Public License v3.0
30 stars 8 forks source link

dockerize #1

Open iot-root opened 1 year ago

iot-root commented 1 year ago
iot-root commented 5 months 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"]
iot-root commented 5 months ago

@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