Browse Source

chore: add Railway deploy config and production agent URL

- Add railway.json pointing to Dockerfile (explicit build config)
- Add agentUrl to GfEnvironment interface
- Dev: agentUrl = '/agent' (proxied through Angular dev server)
- Prod: agentUrl = 'https://ghostfolio-agent-production.up.railway.app'
- Inject GF_ENVIRONMENT into GfAiChatComponent constructor

Co-authored-by: Cursor <cursoragent@cursor.com>
pull/6453/head
Priyanka Punukollu 1 month ago
parent
commit
cb9fd55aef
  1. 16
      apps/client/src/app/components/ai-chat/ai-chat.component.ts
  2. 1
      apps/client/src/environments/environment.prod.ts
  3. 1
      apps/client/src/environments/environment.ts
  4. 1
      libs/ui/src/lib/environment/environment.interface.ts
  5. 14
      railway.json

16
apps/client/src/app/components/ai-chat/ai-chat.component.ts

@ -3,12 +3,15 @@ import {
ChangeDetectorRef, ChangeDetectorRef,
Component, Component,
ElementRef, ElementRef,
Inject,
OnDestroy, OnDestroy,
ViewChild ViewChild
} from '@angular/core'; } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms'; import { FormsModule } from '@angular/forms';
import { HttpClient, HttpClientModule } from '@angular/common/http'; import { HttpClient, HttpClientModule } from '@angular/common/http';
import { GfEnvironment } from '@ghostfolio/ui/environment';
import { GF_ENVIRONMENT } from '@ghostfolio/ui/environment';
import { AiMarkdownPipe } from './ai-markdown.pipe'; import { AiMarkdownPipe } from './ai-markdown.pipe';
@ -51,13 +54,18 @@ export class GfAiChatComponent implements OnDestroy {
private pendingWrite: Record<string, unknown> | null = null; private pendingWrite: Record<string, unknown> | null = null;
public awaitingConfirmation = false; public awaitingConfirmation = false;
private readonly AGENT_URL = '/agent/chat'; private readonly AGENT_URL: string;
private readonly FEEDBACK_URL = '/agent/feedback'; private readonly FEEDBACK_URL: string;
public constructor( public constructor(
private changeDetectorRef: ChangeDetectorRef, private changeDetectorRef: ChangeDetectorRef,
private http: HttpClient private http: HttpClient,
) {} @Inject(GF_ENVIRONMENT) environment: GfEnvironment
) {
const base = (environment.agentUrl ?? '/agent').replace(/\/$/, '');
this.AGENT_URL = `${base}/chat`;
this.FEEDBACK_URL = `${base}/feedback`;
}
public ngOnDestroy() {} public ngOnDestroy() {}

1
apps/client/src/environments/environment.prod.ts

@ -1,6 +1,7 @@
import type { GfEnvironment } from '@ghostfolio/ui/environment'; import type { GfEnvironment } from '@ghostfolio/ui/environment';
export const environment: GfEnvironment = { export const environment: GfEnvironment = {
agentUrl: 'https://ghostfolio-agent-production.up.railway.app',
lastPublish: '{BUILD_TIMESTAMP}', lastPublish: '{BUILD_TIMESTAMP}',
production: true production: true
}; };

1
apps/client/src/environments/environment.ts

@ -5,6 +5,7 @@ import type { GfEnvironment } from '@ghostfolio/ui/environment';
// The list of file replacements can be found in `angular.json`. // The list of file replacements can be found in `angular.json`.
export const environment: GfEnvironment = { export const environment: GfEnvironment = {
agentUrl: '/agent',
lastPublish: null, lastPublish: null,
production: false production: false
}; };

1
libs/ui/src/lib/environment/environment.interface.ts

@ -1,4 +1,5 @@
export interface GfEnvironment { export interface GfEnvironment {
agentUrl?: string;
lastPublish: string | null; lastPublish: string | null;
production: boolean; production: boolean;
} }

14
railway.json

@ -0,0 +1,14 @@
{
"$schema": "https://railway.com/railway.schema.json",
"build": {
"builder": "DOCKERFILE",
"dockerfilePath": "Dockerfile"
},
"deploy": {
"startCommand": "/ghostfolio/entrypoint.sh",
"healthcheckPath": "/api/v1/health",
"healthcheckTimeout": 300,
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 5
}
}
Loading…
Cancel
Save