markfinger / python-react

Server-side rendering of React components
MIT License
1.62k stars 116 forks source link

Docker integration #75

Closed prochafilho closed 7 years ago

prochafilho commented 7 years ago

I am trying to run the basic_rendering example with Docker. The node server is sitting inside the docker container and it all looks good but, when I make the request to /render I get an error :

ReactRenderingError: Message: Cannot find module '/Users/paulo/projects/python-react/examples/basic_rendering/static/js/CommentBox.jsx'

Truth be told I am also a beginner with Docker, any ideias on how to integrate with the docker container?

mic159 commented 7 years ago

Inside docker, the path to your file will be different. The docker container has its own directory layout.

What you are looking for is the ADD command in your Dockerfile that puts your code into the docker container.

For example of you had ADD . /code then the current directory (.) gets put under /code.

The JS file you want to render needs to be inside that path that was ADDed to docker.

Then you would tell it to render something like /code/static/js/comment_box.jsx

markfinger commented 7 years ago

Additionally, there are some path/file checks on both ends. So you'll probably need the same mounts in both the python and the node containers.

prochafilho commented 7 years ago

Thank you so much for both of your help! The container only hosts the node process, I am trying to follow Docker's: one container, one process. The python process is running from my own local machine, and I see the files.

prochafilho commented 7 years ago

Hey Mark! Thank you for your advice! So, the mounts need to match on both side of the containers?

markfinger commented 7 years ago

Yeah, both will need to match. The python process will check for the entry point existence and the node process will try to import the path.

prochafilho commented 7 years ago

Thank you guys. Im closing this.