Update Dockerfile
Browse files- Dockerfile +4 -24
Dockerfile
CHANGED
|
@@ -1,46 +1,26 @@
|
|
| 1 |
FROM python:3.10
|
| 2 |
WORKDIR /app
|
| 3 |
|
|
|
|
| 4 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 5 |
ffmpeg curl ca-certificates && \
|
| 6 |
curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
|
| 7 |
apt-get install -y nodejs && \
|
| 8 |
apt-get clean && rm -rf /var/lib/apt/lists/*
|
| 9 |
|
| 10 |
-
|
| 11 |
-
# Create a non-root user for security
|
| 12 |
-
# Using uid 1000 which is common
|
| 13 |
RUN useradd -m -u 1000 appuser
|
| 14 |
-
|
| 15 |
-
# Copy requirements first to leverage Docker cache
|
| 16 |
COPY requirements.txt .
|
| 17 |
|
| 18 |
-
# Install Python dependencies
|
| 19 |
RUN pip install --no-cache-dir --upgrade pip && \
|
| 20 |
pip install --no-cache-dir --pre -r requirements.txt && \
|
| 21 |
-
pip install --no-cache-dir --upgrade yt-dlp
|
|
|
|
| 22 |
|
| 23 |
-
# Copy the rest of the application files
|
| 24 |
-
# Make sure main.py and www.youtube.com_cookies.txt (if used) are in the build context
|
| 25 |
COPY . .
|
| 26 |
-
|
| 27 |
-
# Set permissions:
|
| 28 |
-
# - Directories: read/execute for all, write for owner (755)
|
| 29 |
-
# - Files: read for all, write for owner (644)
|
| 30 |
-
# - Change ownership to the non-root user
|
| 31 |
-
# Note: Explicit chmod for cookie file might be redundant if COPY respects source permissions, but doesn't hurt.
|
| 32 |
RUN find /app -type d -exec chmod 755 {} \; && \
|
| 33 |
find /app -type f -exec chmod 644 {} \; && \
|
| 34 |
chown -R appuser:appuser /app
|
| 35 |
|
| 36 |
-
# Switch to the non-root user
|
| 37 |
USER appuser
|
| 38 |
-
|
| 39 |
-
# Expose the port the app will run on (common for HF Spaces)
|
| 40 |
EXPOSE 7860
|
| 41 |
-
|
| 42 |
-
# Command to run the application using uvicorn
|
| 43 |
-
# - main:app -> finds the 'app' instance in the 'main.py' file
|
| 44 |
-
# - --host 0.0.0.0 -> makes the server accessible from outside the container
|
| 45 |
-
# - --port 7860 -> matches the EXPOSE directive
|
| 46 |
-
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 1 |
FROM python:3.10
|
| 2 |
WORKDIR /app
|
| 3 |
|
| 4 |
+
# Node.js 20 LTS (needed for EJS solver) + ffmpeg
|
| 5 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 6 |
ffmpeg curl ca-certificates && \
|
| 7 |
curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
|
| 8 |
apt-get install -y nodejs && \
|
| 9 |
apt-get clean && rm -rf /var/lib/apt/lists/*
|
| 10 |
|
|
|
|
|
|
|
|
|
|
| 11 |
RUN useradd -m -u 1000 appuser
|
|
|
|
|
|
|
| 12 |
COPY requirements.txt .
|
| 13 |
|
|
|
|
| 14 |
RUN pip install --no-cache-dir --upgrade pip && \
|
| 15 |
pip install --no-cache-dir --pre -r requirements.txt && \
|
| 16 |
+
pip install --no-cache-dir --upgrade "yt-dlp[default]"
|
| 17 |
+
# The [default] group pulls in yt-dlp-ejs automatically
|
| 18 |
|
|
|
|
|
|
|
| 19 |
COPY . .
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
RUN find /app -type d -exec chmod 755 {} \; && \
|
| 21 |
find /app -type f -exec chmod 644 {} \; && \
|
| 22 |
chown -R appuser:appuser /app
|
| 23 |
|
|
|
|
| 24 |
USER appuser
|
|
|
|
|
|
|
| 25 |
EXPOSE 7860
|
| 26 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|