Ignore unavailable devices in docker-compose

If I put the following on a device that has i2c bus 1 and 7 on the host (RockPi) it builds and runs successfully:

      - /dev/i2c-7:/dev/i2c-7
      - /dev/i2c-1:/dev/i2c-1

However if I deploy this to a raspberry pi which doesn’t have i2c-7 then it fails to start the containers.

Is there a way to solve this without multiple docker-compose files / multiple repos?


(P.S. I know I can use privileged: true but want to avoid that)