feat: implement ssr#66
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces Inertia SSR support and adds infrastructure needed to run an SSR rendering service alongside the Laravel app.
Changes:
- Add an Inertia SSR entry (
resources/js/ssr.tsx) and wire it into deployment via a dedicated SSR Docker image/service. - Add an SEO canonical link tag to the main Blade app shell.
- Update deployment/compose configs and lockfiles to support the SSR runtime and dependency updates.
Reviewed changes
Copilot reviewed 10 out of 12 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| resources/views/app.blade.php | Adds canonical link tag for SEO. |
| resources/js/ssr.tsx | Implements Inertia SSR server entry and wraps the app in TooltipProvider. |
| public/build/manifest.json | Updates Vite build manifest (large generated diff). |
| package-lock.json | Dependency updates (incl. Inertia beta bump and transitive updates). |
| docker-compose.yml | Adds base ssr service definition. |
| docker-compose.dev.yml | Adds ssr service for development. |
| docker-compose.prod.yml | Adds ssr service for production swarm deployment. |
| Dockerfile.ssr | Adds a dedicated multi-stage SSR Docker image build. |
| Dockerfile.ssr.dockerignore | Adds ignore rules intended for SSR builds. |
| Dockerfile.node | Fixes indentation for the ci stage line. |
| .github/workflows/action_deploy-production.yml | Adds SSR image build job and passes SSR image tag into deploy. |
| .env.example | Adds SSR env vars (URL + bundle existence check flag). |
Comments suppressed due to low confidence (1)
docker-compose.dev.yml:78
- In
docker-compose.dev.yml, the Traefik labels for the Vite dev server (traefik.http.routers.vite.*/ port 5173) are attached to the newssrservice. Sincessrrunsnode bootstrap/ssr/ssr.jsand does not expose 5173, this will break routing to the Vite dev server. Move these labels back to thenodeservice (or remove them fromssr).
labels:
- "traefik.enable=true"
- "traefik.http.routers.vite.rule=HostRegexp(`vite.dev.test`)"
- "traefik.http.routers.vite.entrypoints=websecure"
- "traefik.http.routers.vite.tls=true"
- "traefik.http.services.vite.loadbalancer.server.port=5173"
- "traefik.http.services.vite.loadbalancer.server.scheme=https"
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| { | ||
| "_app-layout-DV6zawK2.js": { | ||
| "file": "assets/app-layout-DV6zawK2.js", | ||
| "_app-layout-Dm23TAYF.js": { | ||
| "file": "assets/app-layout-Dm23TAYF.js", | ||
| "name": "app-layout", | ||
| "imports": [ |
There was a problem hiding this comment.
This PR updates public/build/manifest.json, but /public/build is listed in .gitignore. Committing build artifacts tends to create noisy diffs/merge conflicts and can drift from what CI produces. If the runtime image needs these assets, it’s usually better to generate them during CI/Docker build and keep public/build untracked (or remove the ignore rule if the repo intentionally tracks built assets).
| createServer((page) => | ||
| createInertiaApp({ | ||
| page, | ||
| render: ReactDOMServer.renderToString, | ||
| title: (title) => (title ? `${title} - ${appName}` : appName), | ||
| pages: './pages', | ||
| setup: ({ App, props }) => { | ||
|
|
||
| /* eslint-disable */ | ||
| // @ts-expect-error | ||
| global.route<RouteName> = (name, params, absolute) => | ||
| route(name, params as any, absolute, { | ||
| // @ts-expect-error | ||
| ...page.props.ziggy, | ||
| // @ts-expect-error | ||
| location: new URL(page.props.ziggy.location), | ||
| }); | ||
| /* eslint-enable */ | ||
| const page = props.initialPage; | ||
|
|
There was a problem hiding this comment.
createServer((page) => ...) introduces a page parameter, and inside setup another const page = props.initialPage is declared. This shadowing makes it easy to accidentally reference the wrong page and is especially risky in SSR code. Rename one of them (e.g., initialPage) to avoid ambiguity.
| ssr: | ||
| command: node bootstrap/ssr/ssr.js | ||
| healthcheck: | ||
| test: ["CMD", "wget", "-q", "--spider", "http://localhost:13714/health"] | ||
| interval: 30s | ||
| timeout: 10s | ||
| retries: 3 | ||
| start_period: 10s |
There was a problem hiding this comment.
ssr is defined without either an image or build section. This works only if another compose file always augments it, but the CI compose merge (docker-compose.yml + docker-compose.ci.yml) currently does not define ssr, so docker compose config validation is likely to fail. Add a minimal build/image for ssr in docker-compose.ci.yml, or move the ssr service definition out of the base compose and into the env-specific compose files only.
| volumes: | ||
| - .:/app/ |
There was a problem hiding this comment.
The ssr service bind-mounts the entire repo to /app, but the image build produces bootstrap/ssr/ssr.js inside the image. The bind mount will hide that built bundle, so node bootstrap/ssr/ssr.js will fail unless the host has already generated the bundle. Consider removing the bind mount, or changing the command/entrypoint to build the SSR bundle at container start (or mounting only what’s needed).
| volumes: | |
| - .:/app/ |
| node_modules | ||
| vendor | ||
| public/build | ||
| bootstrap/ssr | ||
| bootstrap/cache | ||
| storage | ||
| .git | ||
| .github | ||
| .infrastructure | ||
| *.md |
There was a problem hiding this comment.
Dockerfile.ssr.dockerignore won’t be picked up automatically by Docker/Compose (they only read .dockerignore in the build context unless the build tooling explicitly sets an alternate ignore file). I couldn’t find any build command/workflow referencing --ignorefile, so this file likely has no effect. Either configure the build to use it, or document/rename the approach so the intended ignore rules are actually applied.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@copilot open a new pull request to apply changes based on the comments in this thread |
|
@LambdaDigamma I've opened a new pull request, #67, to work on those changes. Once the pull request is ready, I'll request review from you. |
- Untrack public/build/manifest.json (build artifact in .gitignore) - Rename inner `page` to `initialPage` in ssr.tsx to avoid shadowing - Add ssr service build definition to docker-compose.ci.yml - Remove bind-mount from ssr service in docker-compose.dev.yml - Document BuildKit requirement in Dockerfile.ssr.dockerignore Co-authored-by: LambdaDigamma <19361610+LambdaDigamma@users.noreply.github.com> Agent-Logs-Url: https://github.com/LambdaDigamma/moers-web/sessions/eff12651-d417-4d01-9701-98856e15a333
fix: address SSR implementation review comments
No description provided.