mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
Fare and route-coach, production checklist updates
This commit is contained in:
@@ -121,13 +121,59 @@ This ensures `docker ps` shows `0.0.0.0:<port>-><port>/tcp` with matching ports.
|
||||
|
||||
### Runtime
|
||||
|
||||
The final image runs:
|
||||
The final image uses Next.js `output: 'standalone'` and runs:
|
||||
|
||||
```bash
|
||||
npx next start
|
||||
node server.js
|
||||
```
|
||||
|
||||
Next.js reads `PORT` from the runtime environment (supplied via `env_file` in docker-compose) to determine which port to listen on.
|
||||
Next.js reads `PORT` from the runtime environment (supplied via `env_file` in docker-compose). The standalone output bundles only the required `node_modules`, producing a significantly smaller image than a full `pnpm deploy`.
|
||||
|
||||
## Rollback Procedure
|
||||
|
||||
Each build is tagged with the short git SHA (`${COMPOSE_PROJECT_NAME}-<service>:<sha8>`).
|
||||
|
||||
### Rollback a single service
|
||||
|
||||
```bash
|
||||
# 1. Find the last known-good image tag
|
||||
docker images | grep passenger-api
|
||||
|
||||
# 2. Re-tag it as the current image
|
||||
docker tag edr-passenger-main-passenger-api:<previous-sha> edr-passenger-main-passenger-api:latest
|
||||
|
||||
# 3. Restart the container from the previous image
|
||||
docker compose --project-name edr-passenger-main up -d passenger-api --force-recreate
|
||||
```
|
||||
|
||||
### Rollback via re-run
|
||||
|
||||
Alternatively, trigger a `workflow_dispatch` on the last known-good commit SHA from the GitHub Actions UI — this rebuilds and redeploys that exact commit.
|
||||
|
||||
## Production Security Checklist
|
||||
|
||||
Before deploying to production, verify:
|
||||
|
||||
- [ ] `JWT_SECRET`, `JWT_ACCESS_TOKEN_SECRET`, `JWT_REFRESH_TOKEN_SECRET` are set to random 32+ char strings (`openssl rand -hex 32`)
|
||||
- [ ] `DATABASE_URL` includes `?sslmode=require&connection_limit=10`
|
||||
- [ ] `WAAFI_INSECURE_TLS` is `false` (app will refuse to start if `true` in production)
|
||||
- [ ] `NODE_ENV=production` is set
|
||||
- [ ] `GITHUB_PACKAGE_TOKEN` is a scoped read-only token, not a personal admin token
|
||||
- [ ] No `.env` files are committed to the repository (`git status` should show none)
|
||||
|
||||
## Data Retention Policy
|
||||
|
||||
The `TasksService` runs a daily purge cron at 02:00 EAT that automatically deletes:
|
||||
|
||||
| Table | Retention |
|
||||
|---|---|
|
||||
| `OtpCode` | 1 hour after expiry or verification |
|
||||
| `FaydaVerificationSession` | 1 hour after expiry or completion |
|
||||
| `AuditLog` | 365 days |
|
||||
| `PaymentWebhookEvent` | 90 days |
|
||||
| `GateValidationLog` | 180 days |
|
||||
|
||||
No manual intervention is required. Monitor the `TasksService` log output for purge counts.
|
||||
|
||||
## GitHub Actions Deployment Flow
|
||||
|
||||
@@ -147,9 +193,10 @@ For each service:
|
||||
- Computes branch slug and sets:
|
||||
- `COMPOSE_PROJECT_NAME=<project>-<branch-slug>`
|
||||
- Creates `.npmrc`/`.npmrc_temp` from `NPM_TOKEN`.
|
||||
- Runs:
|
||||
- `docker compose --project-name "$COMPOSE_PROJECT_NAME" build <service>`
|
||||
- `docker compose --project-name "$COMPOSE_PROJECT_NAME" up -d <service>`
|
||||
- For `passenger-api` and `payment-api`: builds and runs the migration image as a gated step before the app image.
|
||||
- Builds the service image and tags it with the short git SHA.
|
||||
- Runs `docker compose up -d <service> --force-recreate`.
|
||||
- For API services: polls `GET /health/ready` every 10s for up to 120s. Fails the job if the service does not become healthy.
|
||||
- Cleans `.npmrc`/`.npmrc_temp`.
|
||||
|
||||
## Branch/Environment Isolation
|
||||
|
||||
Reference in New Issue
Block a user