diff --git a/.env.template b/.env.template index 7a9559d7..86f24f47 100644 --- a/.env.template +++ b/.env.template @@ -3,19 +3,19 @@ DB_USER= DB_PASSWORD= DB_NAME= DB_HOST= -DB_PORT= +DB_PORT=19010 DATABASE_URL= WEB_APP_URL= # REDIS REDIS_HOST= -REDIS_PORT= +REDIS_PORT=19011 REDIS_PASSWORD= # TYPESENSE TYPESENSE_HOST= -TYPESENSE_PORT= +TYPESENSE_PORT=19012 TYPESENSE_PROTOCOL= TYPESENSE_API_KEY= diff --git a/README.md b/README.md index 6d34f447..1a9be19f 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,28 @@ cp .env.template .env.local bun run start ``` +### Local ports + +Everything in development lives in **19000-19019**, so the repo can run alongside other +projects without colliding on 3000, 6379 or 8108. The host ports come from `.env`; the +container ports behind them are untouched, as are the defaults the deployed images use. + +| Port | Service | Set in | +| ----- | -------------- | --------------------------------------- | +| 19000 | web | `apps/web/project.json` (`next dev -p`) | +| 19001 | api | `apps/api/.env` | +| 19002 | notify | `apps/notify/.env` | +| 19003 | worker | `apps/worker/.env` | +| 19004 | mobile (Metro) | `apps/mobile/project.json` | +| 19010 | postgres | `.env` (`DB_PORT`) | +| 19011 | redis | `.env` (`REDIS_PORT`) | +| 19012 | typesense | `.env` (`TYPESENSE_PORT`) | +| 19013 | s3 (rustfs) | `.env` (`S3_PORT`) | +| 19014 | s3 console | `.env` (`S3_CONSOLE_PORT`) | + +Mobile needs its port pinned explicitly: `@nx/expo:start` defaults Metro to 19000, which +is the web app's port here, while `expo run:ios` and `expo run:android` default to 8081. + ## 🤝 Contributing Contributions are welcome! See [CONTRIBUTING.md](./CONTRIBUTING.md) for how to submit issues and pull requests. diff --git a/apps/api/.env.template b/apps/api/.env.template index f13ce56d..6f824f7d 100644 --- a/apps/api/.env.template +++ b/apps/api/.env.template @@ -1,4 +1,4 @@ -PORT=9000 +PORT=19001 HOST=0.0.0.0 API_URL= diff --git a/apps/api/project.json b/apps/api/project.json index f4b9b7bb..195670a4 100644 --- a/apps/api/project.json +++ b/apps/api/project.json @@ -86,11 +86,11 @@ "continuous": true, "executor": "nx:run-commands", "options": { - "command": "HOST=localhost bunx @modelcontextprotocol/inspector --web --transport http --server-url http://localhost:9000/mcp" + "command": "HOST=localhost bunx @modelcontextprotocol/inspector --web --transport http --server-url http://localhost:19001/mcp" }, "configurations": { "cli": { - "command": "HOST=localhost bunx @modelcontextprotocol/inspector --cli --transport http --server-url http://localhost:9000/mcp" + "command": "HOST=localhost bunx @modelcontextprotocol/inspector --cli --transport http --server-url http://localhost:19001/mcp" } } }, diff --git a/apps/mobile/package.json b/apps/mobile/package.json index 67f01b88..1e1f7890 100644 --- a/apps/mobile/package.json +++ b/apps/mobile/package.json @@ -4,8 +4,8 @@ "main": "index.js", "private": true, "scripts": { - "android": "expo run:android", - "ios": "expo run:ios", + "android": "expo run:android --port 19004", + "ios": "expo run:ios --port 19004", "lint": "expo lint" }, "dependencies": { diff --git a/apps/mobile/project.json b/apps/mobile/project.json index 8ad966c4..cc11a522 100644 --- a/apps/mobile/project.json +++ b/apps/mobile/project.json @@ -17,6 +17,9 @@ "command": "tsc --noEmit -p apps/mobile/tsconfig.app.json" } }, + "start": { + "options": { "port": 19004 } + }, "dev": { "executor": "nx:run-commands", "options": { @@ -26,13 +29,13 @@ "dev-ios": { "executor": "nx:run-commands", "options": { - "command": "APP_VARIANT=development nx run-ios mobile" + "command": "APP_VARIANT=development nx run-ios mobile --port 19004" } }, "dev-android": { "executor": "nx:run-commands", "options": { - "command": "APP_VARIANT=development nx run-android mobile" + "command": "APP_VARIANT=development nx run-android mobile --port 19004" } }, "prebuild": { diff --git a/apps/notify/.env.template b/apps/notify/.env.template index b6b80d15..459fbcac 100644 --- a/apps/notify/.env.template +++ b/apps/notify/.env.template @@ -1,4 +1,4 @@ -PORT=9001 +PORT=19002 HOST=0.0.0.0 ASSETS_BASE_URL= diff --git a/apps/web/project.json b/apps/web/project.json index 57ee0c33..a10698c1 100644 --- a/apps/web/project.json +++ b/apps/web/project.json @@ -14,7 +14,7 @@ "serve": { "dependsOn": ["^build", "api:serve"], "options": { - "command": "bun --bun next dev" + "command": "bun --bun next dev -p 19000" } }, "start": { diff --git a/apps/web/src/lib/utils.spec.ts b/apps/web/src/lib/utils.spec.ts index dce6b9b0..33212060 100644 --- a/apps/web/src/lib/utils.spec.ts +++ b/apps/web/src/lib/utils.spec.ts @@ -61,6 +61,6 @@ describe('getURL', () => { NEXT_PUBLIC_VERCEL_URL: undefined, NODE_ENV: 'development', }), - ).toBe('http://localhost:3000'); + ).toBe('http://localhost:19000'); }); }); diff --git a/apps/web/src/lib/utils.ts b/apps/web/src/lib/utils.ts index 4aebc5b7..a26890a2 100644 --- a/apps/web/src/lib/utils.ts +++ b/apps/web/src/lib/utils.ts @@ -44,7 +44,7 @@ export function toISO8601Duration(minutes: number): string { } const PRODUCTION_URL = 'https://recomend.app'; -const DEVELOPMENT_URL = 'http://localhost:3000'; +const DEVELOPMENT_URL = 'http://localhost:19000'; /** * The site's own origin, never with a trailing slash. diff --git a/apps/worker/.env.template b/apps/worker/.env.template index 0812e7ca..df0d0fed 100644 --- a/apps/worker/.env.template +++ b/apps/worker/.env.template @@ -1,2 +1,2 @@ -PORT=9002 +PORT=19003 HOST=0.0.0.0 \ No newline at end of file diff --git a/libs/assets/README.md b/libs/assets/README.md index 142c03ce..2433631b 100644 --- a/libs/assets/README.md +++ b/libs/assets/README.md @@ -94,8 +94,8 @@ it explicitly, e.g. `apps/notify/project.json`: } ``` -Locally, `${ASSETS_BASE_URL}` resolves to `http://localhost:9900/medias/static`, -so the example above resolves to `http://localhost:9900/medias/static/app/icon.png`. +Locally, `${ASSETS_BASE_URL}` resolves to `http://localhost:19013/medias/static`, +so the example above resolves to `http://localhost:19013/medias/static/app/icon.png`. ## Local dev diff --git a/libs/env/src/lib/env.validation.spec.ts b/libs/env/src/lib/env.validation.spec.ts index 54aa5950..653182fa 100644 --- a/libs/env/src/lib/env.validation.spec.ts +++ b/libs/env/src/lib/env.validation.spec.ts @@ -84,7 +84,7 @@ describe('commonSchema', () => { const result = commonSchema.parse({}); expect(result.NODE_ENV).toBe('development'); expect(result.LOG_LEVEL).toBe('info'); - expect(result.WEB_APP_URL).toBe('http://localhost:3000'); + expect(result.WEB_APP_URL).toBe('http://localhost:19000'); }); it('rejects an unsupported NODE_ENV', () => { diff --git a/libs/env/src/lib/env.validation.ts b/libs/env/src/lib/env.validation.ts index 1a655a8e..353d9c75 100644 --- a/libs/env/src/lib/env.validation.ts +++ b/libs/env/src/lib/env.validation.ts @@ -30,7 +30,7 @@ export const extensionSchema = redisSchema; export const commonSchema = extensionSchema.extend({ NODE_ENV: z.enum(['development', 'production', 'test']).default('development'), LOG_LEVEL: z.enum(['debug', 'info', 'warn', 'error']).default('info'), - WEB_APP_URL: z.url().default('http://localhost:3000'), + WEB_APP_URL: z.url().default('http://localhost:19000'), }); // Static assets served from RustFS/S3 (see libs/assets)