-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
43 lines (30 loc) · 1007 Bytes
/
Copy pathDockerfile
File metadata and controls
43 lines (30 loc) · 1007 Bytes
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
# Stage 1: Build
FROM node:18.20.8-bullseye AS builder
WORKDIR /app
# Only copy package files first to leverage cache
COPY package.json package-lock.json ./
# Use npm cache mount for speed
RUN --mount=type=cache,target=/root/.npm \
npm ci --no-audit
# Copy rest of source
COPY . .
# Run build (needs devDependencies)
RUN npm run build
# Stage 2: Production
FROM node:18.20.8-bullseye-slim
WORKDIR /app
# Install system dependencies needed at runtime
RUN apt-get update && apt-get install -y \
ffmpeg \
python3
RUN apt-get install -y python3-pip \
&& pip3 install yt-dlp \
&& rm -rf /var/lib/apt/lists/*
# Only copy package files first to leverage cache
COPY package.json package-lock.json ./
# Only production dependencies, with npm cache mount
RUN --mount=type=cache,target=/root/.npm \
npm ci --omit=dev --prefer-offline --no-audit
# Copy the bundled files from builder
COPY --from=builder /app/dist ./dist
ENV NODE_ENV=production