mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 12:41:04 +00:00
8.7 KiB
8.7 KiB
Checkpoint
Major Tasks Completed
- Docker deployment scaffolded for all 6 apps in the monorepo.
- Split API images into app-specific Dockerfiles:
apps/edr-freight-api/Dockerfileapps/edr-passenger-api/Dockerfile
- Kept shared Vite/nginx image:
infrastructure/docker/Dockerfile.webinfrastructure/nginx/spa.conf
- Updated
docker-compose.yamlto run all 6 services (apps only, no Postgres service in compose). - Added/updated deployment scripts:
scripts/deploy/create-npmrc.shscripts/deploy/sync-env-from-server.sh
- Added self-hosted GitHub Actions deployment workflow:
- Consolidated into one file:
.github/workflows/deploy.yml
- Consolidated into one file:
- Deployment workflow now:
- uses a single checkout (
preparejob), - deploys services via parallel matrix,
- sets compose project names per branch/environment,
- passes explicit
docker compose --project-name.
- uses a single checkout (
- Environment sync script now:
- supports branch slug paths,
- validates each service env file exists,
- requires
PORTin each env file, - exports per-service port vars to
GITHUB_ENV.
docker-compose.yamlnow reads per-service ports via variables exported from env sync.- Passenger startup flow fixed to run:
prisma:generate,prisma:migrate,prisma:seed, before API startup.
- Passenger seed TypeScript issues fixed in
apps/edr-passenger-api/prisma/seed.tsso it compiles under strict checks. - Added deployment runbook:
DEPLOYMENT.md
Passenger Web Migration to Next.js
- Passenger web apps migrated from Vite/SPA to Next.js:
- Updated
apps/edr-passenger-web/portal/next.config.jsandapps/edr-passenger-web/backoffice/next.config.js:- Removed
output: 'export'to enable server mode - Preserved
transpilePackagesfor @edr/* shared packages
- Removed
- Updated
- Created dedicated Next.js Dockerfile:
infrastructure/docker/Dockerfile.passenger-web- Uses Node.js server (not nginx) for better Next.js support
- Builds with turbo, runs
npx next startin the final stage - Accepts build args:
APP_PACKAGE,APP_PATH,NEXT_PUBLIC_API_URL
- Updated docker-compose.yaml:
passenger-portalandpassenger-backofficenow useinfrastructure/docker/Dockerfile.passenger-web- Port mappings are fully dynamic: both host and container ports use
${PASSENGER_PORTAL_PORT}/${PASSENGER_BACKOFFICE_PORT}, driven byPORTin the service env file NEXT_PUBLIC_API_URLbuild arg sourced directly from the service env file (no separate build env file needed)
- Updated DEPLOYMENT.md to reflect all of the above.
Port Mapping Fix (Latest)
- Fixed passenger web port mapping mismatch (
0.0.0.0:8003->5184/tcp):- Container port was hardcoded (
5174/5184); host port came fromPORTin the env file via the sync script - Both sides of the mapping now use
${PASSENGER_PORTAL_PORT:-5174}/${PASSENGER_BACKOFFICE_PORT:-5184} - Removed hardcoded
PORTbuild arg from docker-compose.yaml (runtimeenv_filesupplies it to Next.js)
- Container port was hardcoded (
NEXT_PUBLIC_API_URL Build-Time Fix (Latest)
- Fixed passenger web apps using
localhost:4000instead of the configured API URL:- Root cause:
NEXT_PUBLIC_*vars are baked into the JS bundle at build time; setting them in the runtimeenv_filehas no effect sync-env-from-server.shnow extracts anyNEXT_PUBLIC_*vars from the service.envand writes them toGITHUB_ENVbefore the build stepdocker-compose.yamlbuild arg renamed fromPASSENGER_NEXT_PUBLIC_API_URLtoNEXT_PUBLIC_API_URLto match the key used in the service env files directly
- Root cause:
Key Files to Review
.github/workflows/deploy.ymldocker-compose.yamlscripts/deploy/sync-env-from-server.shscripts/deploy/create-npmrc.shapps/edr-passenger-api/docker-entrypoint.shapps/edr-passenger-api/prisma/seed.tsinfrastructure/docker/Dockerfile.passenger-web(NEW)apps/edr-freight-api/Dockerfile(MODIFIED — pnpm store cache)apps/edr-passenger-api/Dockerfile(MODIFIED — prisma generate in /deploy + pnpm store cache)apps/edr-payment-api/Dockerfile(MODIFIED — pnpm store cache)infrastructure/docker/Dockerfile.web(MODIFIED — pnpm store cache)apps/edr-passenger-web/portal/next.config.js(MODIFIED)apps/edr-passenger-web/backoffice/next.config.js(MODIFIED)DEPLOYMENT.md(MODIFIED)
Backoffice Pages — Completion
- All backoffice pages are now fully implemented and connected to the API:
live/page.tsx— replaced stub with real LiveTrackingPage usingliveApi(trips, crowd signals, delay/status stats)notifications/page.tsx— replaced hardcoded mock + brokenTableimport with real page usingnotificationsApi(templates list, send form, notification history tab)
Prisma Client Missing After pnpm deploy (Latest)
- Fixed passenger API crash in Docker (
TypeError: Cannot convert undefined or null to objectatclass-validatorIsEnum, triggered bydist/modules/fare-engine/currency.dto.js):- Root cause:
currency.dto.tsimports theCurrencyenum (a runtime value) from@prisma/client. The generated Prisma client is an output ofprisma generate, not a package in the pnpm store, sopnpm deploydid not copy it into/deploy. At runtimeCurrencyresolved toundefined→@IsEnum(undefined)→Object.entries(undefined)throws at module load. - Prisma 6 + pnpm writes the client to
node_modules/.pnpm/@prisma+client@.../node_modules/.prisma/client, not rootnode_modules/.prisma. The oldcprescue in the Dockerfile guarded on[ -d node_modules/.prisma ](root) which never existed → silently skipped. - Fix in
apps/edr-passenger-api/Dockerfile: replaced the brokencpwithRUN cd /deploy && npm run prisma:generateafterpnpm deploy, regenerating the client into the exact runtime-resolve path (/deploy/node_modules/.prisma/client). Safe because deploy has no--prodflag (so theprismaCLI ships) andpackage.jsondeclares the schema path. - Affected 16 passenger-api files importing from
@prisma/client;currency.dto.jsjust loaded first. payment-api unaffected (TypeORM, no Prisma).
- Root cause:
pnpm Store Build Cache Fix (Latest)
- Fixed Docker builds re-downloading all dependencies every pipeline run:
- Root cause: install steps used
--mount=type=cache,id=pnpm,target=/pnpm/store, but nothing set pnpm's store-dir to/pnpm/store. Default store (~/.local/share/pnpm/store) was never under the mount → BuildKit cached an empty dir → full re-download each build. The two web Dockerfiles had the mount but it was dead; the two API Dockerfiles (freight, payment) had no mount at all. - Fix: added
ENV PNPM_HOME="/pnpm"(+ PATH) to thebasestage of all 5 Dockerfiles so the store resolves to/pnpm/store, matching the mount. Added the cache mount to everypnpm installandpnpm deploystep that lacked it. - Files:
apps/edr-freight-api/Dockerfile,apps/edr-passenger-api/Dockerfile,apps/edr-payment-api/Dockerfile,infrastructure/docker/Dockerfile.web,infrastructure/docker/Dockerfile.passenger-web. - Caveat: BuildKit cache mounts live on the runner host; persists only while the same self-hosted runner/builder is reused and not pruned (
docker builder prunewipes it).
- Root cause: install steps used
Next Actions
- Run full CI on all target branches (
main,dev,staging) and verify matrix job behavior. - Validate server env directory layout matches script expectations:
/home/<deploy_user>/environment/edr/<branch-slug>/<project>/...
- Confirm each service env file includes valid
PORTand service-specific runtime vars. - Verify branch-specific compose project names produce isolated containers/networks/volumes on runner.
- Smoke test all 6 deployed services behind real environment URLs.
Open Risks / Notes
- Passenger seed runs on every container start; confirm this is desired for production-like environments.
- Prisma warns about
package.json#prismadeprecation (Prisma 7 migration pending). - Matrix parallelism increases runner load; ensure self-hosted runner capacity is sufficient.
- Port collisions are prevented by env-driven mapping, but bad env values can still cause runtime conflicts.
- Passenger web uses Next.js server mode (not static export):
- Requires Node.js at runtime (previously could use pure static hosting)
NEXT_PUBLIC_API_URLmust be set in the service env file (passenger-portal.env/passenger-backoffice.env) — the sync script forwards it to the build automatically- Each portal/backoffice instance runs its own Node.js process (watch container memory usage)
- Freight web still uses Vite+nginx (different from passenger web) — maintain both Dockerfiles separately