Craftonix

  • Nov 9, 2023
  • Joined Aug 16, 2023
  • 0 best answers
  • For the next person who finds this:

    Ok, got it working balena has actually managed to make Udev work well out of the box with their base images. so for perpetuity here is my docker-compose.yaml & Dockerfile:
    Dockerfile.template:

    FROM balenalib/%%BALENA_ARCH%%-debian-python:3.9-bullseye
    ENV UDEV=1
    ENV DEBIAN_FRONTEND=noninteractive
    RUN apt-get update && apt-get install -y wget python3-dev build-essential cmake pkg-config libjpeg-dev libtiff5-dev libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev libgtk2.0-dev libgtk-3-dev libatlas-base-dev gfortran git libopencv-dev
    RUN git clone --recurse-submodules https://github.com/luxonis/depthai-python.git
    
    WORKDIR depthai-python
    
    RUN ./ci/docker_dependencies.sh
    RUN pip install -U pip && pip install --extra-index-url https://www.piwheels.org/simple/ --prefer-binary opencv-python
    
    # Install C++ library
    RUN cmake -S /depthai-python/depthai-core -B /build -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=ON -D CMAKE_INSTALL_PREFIX=/usr/local
    RUN cmake --build /build --parallel 4 --config Relase --target install
    
    # Install Python library
    RUN cd /depthai-python && python3 -m pip install .

    docker-compose.yaml:

    version: '2.4'
    
    services:
      spatial-tracker:
        build:
          context: .
          dockerfile: Dockerfile.template
        restart: always
        privileged: true
        network_mode: host
        environment:
          - DISPLAY=$DISPLAY
        devices:
          - "/dev/bus/usb:/dev/bus/usb"
          - "/tmp/.X11-unix:/tmp/.X11-unix"
        device_cgroup_rules:
          - "c 189:* rmw"
        tty: true
        labels:
          io.balena.features.dbus: '1'
          io.balena.features.balena-socket: '1'
          io.balena.features.kernel-modules: '1'
          io.balena.features.sysfs: '1'