From 82c4cfe21e5d54d5657ec8892add00956540d81a Mon Sep 17 00:00:00 2001 From: Abdulazeem-code Date: Mon, 3 Aug 2026 10:21:15 +0100 Subject: [PATCH] Add Render blueprint and DATABASE_URL guard --- README.md | 12 ++++++++++-- render.yaml | 24 ++++++++++++++++++++++++ stellar-payment-platform/startup.sh | 7 +++++++ 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 render.yaml diff --git a/README.md b/README.md index 172140f..49a4a4a 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Stellar Tags is a payment platform that combines a Soroban smart contract, a Nod ## Architecture Map -The following diagram maps exactly how data flows between the user, Vercel, Railway, and the Stellar network. +The following diagram maps exactly how data flows between the user, Render, and the Stellar network. ```text [ User / Browser ] @@ -29,7 +29,7 @@ The following diagram maps exactly how data flows between the user, Vercel, Rail | HTTP API Calls (via VITE_API_BASE) v [ stellar-payment-platform ] <---> [ PostgreSQL Database ] - (server.js: Server router on Railway) (via Prisma ORM: User/payment layout) + (server.js: Server router on Render) (via Prisma ORM: User/payment layout) | | Stellar Network / RPC v @@ -127,6 +127,12 @@ Useful Prisma commands (run from `stellar-payment-platform/`): > `.env` is gitignored — never commit real credentials. Each contributor keeps > their own local `DATABASE_URL`. +### Render deployment + +The repository includes a [render.yaml](render.yaml) blueprint for the backend API and its PostgreSQL database. When you deploy from Render, import the blueprint or create the service from the repo so `DATABASE_URL` is injected automatically from the managed database. + +If you deploy the backend without the blueprint, make sure the web service has a PostgreSQL `DATABASE_URL` secret configured before startup. The container runs Prisma migrations on boot, so the variable must already exist. + ### Smart contract (Soroban) ```bash @@ -167,6 +173,8 @@ To ensure a seamless local developer installation requiring zero guesswork, plea - `LOG_MAX_SIZE` - (Optional) Size at which the active log file rotates. Defaults to `20m`. - `LOG_MAX_FILES` - (Optional) Retention for rotated files, as a count (`30`) or an age (`14d`). Defaults to `14d`. +For Render deployments, make sure the web service has `DATABASE_URL` set in its environment or linked from a Render PostgreSQL instance before startup. The container runs `prisma migrate deploy` during boot, so the variable must be available at runtime. + ## Logging The server logs through a shared [Winston](https://github.com/winstonjs/winston) logger diff --git a/render.yaml b/render.yaml new file mode 100644 index 0000000..7453692 --- /dev/null +++ b/render.yaml @@ -0,0 +1,24 @@ +databases: + - name: stellar-tags-db + databaseName: stellar_tags + user: stellar_tags + plan: basic-256mb + +services: + - type: web + name: stellar-tags-api + runtime: docker + dockerfilePath: ./Dockerfile-backend + dockerContext: . + autoDeployTrigger: commit + plan: starter + healthCheckPath: /health + envVars: + - key: NODE_ENV + value: production + - key: LOG_DIR + value: /app/logs + - key: DATABASE_URL + fromDatabase: + name: stellar-tags-db + property: connectionString \ No newline at end of file diff --git a/stellar-payment-platform/startup.sh b/stellar-payment-platform/startup.sh index 6805514..9091bff 100644 --- a/stellar-payment-platform/startup.sh +++ b/stellar-payment-platform/startup.sh @@ -6,6 +6,13 @@ set -e # this schema (`url` in the datasource block, the "metrics" preview feature). PRISMA="./node_modules/.bin/prisma" +if [ -z "${DATABASE_URL:-}" ]; then + echo "ERROR: DATABASE_URL is not set." >&2 + echo "Render must provide a PostgreSQL connection string to this service before startup." >&2 + echo "Link a Render PostgreSQL instance or set DATABASE_URL in the service environment." >&2 + exit 1 +fi + if [ ! -x "$PRISMA" ]; then echo "ERROR: Prisma CLI not found at $PRISMA." >&2 echo "It must be a production dependency so it survives 'npm prune --omit=dev'." >&2