From 96f3b1665dd5fb55dc579270823f440efe152bf2 Mon Sep 17 00:00:00 2001 From: Dev Singh Date: Thu, 4 Sep 2025 17:00:22 -0500 Subject: [PATCH 1/2] setup --- deployment/Caddyfile | 7 +++---- deployment/compose.yaml | 2 -- deployment/compose_cpu.yaml | 4 ++-- deployment/compose_cuda.yaml | 4 ++-- deployment/docker-autostart.sh | 12 +++--------- 5 files changed, 10 insertions(+), 19 deletions(-) diff --git a/deployment/Caddyfile b/deployment/Caddyfile index 45860ad..ce7f055 100644 --- a/deployment/Caddyfile +++ b/deployment/Caddyfile @@ -1,10 +1,9 @@ -${DOMAIN:localhost} { +{$DOMAIN} { handle /api/* { - reverse_proxy http://localhost:${NODE_PORT:8080} + reverse_proxy http://node-server:80 } handle { - reverse_proxy http://localhost:${FRONTEND_PORT:3000} - + reverse_proxy http://frontend:80 } } \ No newline at end of file diff --git a/deployment/compose.yaml b/deployment/compose.yaml index 943752a..2e95206 100644 --- a/deployment/compose.yaml +++ b/deployment/compose.yaml @@ -11,8 +11,6 @@ services: - caddy_data:/data - caddy_config:/config environment: - - FRONTEND_PORT=${FRONTEND_PORT} - - NODE_PORT=${NODE_PORT} - DOMAIN=${DOMAIN} volumes: diff --git a/deployment/compose_cpu.yaml b/deployment/compose_cpu.yaml index 00713e4..07e1e80 100644 --- a/deployment/compose_cpu.yaml +++ b/deployment/compose_cpu.yaml @@ -29,7 +29,7 @@ services: - SESSION_TOKEN_BYTES=${SESSION_TOKEN_BYTES} - SESSION_LENGTH_SEC=${SESSION_LENGTH_SEC} ports: - - ${NODE_PORT}:80 + - "80" restart: unless-stopped frontend: @@ -39,6 +39,6 @@ services: node-server: condition: service_healthy ports: - - ${FRONTEND_PORT}:80 + - "80" image: scribear/frontend:master restart: unless-stopped \ No newline at end of file diff --git a/deployment/compose_cuda.yaml b/deployment/compose_cuda.yaml index a3dd231..4db6e4b 100644 --- a/deployment/compose_cuda.yaml +++ b/deployment/compose_cuda.yaml @@ -39,7 +39,7 @@ services: - SESSION_TOKEN_BYTES=${SESSION_TOKEN_BYTES} - SESSION_LENGTH_SEC=${SESSION_LENGTH_SEC} ports: - - ${NODE_PORT}:80 + - "80" restart: unless-stopped frontend: @@ -49,6 +49,6 @@ services: node-server: condition: service_healthy ports: - - ${FRONTEND_PORT}:80 + - "80" image: scribear/frontend:master restart: unless-stopped \ No newline at end of file diff --git a/deployment/docker-autostart.sh b/deployment/docker-autostart.sh index 0606bc4..9a13479 100755 --- a/deployment/docker-autostart.sh +++ b/deployment/docker-autostart.sh @@ -16,20 +16,14 @@ else sudo docker compose -f compose.yaml -f ./compose_cpu.yaml up -d fi -until [ "$(curl --max-time 1 -s -w '%{http_code}' -o /dev/null "${SCRIBEAR_URL}")" -eq 200 ] +until [ "$(curl --max-time 1 -s -w '%{http_code}' -o /dev/null "${DOMAIN}")" -eq 200 ] do - echo "Can't reach frontend at ${SCRIBEAR_URL}. Waiting for frontend to be ready..." - sleep 1 -done - -until [ "$(curl --max-time 1 -s -w '%{http_code}' -o /dev/null "http://127.0.0.1:${FRONTEND_PORT}")" -eq 200 ] -do - echo "Can't reach frontend at http://127.0.0.1:${FRONTEND_PORT}. Waiting for frontend to be ready..." + echo "Can't reach frontend at ${DOMAIN}. Waiting for frontend to be ready..." sleep 1 done echo "Launching Chrome" -google-chrome "http://127.0.0.1:${FRONTEND_PORT}/?mode=kiosk&kioskServerAddress=localhost:${NODE_PORT}&sourceToken=${SOURCE_TOKEN}&scribearURL=${SCRIBEAR_URL}" --start-fullscreen +google-chrome "${DOMAIN}/?mode=kiosk&kioskServerAddress=localhost:${NODE_PORT}&sourceToken=${SOURCE_TOKEN}&scribearURL=${SCRIBEAR_URL}" --start-fullscreen stop_services() { if [ $WHISPER_SERVICE_CUDA = 'true' ]; then From 9b86a763ddaec0c070e9753cff71997c619450c7 Mon Sep 17 00:00:00 2001 From: Dev Singh Date: Thu, 4 Sep 2025 17:02:22 -0500 Subject: [PATCH 2/2] Fix linting --- node-server/src/server/create_server.ts | 15 +++++++-------- package-lock.json | 6 ++++++ 2 files changed, 13 insertions(+), 8 deletions(-) create mode 100644 package-lock.json diff --git a/node-server/src/server/create_server.ts b/node-server/src/server/create_server.ts index 1181eff..9b345de 100644 --- a/node-server/src/server/create_server.ts +++ b/node-server/src/server/create_server.ts @@ -1,7 +1,7 @@ -import Fastify, { type FastifyInstance } from 'fastify'; +import Fastify, {type FastifyInstance} from 'fastify'; import fastifyCors from '@fastify/cors'; -import type { ConfigType } from '../shared/config/config_schema.js'; -import type { Logger } from '../shared/logger/logger.js'; +import type {ConfigType} from '../shared/config/config_schema.js'; +import type {Logger} from '../shared/logger/logger.js'; import TranscriptionEngine from './services/transcription_engine.js'; import fastifyWebsocket from '@fastify/websocket'; import websocketHandler from './routes/websocket_handler.js'; @@ -30,7 +30,7 @@ declare module 'fastify' { * @returns created fastify server */ export default function createServer(config: ConfigType, logger: Logger) { - const fastify = Fastify({ loggerInstance: logger }) as unknown as FastifyInstance; + const fastify = Fastify({loggerInstance: logger}) as unknown as FastifyInstance; fastify.register(fastifyWebsocket); @@ -50,13 +50,12 @@ export default function createServer(config: ConfigType, logger: Logger) { fastify.decorate('authenticationService', new AuthenticationService(config, fastify.tokenService)); fastify.register( - async (api, _options) => { - api.register(websocketHandler,); + async api => { + api.register(websocketHandler); api.register(accessTokenHandler); api.register(healthcheckHandler); - }, - { prefix: "/api" }, + {prefix: '/api'}, ); return fastify; diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..4e77fcc --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "ScribeAR-NodeServer", + "lockfileVersion": 3, + "requires": true, + "packages": {} +}