Running dev environment on Windows WSL

Hi
I have configured WSL on my Win 10 for CHT Local Environment testing, and after starting Docker, I get the error below: 404 Not Found, nginx/1.13.6


WSL Errors4

Any one with an idea? Tried different things, none working so far

Can you confirm if your all your containers got started? docker ps -a

Alternatively, this might be come in handy in dealing with some of the docker-compose issues cht-core/scripts/docker-helper at master · medic/cht-core · GitHub

@derick
I think the challenge is WSL VM IP and local machine IP, need to figure it out
I share the status of the containers

@oyierphil - I think you should try a restart:

cd /var/boda_comm
sudo docker-compose restart

As well, you can find the IP of your WSL VM with:

ip -o addr show eth0
4: eth0    inet 192.168.37.56/20 brd 192.168.47.255 scope global eth0\       valid_lft forever preferred_lft forever
4: eth0    inet6 fe80::215:5dff:fe64:20f2/64 scope link \       valid_lft forever preferred_lft forever

So for me, my IP would be 192.168.37.56.

Per @derick’s comment, I also recommend the CHT Docker Helper script he cited. It handles a lot of these issues for you and also installs a valid TLS certificate so your install works with Android for entirely local and offline testing!

Dear Jones
I have tried all the options above and so far none has worked
Will try restarting again tomorrow
Regards

@oyierphil - oh no! I’m sorry to hear that. However, I’m glad you reported you’re still having problems. I asked another teammate who has access to a windows system to see if they can offer and advice.

For the CHT Docker Helper script, did it end up going through all 5 tries and failing? This can often take many minutes on older hardware. As well, restarting your entire computer may help (which I think you said you’d try tomorrow).

@mrjones
Had tried restarting the containers earlier, but wanted to try again this morning, same error, 404 Not Found —nginx/1.13.6
Figuring out where the problem is, will try again in the evening

@oyierphil - Any luck with the restarts or the CHT Docker Helper script?

@mrjones
Not yet solved, tried many options this afternoon and not yet, will try again later
Interesting I can ping 127.0.0.1 from the terminal but cant access the same on the browser, will try again later
Will use the remote instance for testing now, good afternoon

@oyierphil - oh no! I’m sorry you’re still having problems : (

I have a spare windows machine and I was able to get the CHT running locally by using the CHT Docker Helper Script:

  1. Ensuring I have WSL 2 installed and running

  2. Install Docker Desktop

  3. Make sure Docker Destkop is running and in compose v2.0. The script failed on non-obvious ways when Docker Desktop was not running after a reboot - hence me checking “Start when you login”. As well, it would not work unless compose v2 was checked:

  4. Launch a WSL command line with Start Menu → wsl

  5. cd into your clone of the CHT Core Repo cht-core/scripts/docker-helper

  6. create your env file per the steps in “First Run”

  7. Run the helper script and enjoy a local dev environment!

    ]

1 Like

@mrjones
I today managed to start a local development environment on WSL after installing Docker Destkop. Followed the steps above, number 6 took me to another page (cht-core/scripts/docker-helper at master · medic/cht-core · GitHub), which has another link to the documentation (App Developer Hosting | Community Health Toolkit). Figuring out how to create the .env file, given that I have a complete project folder with my configs and forms, will appreciate your insights

I have however managed to run the cht-core application on my local computer after accepting the security risks due to lack of SSL certificate

Hope this work when I change to my project folder, push my configs and forms for testing on the different places and roles

@oyierphil - That’s such great news - thanks for reporting back about your success!

To create an .env file, you can follow the “First Run” steps here, but it’s just three variables for project name, HTTP port and HTTPS port. It looks like this:

COMPOSE_PROJECT_NAME=my_first_project
CHT_HTTP=8080
CHT_HTTPS=8443   

You then specify the path to it with the -e flag. You’ll always want to specify the relative path like this:

./cht-docker-compose.sh -e ../../../my_first_project/.env_docker

Finally, to get valid TLS certificates, you can get the CHT URL from the docker helper as seen here:

In you’re screenshot you’re using https://localhost (and also implicitly port 443), but the CHT Docker Helper installs certificates for *.my.local-ip.co. The * part is the IP of your container but with dashes. So in my screenshot, the IP is 172.24.104.228 which the helper script has translated to the final URL of https://172-24-104-228.my.local-ip.co:8443

Best of luck!