Repository: readthedocs/readthedocs.org

Issue:
Docs: explain how to use ngrok with Docker setup
While working with external services, like GitHub or Stripe, it's handy to use ngrok (https://ngrok.com) to access the instance running locally on Docker for a domain publicly accessible. However, there are some changes required to make it work.

```diff
diff --git a/docker-compose.override.yml b/docker-compose.override.yml
index e88276dbd..a1d28c6c0 100644
--- a/docker-compose.override.yml
+++ b/docker-compose.override.yml
@@ -52,6 +52,7 @@ services:
       - HOSTIP=${HOSTIP:-}
     extra_hosts:
       - "community.dev.readthedocs.io:10.10.0.100"
+      - "readthedocs.ngrok.io:10.5.0.100"
 
   celery:
     image: community_server:latest
diff --git a/dockerfiles/nginx/proxito.conf b/dockerfiles/nginx/proxito.conf
index 0cd250fab..c2935e42b 100644
--- a/dockerfiles/nginx/proxito.conf
+++ b/dockerfiles/nginx/proxito.conf
@@ -1,7 +1,7 @@
 # Proxito
 server {
     listen 80 default_server;
-    server_name *.community.dev.readthedocs.io *.org.dev.readthedocs.build;
+    server_name *.readthedocs.ngrok.io;
 
     # TODO: serve the favicon.ico from the project/version itself instead
     location /favicon.ico {
diff --git a/dockerfiles/nginx/web.conf b/dockerfiles/nginx/web.conf
index 3d6c6523c..57a2dcc91 100644
--- a/dockerfiles/nginx/web.conf
+++ b/dockerfiles/nginx/web.conf
@@ -2,7 +2,7 @@ server {
     listen 80;
 
     # This should match settings.PRODUCTION_DOMAIN
-    server_name community.dev.readthedocs.io;
+    server_name readthedocs.ngrok.io;
 
     location /favicon.ico {
         proxy_pass http://storage:9000/static/images/favicon.ico;
diff --git a/readthedocs/settings/docker_compose.py b/readthedocs/settings/docker_compose.py
index 15287c29e..cd5ba9bfd 100644
--- a/readthedocs/settings/docker_compose.py
+++ b/readthedocs/settings/docker_compose.py
@@ -15,8 +15,8 @@ class DockerBaseSettings(CommunityDevSettings):
     DOCKER_LIMITS = {'memory': '1g', 'time': 900}
     USE_SUBDOMAIN = True
 
-    PRODUCTION_DOMAIN = 'community.dev.readthedocs.io'
-    PUBLIC_DOMAIN = 'community.dev.readthedocs.io'
+    PRODUCTION_DOMAIN = 'readthedocs.ngrok.io'
+    PUBLIC_DOMAIN = 'readthedocs.ngrok.io'
     PUBLIC_API_URL = f'http://{PRODUCTION_DOMAIN}'
 
     SLUMBER_API_HOST = 'http://web:8000'
@@ -144,8 +144,8 @@ class DockerBaseSettings(CommunityDevSettings):
     S3_BUILD_COMMANDS_STORAGE_BUCKET = 'builds'
     S3_BUILD_ENVIRONMENT_STORAGE_BUCKET = 'envs'
     S3_STATIC_STORAGE_BUCKET = 'static'
-    S3_STATIC_STORAGE_OVERRIDE_HOSTNAME = 'community.dev.readthedocs.io'
-    S3_MEDIA_STORAGE_OVERRIDE_HOSTNAME = 'community.dev.readthedocs.io'
+    S3_STATIC_STORAGE_OVERRIDE_HOSTNAME = 'readthedocs.ngrok.io'
+    S3_MEDIA_STORAGE_OVERRIDE_HOSTNAME = 'readthedocs.ngrok.io'
 
     AWS_AUTO_CREATE_BUCKET = True
     AWS_DEFAULT_ACL = 'public-read'
```

We should explain this somewhere in our https://docs.readthedocs.io/en/stable/development/standards.html guide and/or create a command that automates this process.


Discussion:
Also, note, this doesn't serve assets from webpack correctly currently. I believe it should be usable without webpack however. It would be great to have a flag to enable this somewhere, or perhaps even just use an env var or similar to configure these settings.
Hi guys I will be working on this issue, ok?
Go ahead @GustavoGB !
Hi, I am looking at this issue, if Gustavo is not working on it, can I try it? 
@thinh241819 yes! Sure! Go ahead because there was no progress on this yet
> @thinh241819 yes! Sure! Go ahead because there was no progress on this yet

Hi, @humitos, I have a quick question. Is this documentation intended for developers or for the users?
The documentation is intended for developers
Something to keep in mind when setting up a new GitHub integration to test things locally: set the callback url as `http`, ngrok supports https, but our app makes use of the DEBUG and other options that change the protocol on some URLs to `http`, GitHub doesn't like that mismatch.

Resolving patch:
diff --git a/readthedocs/settings/docker_compose.py b/readthedocs/settings/docker_compose.py
--- a/readthedocs/settings/docker_compose.py
+++ b/readthedocs/settings/docker_compose.py
@@ -15,8 +15,8 @@ class DockerBaseSettings(CommunityDevSettings):
     DOCKER_LIMITS = {'memory': '1g', 'time': 900}
     USE_SUBDOMAIN = True
 
-    PRODUCTION_DOMAIN = 'community.dev.readthedocs.io'
-    PUBLIC_DOMAIN = 'community.dev.readthedocs.io'
+    PRODUCTION_DOMAIN = os.environ.get('RTD_PRODUCTION_DOMAIN', 'community.dev.readthedocs.io')
+    PUBLIC_DOMAIN = PRODUCTION_DOMAIN
     PUBLIC_API_URL = f'http://{PRODUCTION_DOMAIN}'
 
     SLUMBER_API_HOST = 'http://web:8000'
@@ -173,8 +173,8 @@ def show_debug_toolbar(request):
     S3_BUILD_ENVIRONMENT_STORAGE_BUCKET = 'envs'
     S3_BUILD_TOOLS_STORAGE_BUCKET = 'build-tools'
     S3_STATIC_STORAGE_BUCKET = 'static'
-    S3_STATIC_STORAGE_OVERRIDE_HOSTNAME = 'community.dev.readthedocs.io'
-    S3_MEDIA_STORAGE_OVERRIDE_HOSTNAME = 'community.dev.readthedocs.io'
+    S3_STATIC_STORAGE_OVERRIDE_HOSTNAME = PRODUCTION_DOMAIN
+    S3_MEDIA_STORAGE_OVERRIDE_HOSTNAME = PRODUCTION_DOMAIN
 
     AWS_S3_ENCRYPTION = False
     AWS_S3_SECURE_URLS = False


Test patch: