Skip to content

Commit cc8839b

Browse files
committed
fix(notes): resolve white page on Porter deploy
- Set PORT=80 in porter.yaml env so app binds to the port Porter routes to (was defaulting to 3000 while Porter forwarded traffic to 80) - Fix frontend crash on load: replace Vite-specific import.meta.env.DEV with process.env.NODE_ENV check in devMode.ts (undefined in Bun prod bundle → TypeError → blank page) - Add .dockerignore to stop node_modules/.env from leaking into image - Add docker:build/run/test scripts for local prod-parity testing (linux/amd64 to match Porter) - Clean up Dockerfile: drop stale build:webview comment (Bun.serve bundles HTML routes at runtime, no separate build step needed)
1 parent 1136d2b commit cc8839b

5 files changed

Lines changed: 31 additions & 5 deletions

File tree

.dockerignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
node_modules
2+
**/node_modules
3+
.env
4+
.env.local
5+
.env.*.local
6+
.git
7+
.gitignore
8+
.DS_Store
9+
*.log
10+
.vscode
11+
.idea
12+
dist
13+
build
14+
coverage
15+
.next
16+
.cache
17+
packages/display-utils/dist
18+
packages/display-utils/node_modules

docker/Dockerfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ RUN bun install
2626
# Copy the rest of the application code
2727
COPY . .
2828

29-
# Build webview for production
30-
# RUN bun run build:webview
29+
# Note: no separate webview build step — Bun.serve bundles HTML routes
30+
# (src/frontend/index.prod.html → frontend.tsx) on demand at request time.
3131

3232
# Set production environment
3333
ENV NODE_ENV=production
34+
ENV PORT=80
35+
ENV HOST=0.0.0.0
3436

3537
# Expose the port
3638
EXPOSE 80
3739

38-
# dont' Start the application, the porter.yaml file has cmd to start it.
39-
# CMD ["bun", "src/index.ts"]
40+
# porter.yaml's `run:` field starts the app.

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
"scripts": {
1212
"dev": "lsof -ti:3000 | xargs kill -9 2>/dev/null; NODE_ENV=development bun --watch src/index.ts",
1313
"start": "bun src/index.ts",
14+
"start:prod": "NODE_ENV=production bun src/index.ts",
15+
"docker:build": "docker build --platform linux/amd64 -f docker/Dockerfile -t mentra-notes:local .",
16+
"docker:run": "docker run --rm --platform linux/amd64 -p 8080:80 --env-file .env -e NODE_ENV=production -e PORT=80 -e HOST=0.0.0.0 mentra-notes:local bun src/index.ts",
17+
"docker:test": "bun run docker:build && bun run docker:run",
1418
"ngrok": "ngrok http 3000 --url https://isaiah-tpa.ngrok.app",
1519
"test:eval:classifier": "bun test src/test/evals/classifier/triage-classifier.test.ts",
1620
"test:eval:classifier:easy": "EVAL_DIFFICULTY=easy bun test src/test/evals/classifier/triage-classifier.test.ts",

porter.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ services:
1818
NODE_ENV: ${NODE_ENV}
1919
PORTER_APP_NAME: ${PORTER_APP_NAME}
2020
HOST: "0.0.0.0"
21+
PORT: "80"

src/frontend/lib/devMode.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111

1212
/**
1313
* Check if we're in development mode
14+
*
15+
* Bun replaces `process.env.NODE_ENV` at bundle time for HTML routes.
1416
*/
15-
export const isDevelopmentMode = import.meta.env.DEV;
17+
export const isDevelopmentMode = process.env.NODE_ENV !== "production";
1618

1719
/**
1820
* Get current mock data mode setting

0 commit comments

Comments
 (0)