How do I rebuild app using the host network rather than the docker network?

Hi,

Sometimes when I perform upgrades via the web UI, discourse tells me to run

cd /var/discourse
git pull
./launcher rebuild app

Since the rebuild process connects to github several times and github is half-blocked in China, where my server is hosted, I have to setup http/https proxy to better access github. Here is a comparison between visiting youtube w/o proxy and w/ proxy:

root@iosre:/var/discourse# wget https://youtube.com
--2021-06-10 23:55:05--  https://youtube.com/
Resolving youtube.com (youtube.com)... 66.220.152.17, 2001::3d6f:fadc
Connecting to youtube.com (youtube.com)|66.220.152.17|:443... ^C
root@iosre:/var/discourse# export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7891
root@iosre:/var/discourse# wget https://youtube.com
--2021-06-10 23:56:12--  https://youtube.com/
Connecting to 127.0.0.1:7890... connected.
Proxy request sent, awaiting response... 301 Moved Permanently
Location: https://www.youtube.com/ [following]
--2021-06-10 23:56:13--  https://www.youtube.com/
Connecting to 127.0.0.1:7890... connected.
Proxy request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘index.html’

index.html [  <=>  ] 510.58K   813KB/s    in 0.6s    

2021-06-10 23:56:14 (813 KB/s) - ‘index.html’ saved [522830]

However when I run ./launcher rebuild image, the script will enter the app and perform all operations inside the docker, where the network environment is different from the proxied host, and I’m not able to access youtube, so rebuild will fail most of the time.

root@iosre:/var/discourse# ./launcher enter app
root@iosre-app:/var/www/discourse# wget https://youtube.com
--2021-06-10 15:59:57--  https://youtube.com/
Resolving youtube.com (youtube.com)... 69.171.248.128, 2001::d238:33c1
Connecting to youtube.com (youtube.com)|69.171.248.128|:443... ^C
root@iosre-app:/var/www/discourse# export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7891
root@iosre-app:/var/www/discourse# wget https://youtube.com
--2021-06-10 16:00:10--  https://youtube.com/
Connecting to 127.0.0.1:7890... failed: Connection refused.

My question is, what can I do to make use of the host proxy inside the docker, especially in ./launcher rebuild app?

1 Like

Maybe see Replace rubygems.org with taobao mirror to resolve network error in China

There’s also a China template that you can include. You can see it in the templates folder. I’m not quite sure what it does.

(This isn’t a great answer, but it’s been two days and you don’t have any yet.)

2 Likes

Thanks Jay! The China template mirrors rubygems.org with gems.ruby-china.com, which is hosted by taobao/alibaba.

Inspired by that idea, I will try to mirror github.com with a domestic one, hopefully hosted by alibaba too.

2 Likes