-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainerfile.python
More file actions
65 lines (49 loc) · 1.64 KB
/
Copy pathContainerfile.python
File metadata and controls
65 lines (49 loc) · 1.64 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
60
61
62
63
64
65
# Use Python 3.14 slim as base
FROM python:3.14-slim
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
ffmpeg \
curl \
ca-certificates \
quickjs \
unzip \
&& rm -rf /var/lib/apt/lists/*
# Install Deno (JS runtime for yt-dlp EJS solver)
ENV DENO_INSTALL=/usr/local
RUN curl -fsSL https://deno.land/install.sh | sh && \
ln -s /usr/local/bin/deno /usr/bin/deno
# Install yt-dlp (nightly to keep up with YouTube changes)
RUN pip install --no-cache-dir --upgrade --pre yt-dlp
# Install yt-dlp EJS challenge solver bundle
RUN mkdir -p /usr/share/yt-dlp/ejs && \
yt-dlp --skip-download \
--remote-components ejs:github \
--print-to-file ejs /usr/share/yt-dlp/ejs/solver.js \
https://www.youtube.com/watch?v=dQw4w9WgXcQ
# Install Poetry
RUN pip install --no-cache-dir poetry
# Configure Poetry: install into system, no virtualenv
ENV POETRY_NO_INTERACTION=1 \
POETRY_VENV_IN_PROJECT=0 \
POETRY_VIRTUALENVS_CREATE=false \
POETRY_CACHE_DIR=/tmp/poetry_cache
# Ensure yt-dlp can find JS runtimes
ENV PATH="/usr/local/bin:${PATH}"
# Set working directory
WORKDIR /app
# Copy dependency files
COPY pyproject.toml poetry.lock ./
# Install Python dependencies (without dev)
RUN poetry install --without dev --no-interaction && \
rm -rf $POETRY_CACHE_DIR
# Copy application code
COPY tools/ ./tools/
# Create non-root user
RUN useradd -m -u 1000 worker && \
chown -R worker:worker /app
# Switch to non-root user
USER worker
# Set working directory
WORKDIR /app
# Entrypoint
ENTRYPOINT ["poetry", "run", "python", "-m", "tools.downloader.worker"]