File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- FROM node:18-alpine AS base
2-
3- RUN apk update && apk add --no-cache yt-dlp ffmpeg
4- RUN corepack enable && corepack prepare pnpm@9.15.4 --activate
1+ FROM node:18-alpine
52
63WORKDIR /app
74
8- # ── Install dependencies ──────────────────────────────────────────────
9- FROM base AS deps
5+ # Optional runtime deps (used by `packages/train-ai-worker/src/processor/utils/yt-dlp.ts`)
6+ RUN apk update && apk add --no-cache yt-dlp ffmpeg
7+
8+ # Enable pnpm (repo uses pnpm workspaces)
9+ RUN corepack enable && corepack prepare pnpm@9.15.4 --activate
1010
11+ # Install dependencies (workspace)
1112COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
1213COPY packages ./packages
13- RUN pnpm install --frozen-lockfile
1414
15- # ── Build the worker ──────────────────────────────────────────────────
16- FROM deps AS build
15+ RUN pnpm install --frozen-lockfile
1716
17+ # Build the worker and its workspace dependencies
1818RUN pnpm --filter @repo/train-ai-worker... build
1919
20- # ── Production image ──────────────────────────────────────────────────
21- FROM base AS runner
22-
23- COPY --from=deps /app/node_modules ./node_modules
24- COPY --from=deps /app/packages ./packages
25- COPY --from=build /app/packages/train-ai-worker/dist ./packages/train-ai-worker/dist
26- COPY --from=deps /app/package.json ./
27-
2820EXPOSE ${PORT:-8001}
2921
3022CMD ["node" , "packages/train-ai-worker/dist/main.js" ]
File renamed without changes.
Original file line number Diff line number Diff line change @@ -2,24 +2,19 @@ import { NestFactory } from '@nestjs/core';
22import { WorkerModule } from './worker.module' ;
33
44async function bootstrap ( ) {
5- const app = await NestFactory . create ( WorkerModule , {
6- logger : [ 'error' , 'warn' , 'log' ] ,
7- } ) ;
8- await app . init ( ) ;
9- // Keep process alive forever
5+ const app = await NestFactory . create ( WorkerModule ) ;
6+ const port = process . env . PORT ?? 8001 ;
7+ await app . listen ( port ) ;
8+ console . log ( `Train AI Worker listening on : ${ port } ` ) ;
9+
1010 process . on ( 'SIGTERM' , async ( ) => {
11- console . log ( 'Shutting down gracefully... ' ) ;
11+ console . log ( 'SIGTERM received – shutting down gracefully… ' ) ;
1212 await app . close ( ) ;
1313 process . exit ( 0 ) ;
1414 } ) ;
15-
16- console . log ( 'Train AI Worker initialized successfully' ) ;
1715}
1816
1917bootstrap ( ) . catch ( ( error ) => {
2018 console . error ( 'Failed to start Train AI Worker:' , error ) ;
2119 process . exit ( 1 ) ;
22- } ) ;
23-
24- export const handler = bootstrap ;
25- export default bootstrap ;
20+ } ) ;
You can’t perform that action at this time.
0 commit comments