Skip to content

Commit b42c093

Browse files
committed
update railway.toml
1 parent 5d31a74 commit b42c093

3 files changed

Lines changed: 16 additions & 29 deletions

File tree

Dockerfile

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,22 @@
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

63
WORKDIR /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)
1112
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
1213
COPY 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
1818
RUN 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-
2820
EXPOSE ${PORT:-8001}
2921

3022
CMD ["node", "packages/train-ai-worker/dist/main.js"]

packages/train-ai-worker/src/main.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,19 @@ import { NestFactory } from '@nestjs/core';
22
import { WorkerModule } from './worker.module';
33

44
async 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

1917
bootstrap().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+
});

0 commit comments

Comments
 (0)