mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-10-03 18:23:47 +10:00
Vercel now deploys Reactive Resume as two services in one project: `frontend` serves the static Vite build from apps/web/dist, and `backend` runs the Hono server Function from apps/server. Top-level rewrites send server-owned paths (/api, /uploads, /mcp, /.well-known, robots.txt, sitemap.xml, llms.txt, schema.json, index.html) and every path without a file extension to `backend`, so HTML shells keep their injected SEO metadata. Paths with a file extension go to `frontend`. The service builder needs a few accommodations: - apps/server/vercel.mjs replaces api/index.mjs as the entrypoint, because a service entrypoint must exist before the build runs. - `outputDirectory: "."` stops the builder from using the Docker entrypoint in dist/ as the Function handler. - The builder loads external CommonJS dependencies through pnpm links that it leaves out of the Function. ioredis and react-reconciler are now bundled with their dependencies, and bcrypt is replaced with bcryptjs, which reads and writes the same $2b$ hashes. The Vercel compatibility workflow now builds with the services framework and loads a copy of the backend Function outside the checkout, so a dependency missing from the Function fails CI. The stale PDFKit trace checks are removed. Existing Vercel installations must set Framework Preset to Services before redeploying; the self-hosting guide documents this.
116 lines
4.7 KiB
YAML
116 lines
4.7 KiB
YAML
name: Vercel compatibility
|
|
|
|
on:
|
|
pull_request:
|
|
push:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
env:
|
|
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
|
|
|
jobs:
|
|
artifact:
|
|
runs-on: ${{ vars.USE_BLACKSMITH == 'true' && 'blacksmith-32vcpu-ubuntu-2404' || 'ubuntu-latest' }}
|
|
timeout-minutes: 20
|
|
services:
|
|
postgres:
|
|
image: postgres:17-alpine
|
|
env:
|
|
POSTGRES_PASSWORD: postgres
|
|
ports: [5432:5432]
|
|
options: >-
|
|
--health-cmd "pg_isready -U postgres"
|
|
--health-interval 5s --health-timeout 5s --health-retries 10
|
|
env:
|
|
APP_URL: http://localhost:3000
|
|
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/postgres
|
|
AUTH_SECRET: isolated-ci-auth-secret-32-characters
|
|
ENCRYPTION_SECRET: isolated-ci-encryption-secret-32-characters
|
|
REDIS_URL: redis://localhost:6379
|
|
STORAGE_BACKEND: blob
|
|
BLOB_READ_WRITE_TOKEN: vercel_blob_rw_ci_fake_build_only
|
|
VERCEL: "1"
|
|
VERCEL_ENV: production
|
|
steps:
|
|
- if: ${{ vars.USE_BLACKSMITH != 'true' }}
|
|
uses: actions/checkout@v6
|
|
with:
|
|
persist-credentials: false
|
|
- if: ${{ vars.USE_BLACKSMITH == 'true' }}
|
|
uses: useblacksmith/checkout@v1
|
|
with:
|
|
persist-credentials: false
|
|
- uses: pnpm/action-setup@v6
|
|
- uses: actions/setup-node@v6
|
|
with:
|
|
node-version-file: .nvmrc
|
|
cache: pnpm
|
|
- run: pnpm install --frozen-lockfile
|
|
# Local project settings avoid authentication and API calls. Forks receive no cloud credentials.
|
|
- name: Build Vercel artifact against isolated PostgreSQL
|
|
run: |
|
|
mkdir -p .vercel
|
|
node --input-type=module - <<'JS'
|
|
import { writeFileSync } from 'node:fs';
|
|
writeFileSync('.vercel/project.json', JSON.stringify({
|
|
projectId: 'prj_ci', orgId: 'team_ci', projectName: 'reactive-resume-ci',
|
|
settings: { framework: 'services', nodeVersion: '24.x', createdAt: 0 }
|
|
}));
|
|
JS
|
|
pnpm dlx --allow-build=esbuild vercel@61.0.0 build --prod --yes --global-config "$RUNNER_TEMP/vercel-offline"
|
|
# Runs the backend Function from a copy outside the checkout, so a dependency the build left out fails here.
|
|
- name: Check backend Function loading and budget
|
|
run: |
|
|
node --no-experimental-require-module --input-type=module - <<'JS'
|
|
import assert from 'node:assert/strict';
|
|
import { cpSync, lstatSync, mkdirSync, readFileSync, readlinkSync, symlinkSync } from 'node:fs';
|
|
import { dirname, join } from 'node:path';
|
|
const func = '.vercel/output/services/backend/functions/index.func';
|
|
const config = JSON.parse(readFileSync(`${func}/.vc-config.json`));
|
|
assert.equal(config.runtime, 'nodejs24.x');
|
|
assert.equal(config.maxDuration, 300);
|
|
assert.equal(config.handler, 'apps/server/vercel.mjs');
|
|
const root = join(process.env.RUNNER_TEMP, 'backend-function');
|
|
cpSync(func, root, { recursive: true, verbatimSymlinks: true });
|
|
for (const [path, source] of Object.entries(config.filePathMap ?? {})) {
|
|
mkdirSync(dirname(join(root, path)), { recursive: true });
|
|
if (lstatSync(source).isSymbolicLink()) symlinkSync(readlinkSync(source), join(root, path));
|
|
else cpSync(source, join(root, path));
|
|
}
|
|
const { default: app } = await import(join(root, config.handler));
|
|
const stage = await app.fetch(new Request('http://localhost:3000/api/storage/stage', { method: 'POST', body: '{}' }));
|
|
assert.equal(stage.status, 401);
|
|
const home = await app.fetch(new Request('http://localhost:3000/'));
|
|
assert.equal(home.status, 200);
|
|
assert.match(await home.text(), /application\/ld\+json/);
|
|
process.exit(0);
|
|
JS
|
|
|
|
live-smoke:
|
|
if: github.event_name == 'workflow_dispatch'
|
|
runs-on: ${{ vars.USE_BLACKSMITH == 'true' && 'blacksmith-2vcpu-ubuntu-2404' || 'ubuntu-latest' }}
|
|
environment: vercel-smoke
|
|
timeout-minutes: 10
|
|
steps:
|
|
- if: ${{ vars.USE_BLACKSMITH != 'true' }}
|
|
uses: actions/checkout@v6
|
|
with:
|
|
persist-credentials: false
|
|
- if: ${{ vars.USE_BLACKSMITH == 'true' }}
|
|
uses: useblacksmith/checkout@v1
|
|
with:
|
|
persist-credentials: false
|
|
- uses: actions/setup-node@v6
|
|
with:
|
|
node-version-file: .nvmrc
|
|
- name: Smoke-test dedicated deployment
|
|
env:
|
|
SMOKE_URL: ${{ vars.VERCEL_SMOKE_URL }}
|
|
SMOKE_AI_BASE_URL: ${{ vars.VERCEL_SMOKE_AI_BASE_URL }}
|
|
SMOKE_AI_API_KEY: ${{ secrets.VERCEL_SMOKE_AI_API_KEY }}
|
|
run: node tooling/deployment/smoke.mjs
|