Fix prisma deploy issue

This commit is contained in:
adilallo
2026-05-23 17:26:18 -06:00
parent 28eb5007fc
commit 4af244fa09
5 changed files with 41 additions and 37 deletions
+1 -1
View File
@@ -4,7 +4,7 @@
"title": "Community Rule", "title": "Community Rule",
"author": "MEDLab", "author": "MEDLab",
"description": "Community governance and rule-building app", "description": "Community governance and rule-building app",
"version": "0.1.0", "version": "0.1.1",
"httpPort": 3000, "httpPort": 3000,
"healthCheckPath": "/api/health", "healthCheckPath": "/api/health",
"memoryLimit": 805306368, "memoryLimit": 805306368,
+4 -4
View File
@@ -43,10 +43,10 @@ COPY --from=builder --chown=node:node /app/.next/standalone ./
COPY --from=builder --chown=node:node /app/.next/static ./.next/static COPY --from=builder --chown=node:node /app/.next/static ./.next/static
COPY --from=builder --chown=node:node /app/prisma ./prisma COPY --from=builder --chown=node:node /app/prisma ./prisma
# Prisma CLI is in devDependencies and is not included in the Next.js # Prisma CLI (devDependency) is not in the Next.js standalone trace. Install
# standalone output. Copy it explicitly so start.sh can run migrations. # globally in the runner so start.sh can run `prisma migrate deploy` with all
COPY --from=builder --chown=node:node /app/node_modules/prisma ./node_modules/prisma # transitive deps (@prisma/engines, effect, etc.).
COPY --from=builder --chown=node:node /app/node_modules/.bin/prisma ./node_modules/.bin/prisma RUN npm install -g prisma@6.19.3
# Cloudron's runtime rootfs is read-only except /tmp, /run, /app/data. # Cloudron's runtime rootfs is read-only except /tmp, /run, /app/data.
# Three marketing routes use ISR (`revalidate`) and write to .next/cache; # Three marketing routes use ISR (`revalidate`) and write to .next/cache;
+30 -26
View File
@@ -70,7 +70,7 @@ per-app in the manifest and provisioned at install time.
assembles a Nodemailer transport URL from these four vars in assembles a Nodemailer transport URL from these four vars in
[`lib/server/env.ts`](../../lib/server/env.ts). [`lib/server/env.ts`](../../lib/server/env.ts).
### I set manually via `cloudron configure --app <id> --set-env` ### I set manually via `cloudron env set --app <id/location>`
- `SESSION_SECRET` — long random (`openssl rand -hex 32`). Required, - `SESSION_SECRET` — long random (`openssl rand -hex 32`). Required,
≥ 16 chars. Rotating it logs everyone out. ≥ 16 chars. Rotating it logs everyone out.
@@ -114,10 +114,13 @@ apex.
### Phases ### Phases
1. **Staging install** — from a checkout whose 1. **Staging install** — from a checkout whose
[`CloudronManifest.json`](../../CloudronManifest.json) matches the pushed [`CloudronManifest.json`](../../CloudronManifest.json) `version` matches the
image tag, run `cloudron install --location staging.communityrule.info`. pushed image tag, run:
Cloudron reads `dockerimage` from the manifest (no `--image` flag). Set ```bash
manual env vars from §3. `prisma migrate deploy` runs automatically in cloudron install --location staging.communityrule.info \
--image git.medlab.host/communityrule/community-rule:<tag>
```
Set manual env vars from §3. `prisma migrate deploy` runs automatically in
[`scripts/start.sh`](../../scripts/start.sh) on container start. Smoke per [`scripts/start.sh`](../../scripts/start.sh) on container start. Smoke per
[CR-98](https://linear.app/community-rule/issue/CR-98/backend-cloudron-staging-install-smoke) [CR-98](https://linear.app/community-rule/issue/CR-98/backend-cloudron-staging-install-smoke)
(§12). (§12).
@@ -274,9 +277,7 @@ standalone server.
1. **Bump the manifest version.** Edit 1. **Bump the manifest version.** Edit
[`CloudronManifest.json`](../../CloudronManifest.json): [`CloudronManifest.json`](../../CloudronManifest.json):
- increment `version` (e.g. `0.1.0` → `0.1.1`) — Cloudron requires - increment `version` (e.g. `0.1.0` → `0.1.1`) — Cloudron requires
it to **increase** for `cloudron update --image` to be accepted; it to **increase** for `cloudron update --image` to be accepted.
- update `dockerimage` to the tag you're about to push (default tag
is the git short SHA).
2. **Run the release script** from the repo root: 2. **Run the release script** from the repo root:
```bash ```bash
@@ -285,9 +286,9 @@ standalone server.
npm run docker:release npm run docker:release
``` ```
Override the tag with `TAG=v0.1.1 ./scripts/docker-release.sh` for Override the tag with `TAG=0.1.1 ./scripts/docker-release.sh` for
semver releases. The script prints the exact `dockerimage` line to semver releases. The script prints the exact `cloudron install` /
paste back into the manifest. `cloudron update --image …` commands to run next.
3. **First push only:** confirm the 3. **First push only:** confirm the
[`CommunityRule/community-rule`](https://git.medlab.host/CommunityRule/community-rule) [`CommunityRule/community-rule`](https://git.medlab.host/CommunityRule/community-rule)
repo is **Public** (Settings → General). Gitea inherits container-package repo is **Public** (Settings → General). Gitea inherits container-package
@@ -316,15 +317,16 @@ logged in to `my.medlab.host`:
```bash ```bash
# First install (staging): # First install (staging):
cloudron install --location staging.communityrule.info cloudron install --location staging.communityrule.info \
--image git.medlab.host/communityrule/community-rule:<tag>
# Subsequent updates: # Subsequent updates:
cloudron update --app <app-id> cloudron update --app staging.communityrule.info \
--image git.medlab.host/communityrule/community-rule:<tag>
``` ```
`cloudron install` reads `dockerimage` from Pass the registry image with `--image`; it is not a field in
[`CloudronManifest.json`](../../CloudronManifest.json); no `--image` [`CloudronManifest.json`](../../CloudronManifest.json).
flag needed.
### CI — deferred (stretch goal) ### CI — deferred (stretch goal)
@@ -358,24 +360,26 @@ production env vars, and verify the vertical slice before apex cutover
**Install steps:** **Install steps:**
1. **Checkout** a commit whose [`CloudronManifest.json`](../../CloudronManifest.json) 1. **Checkout** a commit whose [`CloudronManifest.json`](../../CloudronManifest.json)
`version`, `dockerimage`, and `memoryLimit` match the image you intend to `version` and `memoryLimit` match the image you intend to run (currently
run (currently `0.1.0` `0.1.1` → `git.medlab.host/communityrule/community-rule:0.1.1`).
`git.medlab.host/communityrule/community-rule:0.1.0`).
2. **Log in to Cloudron CLI:** 2. **Log in to Cloudron CLI:**
```bash ```bash
cloudron login my.medlab.host cloudron login my.medlab.host
``` ```
3. **Install** from the repo root (manifest is read automatically): 3. **Install or update** from the repo root (manifest is read for addons;
image comes from `--image`):
```bash ```bash
cloudron install --location staging.communityrule.info cloudron update --app staging.communityrule.info \
--image git.medlab.host/communityrule/community-rule:0.1.1
``` ```
Cloudron provisions **postgresql**, **sendmail**, and **localstorage** (Use `cloudron install --location … --image …` only if staging is not
addons from the manifest, pulls the image (no registry credentials needed), already installed.) Cloudron provisions **postgresql**, **sendmail**, and
and starts the container. `scripts/start.sh` chowns `/app/data`, runs **localstorage** addons from the manifest, pulls the image (no registry
`prisma migrate deploy`, then execs the Next.js server. credentials needed), and starts the container. `scripts/start.sh` chowns
`/app/data`, runs `prisma migrate deploy`, then execs the Next.js server.
4. **Set manual env vars** (Cloudron does not inject these): 4. **Set manual env vars** (Cloudron does not inject these):
```bash ```bash
cloudron configure --app <app-id> --set-env \ cloudron env set --app staging.communityrule.info \
SESSION_SECRET="$(openssl rand -hex 32)" \ SESSION_SECRET="$(openssl rand -hex 32)" \
SMTP_FROM="Community Rule <hello@communityrule.info>" \ SMTP_FROM="Community Rule <hello@communityrule.info>" \
NEXT_PUBLIC_ENABLE_BACKEND_SYNC=true \ NEXT_PUBLIC_ENABLE_BACKEND_SYNC=true \
+5 -5
View File
@@ -31,8 +31,8 @@ echo
echo "Pushed: $IMAGE:$TAG ($PLATFORM)" echo "Pushed: $IMAGE:$TAG ($PLATFORM)"
echo echo
echo "Next steps:" echo "Next steps:"
echo " 1. Update CloudronManifest.json 'version' (must increase) and" echo " 1. Bump CloudronManifest.json 'version' (must increase for cloudron update)."
echo " 'dockerimage' to:" echo " 2. First install:"
echo " \"dockerimage\": \"$IMAGE:$TAG\"" echo " cloudron install --location staging.communityrule.info --image $IMAGE:$TAG"
echo " 2. First install: cloudron install" echo " Subsequent update:"
echo " Subsequent: cloudron update --app <app-id>" echo " cloudron update --app staging.communityrule.info --image $IMAGE:$TAG"
+1 -1
View File
@@ -21,4 +21,4 @@ chown -R node:node /tmp/next-cache
# Drop privileges, apply any pending migrations, then exec the server. # Drop privileges, apply any pending migrations, then exec the server.
# Inner `exec` ensures SIGTERM from Cloudron reaches node for clean shutdown. # Inner `exec` ensures SIGTERM from Cloudron reaches node for clean shutdown.
exec gosu node:node sh -c \ exec gosu node:node sh -c \
'./node_modules/.bin/prisma migrate deploy && exec node server.js' 'prisma migrate deploy && exec node server.js'