guysoft/MagicMirrorOS

How to use python within the docker container

mattkatz opened this issue · 4 comments

Hi - I'm loving this so far. Great to get a working magicmirror install so quickly.
I'm trying to add https://github.com/nischi/MMM-Face-Reco-DNN - which uses some python libraries under the hood. I've got this working on the base os install, but of course the magicmirror can't use it because the docker container doesn't have access to the base os python.

I'm vaguely aware of docker containerization, but my furious googling of "add python to existing docker container" wasn't enough.

I want to add a layer over your docker image that also has py3, some libraries (pip and debian) installed.
For my needs, should I be forking this repo, then editing the Dockerfile to add more steps?
Or does it make more sense for me to create a new dockerfile that uses FROM: https://hub.docker.com/r/karsten13/magicmirror and then install python3 and then the other libraries?

I want to do something that will be as compatible as possible for future updates etc.

I think building an extra docker file might be the right path because DNN stuff needs lots of libs to work together correctly.
You could put it on Dockerhub and set the trigger that once a new baseimage is out it will build and push a new one for you.

I agree to @guysoft
If you fork the project you will stay on this code base forever or you have to merge from the orignal project regularly.
So its better to use karsten13/magicmirror as base image.

There was already a question about python here, may this helps as starting point.

The Module needs a camera, so you have to map the video device into the container.

This is a full example for motioneye (which uses a camera too), you need to add the devices section to your docker-compose.yml as shown below.

version: "3.5"

services:
  motioneye:
    container_name: motion
    hostname: motion
    image: karsten13/motioneye:arm
    ports:
      - "8081:8081"
      - "8765:8765"
    volumes:
      - ./conf:/etc/motioneye
      - ./files:/var/lib/motioneye
      - /etc/localtime:/etc/localtime:ro
      - /opt/vc:/opt/vc:ro
    environment:
      LD_LIBRARY_PATH: /opt/vc/lib
    devices:
      - /dev/video0
    restart: unless-stopped

I'm closing this issue for now. If you feel this issue should remain open, please let me know.