Discourse Rebuild Fails During Bootstrap: Git HTTPS Timeout, Looking for a Clean SSH-Based Workaround

Hello,

I am running a standard self-hosted Discourse installation on Ubuntu using the official discourse_docker setup.

Environment

  • Ubuntu Server
  • Docker
  • Official discourse_docker
  • Single-container installation (app.yml)
  • Rebuild performed using:
cd /var/discourse
./launcher rebuild app

Problem

The rebuild process fails during the bootstrap phase when Discourse attempts to update the application source from GitHub.

The failure occurs at:

git fetch --tags --prune-tags --prune --force origin

and produces:

fatal: unable to access 'https://github.com/discourse/discourse.git/': SSL connection timeout

followed by:

FAILED
bootstrap failed with exit code 128

Important Findings

GitHub is reachable via HTTPS

On the host:

curl -I https://github.com

works correctly.

Also:

curl -I https://raw.githubusercontent.com

works correctly.

Git over HTTPS is unreliable in my environment

Inside the Discourse environment:

git ls-remote https://github.com/discourse/discourse.git

fails with:

SSL connection timeout

From my investigation, this appears to be caused by issues with my Internet provider’s connectivity to GitHub over HTTPS. At the moment, I am not trying to solve that networking problem itself. Instead, I am looking for a way to perform Discourse rebuilds using SSH, since SSH connectivity to GitHub works correctly in my environment.

GitHub SSH authentication works

I generated a new SSH key, added it to GitHub, and verified authentication:

ssh -T git@github.com

returns:

Hi <username>! You've successfully authenticated, but GitHub does not provide shell access.

Also:

git ls-remote git@github.com:discourse/discourse.git

works successfully from the host.

Repository URLs

On the host, I changed /var/discourse to use SSH:

origin git@github.com:discourse/discourse_docker.git

and Git operations work.

However, inside the Discourse application container:

cd /var/www/discourse
git remote -v

shows:

origin https://github.com/discourse/discourse.git

So during bootstrap, Discourse still attempts to use HTTPS.

What I Would Like To Achieve

My primary goal is to make Discourse rebuild reliably in an environment where GitHub HTTPS connections are unstable or frequently time out.

I would like to know:

  1. Is there an officially supported way to make Discourse bootstrap and rebuild use GitHub over SSH instead of HTTPS?
  2. If not, what is the recommended approach for environments where Git HTTPS is unreliable but SSH works correctly?
  3. Is there a supported method to inject SSH credentials into the bootstrap/build phase?
  4. Has anyone successfully configured discourse_docker to fetch Discourse source updates over SSH?

I would prefer a solution that survives future upgrades, but I am also interested in understanding whether SSH-based fetching during bootstrap is technically supported.

Any guidance would be greatly appreciated.

Thank you.