-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
59 lines (46 loc) · 1.75 KB
/
Copy pathDockerfile
File metadata and controls
59 lines (46 loc) · 1.75 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
51
52
53
54
55
56
57
58
59
# Build a self-contained Next.js image with ffmpeg + yt-dlp.
FROM node:20-slim AS deps
WORKDIR /app
COPY package.json package-lock.json* ./
RUN npm install
FROM node:20-slim AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN npm run build
FROM node:20-slim AS runner
# ffmpeg for audio extraction, python3/pip for yt-dlp (and curl as fallback).
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg \
python3 \
python3-pip \
curl \
unzip \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# yt-dlp's YouTube extractor now expects a JS runtime; Deno is the only one it
# enables by default in recent releases.
RUN curl -fsSL https://deno.land/install.sh | DENO_INSTALL=/usr/local sh
# Install yt-dlp with its default extra so the EJS solver package is bundled.
# --break-system-packages needed on Debian bookworm (PEP 668).
RUN pip3 install --no-cache-dir --break-system-packages "yt-dlp[default]" curl_cffi
# Try to refresh yt-dlp at build time (best-effort; TikTok changes often).
RUN yt-dlp -U || true
WORKDIR /app
# `output: 'standalone'` traces only the node_modules this app actually
# needs, so the runner image doesn't carry the full install from `builder`.
# `npm run build` already copies public/ and .next/static into it.
COPY --from=builder /app/.next/standalone ./
# Persistent cache volume. Mount a disk here in production.
# CACHE_MAX_GB kept under Fly's 3GB free volume.
ENV CACHE_DIR=/app/cache
ENV DB_PATH=/app/cache/tikplay.json
ENV CACHE_TTL_DAYS=7
ENV CACHE_MAX_GB=2
ENV PORT=3000
ENV HOSTNAME=0.0.0.0
VOLUME ["/app/cache"]
EXPOSE 3000
# server.js (from `output: 'standalone'`) binds HOSTNAME/PORT itself — no
# need for `next start -H -p` flags.
CMD ["node", "server.js"]