-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (39 loc) · 1.48 KB
/
Dockerfile
File metadata and controls
51 lines (39 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Stage 1: Build Next.js frontend
FROM node:20-alpine AS frontend-builder
WORKDIR /app/frontend
COPY frontend/package.json frontend/package-lock.json ./
RUN npm ci
COPY frontend/ .
# Temporarily override distDir to build locally (Turbopack doesn't allow ../ paths)
RUN sed -i "s|distDir: '../dist-frontend'|distDir: 'out'|g" next.config.ts
RUN npm run build
# Copy build output to the expected location (/app/dist-frontend)
RUN mkdir -p /app/dist-frontend && cp -r out/* /app/dist-frontend/
# Stage 2: Build backend
FROM node:20-alpine AS backend-builder
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY src/ ./src/
COPY tsconfig.json ./
RUN npm run build:backend
# Stage 3: Runtime (slim image with Node + Python + yt-dlp + ffmpeg)
FROM node:20-alpine
# Install Python, pip, ffmpeg, and other essentials
RUN apk add --no-cache python3 py3-pip ffmpeg
# Install yt-dlp via pip (latest version)
# Using --break-system-packages is safe in a container environment
RUN pip3 install --no-cache-dir --break-system-packages yt-dlp
WORKDIR /app
# Copy package files
COPY package.json package-lock.json ./
# Install production dependencies only
RUN npm ci --only=production
# Copy built backend from builder
COPY --from=backend-builder /app/dist ./dist
# Copy built frontend from builder (frontend builds to ../dist-frontend relative to frontend dir)
COPY --from=frontend-builder /app/dist-frontend ./dist-frontend
# Expose port (Railway uses $PORT)
EXPOSE 3000
# Start command
CMD ["npm", "start"]