Skip to content

Commit 60f6203

Browse files
authored
chore: proxy content from the netlify service (#219)
## Summary This PR reworks the containers and their configuration to ensure we proxy the service from content coming from Netlify instead of the GCS bucket. - Adds a new workflow to allow users to manually invalidate the GCP CDN - nginx configuration will now source content from Netlify - nginx configuration will rewrite host and /developer path appropriately - Cleans up some legacy functionality --- This pull request refactors the deployment pipeline for the `/developers` site by switching from serving static files from GCS to proxying requests to the Netlify deployment via an NGINX container on Cloud Run. It also separates CDN cache invalidation into a dedicated workflow and simplifies the NGINX setup. The most important changes are: **Deployment workflow changes:** * [`.github/workflows/deploy_gcs.yml`](diffhunk://#diff-1b4b1ebc2bdf979ebb337fbe79c15e0a7032d263c9252e0c5c584b213052f21bL1-L25): The workflow is renamed to "Deploy nginx proxy to Cloud Run" and now only triggers when files in `ci/nginx-rewrite/**` are changed. The build and deploy steps for the static site to GCS are removed, as well as the CDN cache invalidation step. The workflow now builds and deploys only the NGINX container. [[1]](diffhunk://#diff-1b4b1ebc2bdf979ebb337fbe79c15e0a7032d263c9252e0c5c584b213052f21bL1-L25) [[2]](diffhunk://#diff-1b4b1ebc2bdf979ebb337fbe79c15e0a7032d263c9252e0c5c584b213052f21bL35-L43) [[3]](diffhunk://#diff-1b4b1ebc2bdf979ebb337fbe79c15e0a7032d263c9252e0c5c584b213052f21bL62-L67) **CDN cache invalidation:** * [`.github/workflows/invalidate-cdn.yml`](diffhunk://#diff-681d70fc4853c54f2e376212d8332d7fef902c66953f0c10caa1888da8bf2525R1-R25): A new workflow is added to handle CDN cache invalidation for `/developers/*` as a separate, manually-triggered job. **NGINX container and proxy configuration:** * [`ci/nginx-rewrite/Dockerfile`](diffhunk://#diff-0467814882cf41c18f620d6146df7793a7b00b70f7da33cbfbea3dded974b441L1-R4): The multi-stage build that fetched static content from GCS is removed. The container now installs `ca-certificates` for SSL proxying and no longer copies content to the image. * [`ci/nginx-rewrite/nginx.conf`](diffhunk://#diff-e84347fcb0b04b6e8fc158235bf34afb0ed65d5cec7e22cce739716a347b347aL26-R47): The server no longer serves static files from the container. Instead, all `/developers/` requests are proxied to the Netlify deployment, with appropriate headers and SSL verification. * [`ci/nginx-rewrite/Dockerfile`](diffhunk://#diff-0467814882cf41c18f620d6146df7793a7b00b70f7da33cbfbea3dded974b441L19-R13): File and directory permissions are updated to remove ownership changes for the now-unused static content directory.
1 parent 62354db commit 60f6203

5 files changed

Lines changed: 52 additions & 56 deletions

File tree

.github/workflows/deploy_gcs.yml

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,21 @@
1-
name: Deploy to GCS
1+
name: Deploy nginx proxy to Cloud Run
22

33
on:
4-
# Trigger the workflow every time you push to the `main` branch
5-
# Using a different branch name? Replace `main` with your branch's name
64
push:
75
branches: [main]
8-
# Allows you to run this workflow manually from the Actions tab on GitHub.
6+
paths:
7+
- 'ci/nginx-rewrite/**'
98
workflow_dispatch:
109

11-
# Allow this job to clone the repo and create a page deployment
1210
permissions:
1311
contents: read
14-
pages: write
15-
id-token: write
1612

1713
jobs:
1814
deploy:
1915
runs-on: ubuntu-latest
2016
steps:
2117
- name: Checkout your repository using git
2218
uses: actions/checkout@v4
23-
- uses: actions/setup-node@v4
24-
with:
25-
node-version: 22
2619

2720
- name: Authenticate to Google Cloud
2821
uses: google-github-actions/auth@v2
@@ -32,15 +25,6 @@ jobs:
3225
- name: Set up Cloud SDK
3326
uses: google-github-actions/setup-gcloud@v2
3427

35-
- uses: oven-sh/setup-bun@v1
36-
- name: Install dependencies
37-
run: bun install
38-
- name: Test build website
39-
run: bun run build
40-
41-
- name: Deploy to GCS
42-
run: gsutil -m rsync -r -d ./dist/ gs://${{ secrets.GCS_BUCKET }}/developers
43-
4428
- name: Build nginx container
4529
run: |
4630
cd ci/nginx-rewrite
@@ -59,9 +43,3 @@ jobs:
5943
--min-instances 0 \
6044
--max-instances 10 \
6145
--quiet
62-
63-
- name: Invalidate CDN cache
64-
run: |
65-
gcloud compute url-maps invalidate-cdn-cache interledger-org \
66-
--path "/developers/*" \
67-
--async
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Invalidate CDN
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
invalidate:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Authenticate to Google Cloud
14+
uses: google-github-actions/auth@v2
15+
with:
16+
credentials_json: ${{ secrets.GSA_JSON }}
17+
18+
- name: Set up Cloud SDK
19+
uses: google-github-actions/setup-gcloud@v2
20+
21+
- name: Invalidate CDN cache for /developers/*
22+
run: |
23+
gcloud compute url-maps invalidate-cdn-cache interledger-org \
24+
--path "/developers/*" \
25+
--async

README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,21 @@ This project has two deployment mechanisms:
8181

8282
Every pull request automatically generates a preview deployment on Netlify at `https://deploy-preview-{PR_NUMBER}--developers-preview.netlify.app/developers/`. This allows reviewers to see changes before they're merged. The Netlify configuration is defined in `netlify.toml`.
8383

84-
### Production Deployments (Google Cloud Storage)
84+
### Production Deployments (Netlify + GCP proxy)
8585

86-
The real production deployment is served through Google Cloud Storage (GCS) at `https://interledger.org/developers/` as part of the main Interledger website. This is a transparent proxy configuration - the developers portal is hosted separately but appears as part of the main domain.
86+
The production site is built and hosted on Netlify, but users access it at `https://interledger.org/developers/` via the main Interledger load balancer. A small nginx service on Cloud Run proxies `/developers/*` requests from the GCP load balancer to the Netlify-hosted site, so the browser URL stays on `interledger.org`.
8787

88-
When a PR is merged to the `main` branch, the `.github/workflows/deploy_gcs.yml` GitHub Actions workflow automatically:
88+
When a PR is merged to `main`, Netlify builds and publishes the new site automatically. GCP's Cloud CDN sits in front of the nginx proxy and caches responses for up to 1 hour.
8989

90-
1. Builds the site using Bun
91-
2. Deploys the built files to Google Cloud Storage (`gs://interledger-websites-public/developers`)
92-
3. Rebuilds and deploys the nginx-rewrite Cloud Run service (which handles the `/developers` proxy routing)
93-
4. Invalidates the CDN cache to ensure new content is served immediately
90+
#### Invalidating the CDN after a deploy
9491

95-
**Note:** There is a legacy `deploy.yaml` workflow in `.github/workflows/` which is being deprecated. New deployments should use `deploy_gcs.yml`.
92+
Because GCP Cloud CDN caches `/developers/*`, newly deployed content may take up to an hour to appear on `interledger.org/developers/`. If you need changes to go live immediately, manually trigger the **Invalidate CDN** workflow:
93+
94+
1. Go to the repo's **Actions** tab on GitHub.
95+
2. Select the **Invalidate CDN** workflow.
96+
3. Click **Run workflow** on the `main` branch.
97+
98+
This runs `gcloud compute url-maps invalidate-cdn-cache` against `/developers/*` and typically propagates within a minute.
9699

97100
For more information about the main Interledger.org infrastructure and deployment pipeline, see the [`interledger.org-v4`](https://github.com/interledger/interledger.org-v4) repository.
98101

ci/nginx-rewrite/Dockerfile

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
FROM google/cloud-sdk:alpine AS fetcher
2-
3-
# Fetch the developers content from GCS
4-
RUN mkdir -p /content/developers && \
5-
gsutil -m rsync -r gs://interledger-org-developers-portal/developers/ /content/developers/
6-
71
FROM nginx:alpine
82

9-
# Copy the fetched content
10-
COPY --from=fetcher /content /usr/share/nginx/html
3+
# Install ca-certificates for SSL verification when proxying to Netlify
4+
RUN apk add --no-cache ca-certificates
115

126
# Copy custom nginx configuration
137
COPY nginx.conf /etc/nginx/nginx.conf
@@ -16,8 +10,7 @@ COPY nginx.conf /etc/nginx/nginx.conf
1610
RUN touch /var/run/nginx.pid && \
1711
chown -R nginx:nginx /var/run/nginx.pid && \
1812
chown -R nginx:nginx /var/cache/nginx && \
19-
chown -R nginx:nginx /var/log/nginx && \
20-
chown -R nginx:nginx /usr/share/nginx/html
13+
chown -R nginx:nginx /var/log/nginx
2114

2215
USER nginx
2316

ci/nginx-rewrite/nginx.conf

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,31 +23,28 @@ http {
2323
types_hash_max_size 2048;
2424
gzip on;
2525

26-
# Use relative redirects
27-
absolute_redirect off;
28-
2926
server {
3027
listen 8080;
3128
server_name _;
3229

33-
# Root directory containing the developers folder
34-
root /usr/share/nginx/html;
35-
3630
# Health check endpoint for Cloud Run
3731
location /health {
3832
access_log off;
3933
return 200 "healthy\n";
4034
add_header Content-Type text/plain;
4135
}
4236

43-
# Serve files under /developers/
37+
# Proxy /developers/ requests to Netlify
4438
location /developers/ {
45-
# This will:
46-
# /developers/ -> /developers/index.html
47-
# /developers/foo -> /developers/foo/index.html
48-
# /developers/foo/ -> /developers/foo/index.html
49-
# /developers/foo/bar/ -> /developers/foo/bar/index.html
50-
try_files $uri $uri/ $uri/index.html =404;
39+
proxy_pass https://interledger-org-developers.netlify.app;
40+
proxy_set_header Host interledger-org-developers.netlify.app;
41+
proxy_set_header X-Real-IP $remote_addr;
42+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
43+
proxy_set_header X-Forwarded-Proto $scheme;
44+
proxy_ssl_server_name on;
45+
proxy_ssl_verify on;
46+
# Rewrite any absolute Location headers from Netlify back to relative paths
47+
proxy_redirect https://interledger-org-developers.netlify.app /;
5148
}
5249

5350
# If someone hits /developers (no slash), redirect to /developers/

0 commit comments

Comments
 (0)