rawpython / remi

Python REMote Interface library. Platform independent. In about 100 Kbytes, perfect for your diet.
Apache License 2.0
3.48k stars 401 forks source link

Run it in a docker container #458

Closed caco3 closed 2 years ago

caco3 commented 2 years ago

Has somebody succeeded to run a remi app in a docker container? I am simply unable to connect to it :(

As I can see, others had struggle before, but that was 4 years ago: https://gitter.im/dddomodossola/remi/archives/2017/02/02

caco3 commented 2 years ago

Hehe, just got it working :)

@dddomodossola, your 4 year old hint and https://stackoverflow.com/questions/54101508/how-do-you-dockerize-a-websocket-server/54102318 helped me.

All one has to do is to start the server with IP 0.0.0.0 instead of the default 127.0.0.1.

Eg.: start(remi_gui.Gui, address="0.0.0.0", port=8081, multiple_instance=False, enable_file_cache=True, update_interval=0.1, start_browser=False)

Dockerfile:

FROM python:3

WORKDIR /

COPY ./*.py ./
EXPOSE 8081
CMD [ "python", "./main.py" ]

Of course make also sure all required python packages are added.

Then build it with docker build -t app . and run the docker container with: docker run -it --rm -p 8081:8081 --name my-app app

dddomodossola commented 2 years ago

@caco3 thank you very much for sharing, this will help other user for sure ;-)