Skip to content

Commit 9f18fd4

Browse files
chrisbbreuerclaude
andcommitted
feat: deploy registry to AWS Lambda and migrate to registry.pantry.dev
- Add Lambda handler adapting API Gateway v2 events to registry handler - Extract shared fetch handler from Bun server for Lambda reuse - Deploy Lambda function + API Gateway HTTP API (pantry-registry) - Add deploy-registry.yml workflow for CI deployments - Replace all registry.stacksjs.com/org/pantry.sh URLs with registry.pantry.dev - Add build:lambda and deploy scripts to registry package.json Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent fba518d commit 9f18fd4

24 files changed

+431
-235
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Deploy Registry
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'packages/registry/src/**'
8+
workflow_dispatch:
9+
10+
jobs:
11+
deploy:
12+
name: Deploy to Lambda
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
17+
steps:
18+
- uses: actions/checkout@v6
19+
20+
- name: Setup Bun
21+
uses: oven-sh/setup-bun@v2
22+
with:
23+
bun-version: latest
24+
25+
- name: Build Lambda bundle
26+
run: |
27+
cd packages/registry
28+
bun build src/lambda.ts --outfile dist/lambda.mjs --target node --minify
29+
cd dist && zip -j lambda.zip lambda.mjs
30+
echo "Bundle size: $(wc -c < lambda.zip) bytes"
31+
32+
- name: Deploy to AWS Lambda
33+
env:
34+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
35+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
36+
AWS_REGION: us-east-1
37+
run: |
38+
aws lambda update-function-code \
39+
--function-name pantry-registry \
40+
--zip-file fileb://packages/registry/dist/lambda.zip \
41+
--region us-east-1 \
42+
--query 'LastModified' --output text
43+
44+
- name: Verify deployment
45+
run: |
46+
sleep 5
47+
HTTP_CODE=$(curl -sS -o /dev/null -w '%{http_code}' \
48+
'https://registry.pantry.dev/health' \
49+
--max-time 15 2>/dev/null) || true
50+
echo "Health check: HTTP $HTTP_CODE"
51+
if [ "$HTTP_CODE" != "200" ]; then
52+
echo "::warning::Health check returned $HTTP_CODE (custom domain may not be configured yet)"
53+
fi
54+
55+
notify:
56+
name: Discord notification
57+
needs: deploy
58+
if: always()
59+
runs-on: ubuntu-latest
60+
steps:
61+
- uses: actions/checkout@v6
62+
- uses: ./.github/actions/discord-notify
63+
with:
64+
title: "Registry Deploy — ${{ needs.deploy.result == 'success' && 'Deployed' || needs.deploy.result == 'cancelled' && 'Cancelled' || 'Failed' }}"
65+
description: "Registry Lambda function updated"
66+
status: ${{ needs.deploy.result == 'success' && 'success' || needs.deploy.result == 'cancelled' && 'warning' || 'failure' }}
67+
fields: |
68+
[
69+
{"name": "Branch", "value": "${{ github.ref_name }}", "inline": true},
70+
{"name": "Actor", "value": "${{ github.actor }}", "inline": true}
71+
]
72+
webhook_url: ${{ secrets.DISCORD_WEBHOOK_URL }}

.github/workflows/health-monitor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
# Use a temp file to isolate the HTTP code from error output
2323
HTTP_CODE=$(curl -sS -o /tmp/health-response -w '%{http_code}' \
2424
--max-time 15 \
25-
'https://registry.stacksjs.com/health' 2>/dev/null) || true
25+
'https://registry.pantry.dev/health' 2>/dev/null) || true
2626
# Extract only the last 3 chars (the HTTP code) in case of any prefix noise
2727
HTTP_CODE="${HTTP_CODE: -3}"
2828
echo "http_code=$HTTP_CODE" >> "$GITHUB_OUTPUT"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ Each published package gets an install URL tied to the commit SHA:
386386

387387
```bash
388388
# Install a specific commit's package
389-
npm install https://registry.stacksjs.org/commits/abc1234/@scope/my-package/tarball
389+
npm install https://registry.pantry.dev/commits/abc1234/@scope/my-package/tarball
390390
```
391391

392392
**GitHub Actions integration** — replace `pkg-pr-new` in your CI:

docs/OIDC_AUTHENTICATION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ pantry publish --no-oidc
173173
pantry publish --dry-run
174174

175175
# Specify custom registry
176-
pantry publish --registry https://registry.pantry.sh
176+
pantry publish --registry https://registry.pantry.dev
177177

178178
# Disable provenance generation
179179
pantry publish --no-provenance

docs/OIDC_IMPLEMENTATION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ pantry publish --dry-run
228228
pantry publish --no-oidc
229229

230230
# Custom registry
231-
pantry publish --registry https://registry.pantry.sh
231+
pantry publish --registry https://registry.pantry.dev
232232

233233
# Disable provenance
234234
pantry publish --no-provenance

docs/OIDC_IMPLEMENTATION_SUMMARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ pantry publish --dry-run
181181
pantry publish --no-oidc
182182

183183
# Custom registry
184-
pantry publish --registry https://registry.pantry.sh
184+
pantry publish --registry https://registry.pantry.dev
185185

186186
# Disable provenance
187187
pantry publish --no-provenance

docs/features/commit-publishing.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pantry publish:commit ./my-package
2424
Each published package gets an install URL:
2525

2626
```
27-
https://registry.stacksjs.org/commits/abc1234/@scope/my-package/tarball
27+
https://registry.pantry.dev/commits/abc1234/@scope/my-package/tarball
2828
```
2929

3030
## Usage
@@ -66,7 +66,7 @@ Private packages (those with `"private": true` in `package.json`) are automatica
6666

6767
| Option | Description | Default |
6868
|--------|-------------|---------|
69-
| `--registry <url>` | Registry URL to publish to | `https://registry.stacksjs.org` |
69+
| `--registry <url>` | Registry URL to publish to | `https://registry.pantry.dev` |
7070
| `--token <token>` | Authentication token | `PANTRY_TOKEN` env var |
7171
| `--dry-run` | Preview what would be published without uploading | `false` |
7272
| `--compact` | Minimal output suitable for CI environments | `false` |
@@ -135,10 +135,10 @@ Published commit packages can be installed using standard package managers:
135135
136136
```bash
137137
# Install via npm/bun/yarn/pnpm
138-
npm install https://registry.stacksjs.org/commits/abc1234/@scope/package/tarball
138+
npm install https://registry.pantry.dev/commits/abc1234/@scope/package/tarball
139139

140140
# Or for unscoped packages
141-
npm install https://registry.stacksjs.org/commits/abc1234/my-package/tarball
141+
npm install https://registry.pantry.dev/commits/abc1234/my-package/tarball
142142
```
143143

144144
## Registry API
@@ -156,10 +156,10 @@ The Pantry registry provides these endpoints for commit packages:
156156

157157
```bash
158158
# List all packages for a commit
159-
curl https://registry.stacksjs.org/commits/abc1234
159+
curl https://registry.pantry.dev/commits/abc1234
160160

161161
# Get metadata for a specific package
162-
curl https://registry.stacksjs.org/commits/abc1234/@scope/my-package
162+
curl https://registry.pantry.dev/commits/abc1234/@scope/my-package
163163
```
164164

165165
## Architecture

docs/features/package-management.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ Published packages get install URLs tied to the commit SHA:
342342

343343
```bash
344344
# Install from a specific commit
345-
npm install https://registry.stacksjs.org/commits/abc1234/@scope/package/tarball
345+
npm install https://registry.pantry.dev/commits/abc1234/@scope/package/tarball
346346
```
347347

348348
### Options

docs/usage.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ Each published package gets an install URL tied to the commit SHA:
868868

869869
```bash
870870
# Install a commit package
871-
npm install https://registry.stacksjs.org/commits/abc1234/@scope/my-package/tarball
871+
npm install https://registry.pantry.dev/commits/abc1234/@scope/my-package/tarball
872872
```
873873

874874
### CI/CD Usage
@@ -887,7 +887,7 @@ Replace `pkg-pr-new` in your GitHub Actions:
887887
888888
| Option | Description |
889889
|--------|-------------|
890-
| `--registry <url>` | Custom registry URL (default: `https://registry.stacksjs.org`) |
890+
| `--registry <url>` | Custom registry URL (default: `https://registry.pantry.dev`) |
891891
| `--token <token>` | Authentication token (or set `PANTRY_TOKEN` env var) |
892892
| `--dry-run` | Preview without publishing |
893893
| `--compact` | Minimal output for CI environments |

packages/registry/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
"test": "bun test",
2424
"test:analytics": "bun test src/analytics.test.ts",
2525
"test:commit-publish": "bun test src/commit-publish.test.ts",
26-
"typecheck": "bun --bun tsc --noEmit"
26+
"typecheck": "bun --bun tsc --noEmit",
27+
"build:lambda": "bun build src/lambda.ts --outfile dist/lambda.mjs --target node --minify && cd dist && zip -j lambda.zip lambda.mjs",
28+
"deploy": "bun run build:lambda && aws lambda update-function-code --function-name pantry-registry --zip-file fileb://dist/lambda.zip --region us-east-1"
2729
},
2830
"dependencies": {},
2931
"devDependencies": {

0 commit comments

Comments
 (0)