Skip to content

Commit fc7b36a

Browse files
authored
docs: now describes the hosting from netlify (#222)
1 parent a5aacf8 commit fc7b36a

2 files changed

Lines changed: 44 additions & 41 deletions

File tree

β€Ž.github/copilot-instructions.mdβ€Ž

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@ This is the Interledger Developers Portal, a documentation site built with [Astr
2222
- **Important**: Build output is copied to `_netlify/builders/developers/` to serve at `/developers/` path
2323
- Redirect rules route `/developers/*` to `/developers/index.html` for client-side routing
2424

25-
### Production (Google Cloud)
26-
- Deployed to `https://interledger.org/developers/` via Google Cloud Storage
27-
- Triggered automatically on merge to `main` by `.github/workflows/deploy_gcs.yml`
28-
- Process: Build β†’ Deploy to GCS β†’ Rebuild nginx-rewrite Cloud Run service β†’ Invalidate CDN
29-
- **Legacy**: `deploy.yml` exists but is deprecated - use `deploy_gcs.yml`
25+
### Production (Netlify, fronted by GCP)
26+
- Built and hosted by Netlify at `https://interledger-org-developers.netlify.app/developers/`
27+
- Users reach it at `https://interledger.org/developers/` via the GCP load balancer, which proxies `/developers/*` through a Cloud Run nginx service (`nginx-rewrite`) to Netlify
28+
- The address bar stays on `interledger.org` β€” it is **not** a redirect
29+
- GCP Cloud CDN sits in front of the proxy (default TTL 1 hour)
30+
- **After a content deploy**, if you need changes live immediately, manually run the **Invalidate CDN** workflow in the Actions tab
31+
- The `Deploy nginx proxy to Cloud Run` workflow (`.github/workflows/deploy_gcs.yml`) only rebuilds the proxy container and triggers on changes under `ci/nginx-rewrite/**`
32+
- The nginx config itself lives in `ci/nginx-rewrite/` (Dockerfile + nginx.conf)
3033

3134
## Key Development Notes
3235

β€Žci/nginx-rewrite/README.mdβ€Ž

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,35 @@
11
# Nginx Rewrite Service
22

3-
Simple nginx-based static file server for the developers portal under the `/developers` path.
3+
Reverse-proxy running on Cloud Run that forwards `/developers/*` requests from the Interledger load balancer to the Netlify-hosted developers portal, while keeping the user's browser URL on `interledger.org` / `staging.interledger.org`.
44

55
## Background
66

7-
Previously, this content was served from an AWS S3 bucket through AWS CloudFront CDN. After migrating to GCS, we encountered a significant limitation: the GCS CDN lacks CloudFront's intelligent URL rewriting capabilities, and automatic `index.html` serving doesn't come out of the box. The simplest solution was to host the content through nginx and handle all rewrite rules at the server level.
7+
Historical progression:
8+
9+
1. **AWS S3 + CloudFront** β€” original setup.
10+
2. **GCS + Cloud CDN** β€” after migrating to GCP. The GCS CDN lacked CloudFront-style URL rewriting and automatic `index.html` serving, so we introduced an nginx layer on Cloud Run to handle rewrite rules and serve baked-in static files.
11+
3. **Netlify + Cloud Run nginx proxy (current)** β€” for project-management reasons the site is now built and hosted on Netlify. The same nginx service was repurposed as a thin reverse proxy so users still see `interledger.org/developers/...` in their address bar instead of a `netlify.app` URL.
812

913
## What it does
1014

11-
- Serves static files from the GCS bucket `gs://interledger-org-developers-portal/developers`
12-
- Content is baked into the container image at build time (multi-stage Docker build)
13-
- Handles index.html fallback for pretty URLs using `try_files`
14-
- Redirects paths without trailing slash to the slash version for clean URLs
15-
- Serves all content under `/developers/` path
15+
- Receives `/developers/*` traffic from the GCP HTTPS load balancer (`nginx-rewrite-backend`).
16+
- Proxies those requests to `https://interledger-org-developers.netlify.app`.
17+
- Rewrites any absolute `Location` headers Netlify sends so redirects stay relative.
18+
- Uses `absolute_redirect off` so nginx-issued redirects (e.g. `/developers` β†’ `/developers/`) don't leak the internal `:8080` scheme/port.
19+
- Exposes a `/health` endpoint for Cloud Run health checks.
1620

17-
## Building and deploying
21+
The container contains **no site content** β€” everything is proxied live from Netlify.
1822

19-
Deployment happens automatically via GitHub Actions when changes are merged to `main`:
23+
## Building and deploying
2024

21-
1. Site is built with Astro
22-
2. Files are synced to `gs://interledger-org-developers-portal/developers`
23-
3. Container is built (fetches content from GCS at build time)
24-
4. New revision is deployed to Cloud Run
25+
Deployment happens automatically via GitHub Actions when files under `ci/nginx-rewrite/**` change on `main`. It can also be triggered manually from the Actions tab (`Deploy nginx proxy to Cloud Run` workflow).
2526

26-
Manual deployment:
27+
Manual deployment from a workstation:
2728

2829
```bash
2930
cd ci/nginx-rewrite
3031

31-
# Build the container (fetches from GCS during build)
32+
# Build the container
3233
gcloud builds submit --tag gcr.io/interledger-websites/nginx-rewrite:latest .
3334

3435
# Deploy to Cloud Run
@@ -44,39 +45,38 @@ gcloud run deploy nginx-rewrite \
4445
--max-instances 10
4546
```
4647

48+
## CDN cache invalidation
49+
50+
The GCP load balancer in front of this service has Cloud CDN enabled on `nginx-rewrite-backend` (default TTL 1 hour). After a Netlify deploy, cached HTML may take up to an hour to refresh. To flush it immediately, run the `Invalidate CDN` workflow in the developers repo (or run `gcloud compute url-maps invalidate-cdn-cache interledger-org --path "/developers/*" --async`).
51+
4752
## How it works
4853

49-
### Multi-stage Docker build
54+
### Dockerfile
5055

51-
1. **Stage 1 (fetcher)**: Uses `google/cloud-sdk:alpine` to fetch content from GCS
52-
- Runs `gsutil rsync` to download `gs://interledger-org-developers-portal/developers/` to `/content/developers/`
53-
2. **Stage 2 (nginx)**: Uses `nginx:alpine` to serve the content
54-
- Copies content from stage 1
55-
- Copies custom `nginx.conf`
56-
- Runs as non-root user (Cloud Run requirement)
56+
Single-stage `nginx:alpine` image with a custom `nginx.conf`. Runs as the non-root `nginx` user (Cloud Run requirement).
5757

5858
### Nginx configuration
5959

60-
Simple configuration in `nginx.conf`:
61-
62-
- **Root**: `/usr/share/nginx/html` (contains the `developers/` folder)
63-
- **Location `/developers/`**: Uses `try_files $uri $uri/ $uri/index.html =404` for index fallback
64-
- **Location `= /developers`**: 301 redirect to `/developers/` for consistency
65-
- **absolute_redirect off**: Ensures redirects use relative paths (important for load balancer)
60+
- **`location /developers/`**: `proxy_pass` to Netlify with `Host` header override and `proxy_ssl_server_name on` for correct SNI.
61+
- **`location = /developers`**: 301 redirect to `/developers/`.
62+
- **`absolute_redirect off`**: makes redirects relative so the public hostname/scheme from the load balancer is preserved.
63+
- **`proxy_redirect`**: rewrites any absolute Netlify URLs in response `Location` headers back to relative paths.
64+
- **`/health`**: 200 OK for Cloud Run.
6665

6766
## Architecture
6867

6968
```
70-
GitHub Actions (on push to main)
69+
User browser
7170
↓
72-
1. Build Astro site
73-
2. Sync to GCS bucket
74-
3. Build container (fetches from GCS)
75-
4. Deploy to Cloud Run
71+
GCP Load Balancer (34.111.215.251)
72+
↓ /developers/* β†’ nginx-rewrite-backend (Cloud CDN enabled)
7673
↓
77-
Load Balancer (staging.interledger.org)
74+
Cloud Run (nginx-rewrite)
75+
↓ proxy_pass
7876
↓
79-
/developers β†’ nginx-rewrite Cloud Run service
77+
Netlify (interledger-org-developers.netlify.app)
8078
↓
81-
Serves baked-in static files
79+
Static site built by Netlify from interledger.org-developers repo
8280
```
81+
82+
The user's address bar stays on `interledger.org` or `staging.interledger.org` throughout.

0 commit comments

Comments
Β (0)