guysoft/MagicMirrorOS

Python 3 installation in container

julianCast opened this issue · 7 comments

Modules like Google-Cast require Python3.
I did, but I think it needs to be installed in the containers to get the correct path in the module.

I'll quote him:

Can you ask there how you can expose other system apps to the MagicMirror process, so modules can use them? Afaik, they're using docker to run MagicMirror, so you just need to install python3 in the container as well (as you're running the which command in your host OS, instead of the container). However, each reboot you would need to repeat the install, so they must have a better way of setting how the container is created, so you can install the Python interpreter inside.

You could build your own container.
You create a Dockerfile and then you can add:

FROM karsten13/magicmirror:latest

Then build your own docker image top of this one.
Then use that in docker-compose.yml

@khassel might have more insight on how he wants to maintain modifications to the image.

As @guysoft already mentioned: Build your own image on top of karsten13/magicmirror:latest.

The problem is module A needs python2.7, module B needs python3.8, module C needs go ...
I don't want to maintain all the module dependencies. A standard module using nodejs and bash will work with my image.

There are may good reasons why MMM-GoogleCast is using python. An existing python lib is used, python is the language of the developer, ...

My intention of building the mm-image is to put only necessary things inside and limit image size.
E.g. adding python 3 would increase the current size of 760MB to ~860MB 530MB to ~580MB. And all the users not needing python would have to download the additionally 100MB 50 MB with every pull.

So if you want to build such an image, all I can do is to write a first draft of the Dockerfile you need.

edit: corrected image sizes

It might be worth considering making a python 3 version since version 2 has already reached its EOL
https://www.python.org/doc/sunset-python-2/
If MM ks using python 2 it might be worth opening an issue there and linking to this one.

mm needs no python. I only gave examples about modules using different languages.

Image for MMM-GoogleCast:

FROM karsten13/magicmirror:latest

USER root

RUN set -e; \
    apt-get update; \
    DEBIAN_FRONTEND=noninteractive apt-get -qy --allow-unauthenticated install python3 python3-pip; \
    pip3 install pychromecast; \
    apt-get clean; \
    rm -rf /var/lib/apt/lists/*; \
    python3 --version;

USER node

Build with docker build -t karsten13/magicmirror:python .

Image sizes:

karsten13/magicmirror             python                    759MB
karsten13/magicmirror             latest                    528MB

Working:
grafik

Thank you for the solution and test! I have to check how to build my own container.
I'll share this in the opened module issue.

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