-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
52 lines (37 loc) · 1.21 KB
/
Copy pathDockerfile
File metadata and controls
52 lines (37 loc) · 1.21 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
# Base image with Node.js and Python
FROM node:20-alpine AS builder
# Install Python (for yt-dlp) and necessary dependencies
RUN apk add --no-cache python3 py3-pip ffmpeg
# Set working directory
WORKDIR /app
# Copy package.json and install dependencies
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile
# Copy the rest of the app's code
COPY . .
# Install yt-dlp using pip inside the builder
RUN python3 -m venv /venv && \
/venv/bin/pip install yt-dlp
# Build the Next.js app
RUN yarn build
# -----------------------------------------
# Create a lightweight runtime container
# -----------------------------------------
FROM node:20-alpine
# Install Python in the runtime container
RUN apk add --no-cache python3 py3-pip ffmpeg
# Set working directory
WORKDIR /app
# Copy built files from builder stage
COPY --from=builder /app ./
# Install only production dependencies
RUN yarn install --frozen-lockfile --production
# Set up Python virtual environment with yt-dlp in runtime
RUN python3 -m venv /venv && \
/venv/bin/pip install yt-dlp
# Ensure the Python environment is used
ENV PATH="/venv/bin:$PATH"
# Expose the port Next.js runs on
EXPOSE 3000
# Start the Next.js app
CMD ["yarn", "start"]