From bed3e7a04e48edc5c01ea08d4466ab89d039c6e1 Mon Sep 17 00:00:00 2001 From: Max P Date: Mon, 23 Feb 2026 17:29:30 -0500 Subject: [PATCH] chore(deploy): speed up Railway runtime build and startup --- Dockerfile | 2 +- package.json | 8 ++++++++ railway.toml | 13 +++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 railway.toml diff --git a/Dockerfile b/Dockerfile index e73cd73e6..0a82dd6b8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,7 +31,7 @@ COPY ./replace.build.mjs replace.build.mjs COPY ./tsconfig.base.json tsconfig.base.json ENV NX_DAEMON=false -RUN npm run build:production +RUN npm run build:production:runtime # Prepare the dist image with additional node_modules WORKDIR /ghostfolio/dist/apps/api diff --git a/package.json b/package.json index 2bf5eebe0..4d0b4be07 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "analyze:client": "nx run client:build:production --stats-json && webpack-bundle-analyzer -p 1234 dist/apps/client/en/stats.json", "angular": "node --max_old_space_size=32768 ./node_modules/@angular/cli/bin/ng", "build:production": "nx run api:copy-assets && nx run api:build:production && nx run client:copy-assets && nx run client:build:production && nx run ui:build-storybook && npm run replace-placeholders-in-build", + "build:production:runtime": "nx run api:copy-assets && nx run api:build:production && nx run client:copy-assets && nx run client:build:production && npm run replace-placeholders-in-build", "build:storybook": "nx run ui:build-storybook", "database:format-schema": "prisma format", "database:generate-typings": "prisma generate", @@ -23,6 +24,7 @@ "database:migrate": "prisma migrate deploy", "database:push": "prisma db push", "database:seed": "prisma db seed", + "database:seed:ai-mvp": "npx dotenv-cli -e .env -- node tools/seed/seed-ai-mvp-data.mjs", "database:setup": "npm run database:push && npm run database:seed", "database:validate-schema": "prisma validate", "dep-graph": "nx dep-graph", @@ -31,6 +33,7 @@ "format:check": "nx format:check", "format:write": "nx format:write", "help": "nx help", + "hostinger:check": "npx dotenv-cli -e .env -- bash tools/hostinger/check-vps.sh", "lint": "nx run-many --target=lint --all", "ng": "nx", "nx": "nx", @@ -38,14 +41,18 @@ "prepare": "husky", "prisma": "prisma", "replace-placeholders-in-build": "node ./replace.build.mjs", + "railway:check": "npx dotenv-cli -e .env -- bash tools/railway/check-token.sh", + "railway:setup": "npx dotenv-cli -e .env -- bash tools/railway/setup-project.sh", "start": "node dist/apps/api/main", "start:client": "nx run client:copy-assets && nx run client:serve --configuration=development-en --hmr -o", "start:production": "npm run database:migrate && npm run database:seed && node main", "start:server": "nx run api:copy-assets && nx run api:serve --watch", "start:storybook": "nx run ui:storybook", "test": "npx dotenv-cli -e .env.example -- npx nx run-many --target=test --all --parallel=4", + "test:ai": "npx dotenv-cli -e .env.example -- npx jest apps/api/src/app/endpoints/ai/ai-agent.utils.spec.ts apps/api/src/app/endpoints/ai/ai.service.spec.ts apps/api/src/app/endpoints/ai/evals/mvp-eval.runner.spec.ts apps/api/src/app/endpoints/ai/ai.controller.spec.ts --config apps/api/jest.config.ts", "test:api": "npx dotenv-cli -e .env.example -- nx test api", "test:common": "npx dotenv-cli -e .env.example -- nx test common", + "test:mvp-eval": "npx dotenv-cli -e .env.example -- npx jest apps/api/src/app/endpoints/ai/evals/mvp-eval.runner.spec.ts --config apps/api/jest.config.ts", "test:single": "nx run api:test --test-file object.helper.spec.ts", "test:ui": "npx dotenv-cli -e .env.example -- nx test ui", "ts-node": "ts-node", @@ -128,6 +135,7 @@ "passport-headerapikey": "1.2.2", "passport-jwt": "4.0.1", "passport-openidconnect": "0.1.2", + "railway": "^2.0.17", "reflect-metadata": "0.2.2", "rxjs": "7.8.1", "stripe": "20.3.0", diff --git a/railway.toml b/railway.toml new file mode 100644 index 000000000..edc96df9c --- /dev/null +++ b/railway.toml @@ -0,0 +1,13 @@ +[build] +builder = "NIXPACKS" + +[deploy] +startCommand = "node main.js" +healthcheckPath = "/api/v1/health" +healthcheckTimeout = 300 +restartPolicyType = "ON_FAILURE" +restartPolicyMaxRetries = 10 + +[env] +NODE_ENV = "production" +PORT = "3333"