Simplify Replit deployment
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
run = "pnpm dev"
|
||||||
|
onBoot = "pnpm install --ignore-workspace"
|
||||||
|
|
||||||
|
[deployment]
|
||||||
|
build = "pnpm install --ignore-workspace && pnpm run build"
|
||||||
|
run = "pnpm start"
|
||||||
@@ -4,6 +4,20 @@ This app is already prepared for one-shot deployment. Follow these commands exac
|
|||||||
|
|
||||||
Do not add this repo to a parent workspace. Do not move it into `artifacts/`. Do not edit source files. Do not edit `package.json`. Do not create `config.json` or a `/tmp` config file for deployment. Do not inspect or free unrelated ports.
|
Do not add this repo to a parent workspace. Do not move it into `artifacts/`. Do not edit source files. Do not edit `package.json`. Do not create `config.json` or a `/tmp` config file for deployment. Do not inspect or free unrelated ports.
|
||||||
|
|
||||||
|
## Replit
|
||||||
|
|
||||||
|
The repo includes `.replit`, so after import the Run button starts the app with:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm dev
|
||||||
|
```
|
||||||
|
|
||||||
|
The `.replit` `onBoot` command installs dependencies with:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pnpm install --ignore-workspace
|
||||||
|
```
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
Run from this repository root:
|
Run from this repository root:
|
||||||
@@ -16,37 +30,41 @@ Use the available `pnpm`. This repo intentionally has no `packageManager` pin.
|
|||||||
|
|
||||||
## Start
|
## Start
|
||||||
|
|
||||||
Without Replit AI Integrations:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pnpm dev
|
pnpm dev
|
||||||
```
|
```
|
||||||
|
|
||||||
With Replit AI Integrations:
|
When Replit AI Integrations are provisioned, the app reads these variables automatically:
|
||||||
|
|
||||||
|
- `AI_INTEGRATIONS_OPENAI_BASE_URL`
|
||||||
|
- `AI_INTEGRATIONS_OPENAI_API_KEY`
|
||||||
|
- `AI_INTEGRATIONS_ANTHROPIC_BASE_URL`
|
||||||
|
- `AI_INTEGRATIONS_ANTHROPIC_API_KEY`
|
||||||
|
|
||||||
|
Provider CLI flags are still supported for manual overrides:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pnpm dev -- \
|
pnpm dev -- \
|
||||||
--host 0.0.0.0 \
|
|
||||||
--port 3000 \
|
|
||||||
--proxy-api-key dev-proxy-key \
|
|
||||||
--openai-base-url "<ai-integrations-openai-base-url>" \
|
--openai-base-url "<ai-integrations-openai-base-url>" \
|
||||||
--openai-api-key "<ai-integrations-openai-api-key>" \
|
--openai-api-key "<ai-integrations-openai-api-key>" \
|
||||||
--anthropic-base-url "<ai-integrations-anthropic-base-url>" \
|
--anthropic-base-url "<ai-integrations-anthropic-base-url>" \
|
||||||
--anthropic-api-key "<ai-integrations-anthropic-api-key>"
|
--anthropic-api-key "<ai-integrations-anthropic-api-key>"
|
||||||
```
|
```
|
||||||
|
|
||||||
The provider flags above are implemented. Do not verify them by reading source first.
|
|
||||||
|
|
||||||
Use Replit AI Integrations endpoints only. Never use public official provider endpoints. Do not print provider tokens.
|
Use Replit AI Integrations endpoints only. Never use public official provider endpoints. Do not print provider tokens.
|
||||||
|
|
||||||
If the process does not stay alive after the shell exits, create the smallest background workflow that runs the same `pnpm dev ...` command from this repository root.
|
|
||||||
|
|
||||||
## Defaults
|
## Defaults
|
||||||
|
|
||||||
- host: `0.0.0.0`
|
- host: `0.0.0.0`
|
||||||
- port: `3000`
|
- port: `3000`
|
||||||
- bearer token: `dev-proxy-key`
|
- bearer token: `dev-proxy-key`
|
||||||
|
|
||||||
|
These can be overridden with CLI flags or environment variables:
|
||||||
|
|
||||||
|
- `--host` or `HOST`
|
||||||
|
- `--port` or `PORT`
|
||||||
|
- `--proxy-api-key` or `PROXY_API_KEY`
|
||||||
|
|
||||||
## Verify
|
## Verify
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
Standalone TypeScript API server with CLI-only deployment configuration.
|
Standalone TypeScript API server with Replit run and deployment configuration.
|
||||||
|
|
||||||
## Stack
|
## Stack
|
||||||
|
|
||||||
@@ -14,7 +14,14 @@ Standalone TypeScript API server with CLI-only deployment configuration.
|
|||||||
|
|
||||||
## Provider Endpoints
|
## Provider Endpoints
|
||||||
|
|
||||||
Use Replit AI Integrations endpoints through CLI flags:
|
Use Replit AI Integrations endpoints. The app reads these environment variables automatically:
|
||||||
|
|
||||||
|
- `AI_INTEGRATIONS_OPENAI_BASE_URL`
|
||||||
|
- `AI_INTEGRATIONS_OPENAI_API_KEY`
|
||||||
|
- `AI_INTEGRATIONS_ANTHROPIC_BASE_URL`
|
||||||
|
- `AI_INTEGRATIONS_ANTHROPIC_API_KEY`
|
||||||
|
|
||||||
|
CLI flags are still available for manual overrides:
|
||||||
|
|
||||||
- `--openai-base-url`
|
- `--openai-base-url`
|
||||||
- `--openai-api-key`
|
- `--openai-api-key`
|
||||||
@@ -31,6 +38,19 @@ Never use public official provider endpoints.
|
|||||||
- `pnpm run build` — typecheck and build `dist/index.mjs`
|
- `pnpm run build` — typecheck and build `dist/index.mjs`
|
||||||
- `pnpm start` — run the built server
|
- `pnpm start` — run the built server
|
||||||
|
|
||||||
|
## Replit Configuration
|
||||||
|
|
||||||
|
- `.replit` `run` uses `pnpm dev`
|
||||||
|
- `.replit` `onBoot` uses `pnpm install --ignore-workspace`
|
||||||
|
- deployment build uses `pnpm install --ignore-workspace && pnpm run build`
|
||||||
|
- deployment run uses `pnpm start`
|
||||||
|
|
||||||
|
## Server Overrides
|
||||||
|
|
||||||
|
- `--host` or `HOST`
|
||||||
|
- `--port` or `PORT`
|
||||||
|
- `--proxy-api-key` or `PROXY_API_KEY`
|
||||||
|
|
||||||
## Routes
|
## Routes
|
||||||
|
|
||||||
- `/` and `/dashboard` — static model dashboard
|
- `/` and `/dashboard` — static model dashboard
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
Clone and run https://git.komnenos.me/springfw/random-proxy in ./random-proxy.
|
||||||
|
|
||||||
|
Goal: get the app running once, with Replit AI Integrations wired, on port 3000.
|
||||||
|
|
||||||
|
Do not:
|
||||||
|
- add it to a parent workspace
|
||||||
|
- move it into artifacts/
|
||||||
|
- modify source files
|
||||||
|
- edit package.json
|
||||||
|
- create config.json or /tmp config files
|
||||||
|
- inspect/free unrelated ports
|
||||||
|
- use nohup/setsid/background shell tricks
|
||||||
|
- run chat-completion smoke tests unless asked
|
||||||
|
|
||||||
|
Steps:
|
||||||
|
|
||||||
|
1. Clone into ./random-proxy.
|
||||||
|
|
||||||
|
2. Provision/use Replit AI Integrations for:
|
||||||
|
- OpenAI
|
||||||
|
- Anthropic
|
||||||
|
|
||||||
|
3. Open ./random-proxy and use the configured Replit Run button.
|
||||||
|
|
||||||
|
4. Wait briefly, then verify:
|
||||||
|
|
||||||
|
curl -s http://localhost:3000/api/healthz
|
||||||
|
curl -s http://localhost:3000/dashboard | head
|
||||||
|
curl -s -H "Authorization: Bearer dev-proxy-key" http://localhost:3000/v1/models
|
||||||
|
|
||||||
|
Report only:
|
||||||
|
- local URL
|
||||||
|
- whether OpenAI and Anthropic AI Integrations were wired
|
||||||
|
- verification results
|
||||||
+22
-8
@@ -55,31 +55,45 @@ function argFlag(name: string): boolean {
|
|||||||
return process.argv.includes(`--${name}`);
|
return process.argv.includes(`--${name}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function envValue(name: string): string | undefined {
|
||||||
|
const value = process.env[name];
|
||||||
|
return value && value.length > 0 ? value : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
function applyArgOverrides(base: AppConfig): AppConfig {
|
function applyArgOverrides(base: AppConfig): AppConfig {
|
||||||
const rawPort = argValue("port");
|
const rawPort = argValue("port") ?? envValue("PORT");
|
||||||
const port = rawPort === undefined ? base.server.port : Number(rawPort);
|
const port = rawPort === undefined ? base.server.port : Number(rawPort);
|
||||||
if (!Number.isInteger(port) || port <= 0) {
|
if (!Number.isInteger(port) || port <= 0) {
|
||||||
throw new Error(`Invalid CLI value "--port": ${rawPort}`);
|
throw new Error(`Invalid port value: ${rawPort}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const host = argValue("host") ?? envValue("HOST") ?? base.server.host;
|
||||||
|
const proxyApiKey = argValue("proxy-api-key") ?? envValue("PROXY_API_KEY") ?? base.proxy.apiKey;
|
||||||
|
const openaiBaseURL = argValue("openai-base-url") ?? envValue("AI_INTEGRATIONS_OPENAI_BASE_URL");
|
||||||
|
const openaiApiKey = argValue("openai-api-key") ?? envValue("AI_INTEGRATIONS_OPENAI_API_KEY");
|
||||||
|
const anthropicBaseURL =
|
||||||
|
argValue("anthropic-base-url") ?? envValue("AI_INTEGRATIONS_ANTHROPIC_BASE_URL");
|
||||||
|
const anthropicApiKey =
|
||||||
|
argValue("anthropic-api-key") ?? envValue("AI_INTEGRATIONS_ANTHROPIC_API_KEY");
|
||||||
|
|
||||||
return {
|
return {
|
||||||
server: {
|
server: {
|
||||||
host: argValue("host") ?? base.server.host,
|
host,
|
||||||
port,
|
port,
|
||||||
},
|
},
|
||||||
proxy: {
|
proxy: {
|
||||||
apiKey: argValue("proxy-api-key") ?? base.proxy.apiKey,
|
apiKey: proxyApiKey,
|
||||||
},
|
},
|
||||||
providers: {
|
providers: {
|
||||||
openai: {
|
openai: {
|
||||||
...base.providers.openai,
|
...base.providers.openai,
|
||||||
...(argValue("openai-base-url") ? { baseURL: argValue("openai-base-url") } : {}),
|
...(openaiBaseURL ? { baseURL: openaiBaseURL } : {}),
|
||||||
...(argValue("openai-api-key") ? { apiKey: argValue("openai-api-key") } : {}),
|
...(openaiApiKey ? { apiKey: openaiApiKey } : {}),
|
||||||
},
|
},
|
||||||
anthropic: {
|
anthropic: {
|
||||||
...base.providers.anthropic,
|
...base.providers.anthropic,
|
||||||
...(argValue("anthropic-base-url") ? { baseURL: argValue("anthropic-base-url") } : {}),
|
...(anthropicBaseURL ? { baseURL: anthropicBaseURL } : {}),
|
||||||
...(argValue("anthropic-api-key") ? { apiKey: argValue("anthropic-api-key") } : {}),
|
...(anthropicApiKey ? { apiKey: anthropicApiKey } : {}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
logging: {
|
logging: {
|
||||||
|
|||||||
Reference in New Issue
Block a user