Skip to content

Commit aeb1a92

Browse files
committed
chore(docs): move to GCP
1 parent ea58a76 commit aeb1a92

6 files changed

Lines changed: 170 additions & 7 deletions

File tree

.dockerignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.git
2+
.github
3+
.husky
4+
.claude
5+
.vercel
6+
.vscode
7+
.idea
8+
.DS_Store
9+
10+
# build outputs and caches (rebuilt inside container)
11+
**/node_modules
12+
**/.turbo
13+
**/build
14+
**/dist
15+
**/.cache
16+
**/.react-router
17+
**/__screenshots__
18+
**/coverage
19+
**/*.log
20+
21+
# editor / OS noise
22+
*.tgz
23+
Thumbs.db

.github/workflows/docs-deploy.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Docs deploy
2+
3+
on:
4+
push:
5+
branches: [next]
6+
paths:
7+
- 'docs/**'
8+
- 'Dockerfile'
9+
- '.dockerignore'
10+
- '.github/workflows/docs-deploy.yml'
11+
pull_request:
12+
types: [opened, synchronize, reopened, closed]
13+
workflow_dispatch:
14+
15+
permissions:
16+
contents: read
17+
pull-requests: write
18+
id-token: write
19+
20+
env:
21+
GCP_PROJECT_NUMBER: 204644970562
22+
CLOUD_RUN_SERVICE: react-spring
23+
CLOUD_RUN_REGION: europe-west1
24+
25+
jobs:
26+
pr-changes:
27+
if: github.event_name == 'pull_request' && github.event.action != 'closed'
28+
runs-on: ubuntu-latest
29+
outputs:
30+
docs: ${{ steps.filter.outputs.docs }}
31+
steps:
32+
- uses: actions/checkout@v4
33+
- uses: dorny/paths-filter@v3
34+
id: filter
35+
with:
36+
filters: |
37+
docs:
38+
- 'docs/**'
39+
- 'Dockerfile'
40+
- '.dockerignore'
41+
- '.github/workflows/docs-deploy.yml'
42+
43+
deploy-prod:
44+
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
45+
runs-on: ubuntu-latest
46+
steps:
47+
- uses: actions/checkout@v4
48+
- uses: google-github-actions/auth@v2
49+
with:
50+
workload_identity_provider: ${{ secrets.WIF_PROVIDER }}
51+
service_account: ${{ secrets.GCP_SA_EMAIL }}
52+
- uses: google-github-actions/setup-gcloud@v2
53+
- name: Deploy to Cloud Run (prod)
54+
run: |
55+
gcloud run deploy "$CLOUD_RUN_SERVICE" \
56+
--source . \
57+
--region "$CLOUD_RUN_REGION" \
58+
--quiet
59+
60+
deploy-preview:
61+
needs: pr-changes
62+
if: |
63+
github.event_name == 'pull_request' &&
64+
github.event.action != 'closed' &&
65+
needs.pr-changes.outputs.docs == 'true'
66+
runs-on: ubuntu-latest
67+
steps:
68+
- uses: actions/checkout@v4
69+
- uses: google-github-actions/auth@v2
70+
with:
71+
workload_identity_provider: ${{ secrets.WIF_PROVIDER }}
72+
service_account: ${{ secrets.GCP_SA_EMAIL }}
73+
- uses: google-github-actions/setup-gcloud@v2
74+
- name: Deploy preview revision
75+
id: deploy
76+
run: |
77+
TAG="pr-${{ github.event.number }}"
78+
gcloud run deploy "$CLOUD_RUN_SERVICE" \
79+
--source . \
80+
--region "$CLOUD_RUN_REGION" \
81+
--tag "$TAG" \
82+
--no-traffic \
83+
--quiet
84+
URL="https://${TAG}---${CLOUD_RUN_SERVICE}-${GCP_PROJECT_NUMBER}.${CLOUD_RUN_REGION}.run.app"
85+
echo "url=$URL" >> "$GITHUB_OUTPUT"
86+
- uses: marocchino/sticky-pull-request-comment@v2
87+
with:
88+
header: docs-preview
89+
message: |
90+
**Docs preview:** ${{ steps.deploy.outputs.url }}
91+
92+
Deployed at `${{ github.sha }}`. Updates on every push.
93+
94+
cleanup-preview:
95+
if: github.event_name == 'pull_request' && github.event.action == 'closed'
96+
runs-on: ubuntu-latest
97+
steps:
98+
- uses: google-github-actions/auth@v2
99+
with:
100+
workload_identity_provider: ${{ secrets.WIF_PROVIDER }}
101+
service_account: ${{ secrets.GCP_SA_EMAIL }}
102+
- uses: google-github-actions/setup-gcloud@v2
103+
# tolerate failure: the PR may not have triggered a preview deploy
104+
- name: Remove preview tag
105+
run: |
106+
gcloud run services update-traffic "$CLOUD_RUN_SERVICE" \
107+
--region "$CLOUD_RUN_REGION" \
108+
--remove-tags "pr-${{ github.event.number }}" \
109+
--quiet || echo "No preview tag to remove"

Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# syntax=docker/dockerfile:1.7
2+
3+
# ----- Build stage: install + build inside the full monorepo -----
4+
FROM node:24-alpine AS builder
5+
6+
RUN corepack enable
7+
WORKDIR /repo
8+
9+
COPY . .
10+
11+
RUN pnpm install --frozen-lockfile
12+
13+
# Build the docs and any workspace packages it depends on
14+
RUN pnpm --filter @react-spring/docs... build
15+
16+
# Produce a self-contained dir with prod-only deps (symlinks dereferenced)
17+
RUN pnpm --filter @react-spring/docs deploy --prod /out
18+
19+
# pnpm deploy doesn't carry over the build output; copy it in explicitly
20+
RUN cp -r /repo/docs/build /out/build
21+
22+
# ----- Runtime stage: slim image with only what's needed to serve -----
23+
FROM node:24-alpine
24+
25+
WORKDIR /app
26+
ENV NODE_ENV=production
27+
ENV PORT=8080
28+
29+
COPY --from=builder /out ./
30+
31+
EXPOSE 8080
32+
CMD ["node_modules/.bin/react-router-serve", "./build/server/index.js"]

docs/app/root.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
WidgetGoogleTagManagerBody,
1717
} from './components/Widgets/WidgetGoogleTagManager'
1818
import { lightThemeClass } from './styles/light-theme.css'
19-
import global from './styles/global.css?url'
19+
import './styles/global.css'
2020
import docusearch from '@docsearch/css/dist/style.css?url'
2121
import { getTheme, setTheme } from './helpers/theme.server'
2222
import { darkThemeClass } from './styles/dark-theme.css'
@@ -62,7 +62,6 @@ export const meta: MetaFunction = () => {
6262

6363
export const links: LinksFunction = () => [
6464
{ rel: 'stylesheet', href: docusearch },
65-
{ rel: 'stylesheet', href: global },
6665
{ rel: 'stylesheet', href: 'https://rsms.me/inter/inter.css' },
6766
{ rel: 'preconnect', href: 'https://fonts.googleapis.com' },
6867
{ rel: 'preconnect', href: 'https://fonts.gstatic.com' },

docs/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
"version": "2.0.0",
66
"private": true,
77
"type": "module",
8-
"sideEffects": false,
8+
"sideEffects": [
9+
"**/*.css",
10+
"**/*.css.ts"
11+
],
912
"scripts": {
1013
"build": "react-router build",
1114
"dev": "concurrently \"pnpm dev:rr\" \"pnpm scripts:watch\"",

docs/react-router.config.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import { vercelPreset } from '@vercel/react-router/vite'
21
import type { Config } from '@react-router/dev/config'
32

4-
export default {
5-
presets: [vercelPreset()],
6-
} satisfies Config
3+
export default {} satisfies Config

0 commit comments

Comments
 (0)