mljar / mercury

Convert Jupyter Notebooks to Web Apps
https://RunMercury.com
GNU Affero General Public License v3.0
3.99k stars 253 forks source link

Wiki Documentation : Deployment on LAN/Intranet #40

Open shivendra2015iiit opened 2 years ago

shivendra2015iiit commented 2 years ago

Prerequisite

Mercury is setup and accessible at 127.0.0.1:8000 (https://github.com/mljar/mercury#readme)

Background

Here our aim is to make mercury accessible within LAN. Currently it can only be accessed on the same computer it is hosted on at Localhost (127.0.0.1:8000). To achieve this please follow along. These steps are for windows Computer but same can be applied for other OS with some tweaks (for ubuntu we do not require firewall configuration discussed later)

Adding you IPV4 address to Allowed host

Get IPV4 address

On cmd

ipconfig

image

Firewall access

Now we have to allow firewall to accept incoming connection to mercury port (8000 by default)

Bind your IP with mercury instead localhost

We can not access 127.0.0.1 from other computer, we can only access it with it's ip-address once we have access to the computer port number will help us access the process we are looking for. For us port is 8000 (for process mercury)

-To start mercury on specific ip use below command which running mercury.

mercury runserver \<yourIPaddress:portNumber> --runworker

mercury runserver  192.168.29.186:8000 --runworker

Voila you are done! now you can access it from anywhere on LAN

shivendra2015iiit commented 2 years ago

@pplonski anything you want me to update?

pplonski commented 2 years ago

@shivendra2015iiit thank you for docs!

I think the step with editing the settings.py is not needed. There is environment variable ALLOWED_HOSTS that can be set with the IP number.

In the linux terminal I would do:

ALLOWED_HOSTS=192.168.29.186 mercury  runserver 192.168.29.186:8000 --runworker

without changing the settings.py. Could you please check how the command with env variable set should look like on Windows?

shivendra2015iiit commented 2 years ago

yes @pplonski , found out in same bash shell if we set ALLOWED_HOSTS=<IP_ADDRESS> and then host mercury, it works. I have updated the documentation.

pplonski commented 1 year ago

I'm closing the issue. We will provide Mercury Cloud soon for easy deployments.

hmanz commented 6 months ago

@shivendra2015iiit this guide you made is super helpful, thank you! @pplonski would it be possible to add this LAN guide to the documentation/wiki?

Also wanted to mention a few points based on my experience in implementing your guide:

  1. It wasn't clear to me how/where to run the line set ALLOWED_HOSTS=192.168.29.186. Instead what I did was create a .env file and place ALLOWED_HOSTS=192.168.29.186 in it. The .env file needs to be in the folder where you plan to run mercury from.
  2. An alternative (and perhaps easier) option instead of mercury runserver 192.168.29.186:8000 --runworker is to just run mercury run 192.168.29.186:8000 inside the folder where your notebooks are.
  3. I noticed that when I run mercury on LAN, then any changes I make to the notebooks locally will update on LAN as well even if I make my changes on a different git branch. Does anyone know how we can keep changes from transferring across git branches? I.e. I want to develop and test my dashboards on my git develop branch, and have my LAN dashboards obtaining their code from the master branch only.
  4. I noticed that when I run mercury on LAN, then if I also run mercury locally it will add my local notebooks to the LAN mercury too. Is there a way we can run mercury in two separate instances, one for local testing and one for LAN? In https://github.com/mljar/mercury/issues/336 @pplonski mentioned that we can have "several deployments of mercury". But it's not clear to me how to do that.

Thank you both for all your time and effort! God bless you!

pplonski commented 6 months ago

@apjanusz what do you think about it?

shivendra2015iiit commented 6 months ago

@pplonski @apjanusz if you have any review suggestion I can accommodate here.

hmanz commented 4 months ago

Hello and hope you are all doing well. Any ideas regarding how to accomplish bullets 3 (separate git branches) and 4 (several deployments of mercury)? @pplonski

hmanz commented 4 months ago

@shivendra2015iiit thanks again for this guide, it was super helpful and has been working great on LAN. By any chance do you also know how we can deploy mercury in a way where it can be accessed outside the network? My understanding is it would be similar to the LAN process but somehow we have to create a webserver with non-local IP address. I'm not very experienced in this field so I would appreciate any help. Thanks!