-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
73 lines (59 loc) · 2.12 KB
/
Dockerfile
File metadata and controls
73 lines (59 loc) · 2.12 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
66
67
68
69
70
71
72
73
FROM python:3.11-slim
# Install system dependencies
RUN apt-get update && apt-get install -y \
ffmpeg \
python3-dev \
build-essential \
libpq-dev \
curl \
wget \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install yt-dlp directly to avoid relying on runtime installation
RUN mkdir -p /app/bin && \
(curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /app/bin/yt-dlp || \
wget https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -O /app/bin/yt-dlp) && \
chmod a+rx /app/bin/yt-dlp && \
ln -sf /app/bin/yt-dlp /usr/local/bin/yt-dlp && \
ln -sf /app/bin/yt-dlp /usr/bin/yt-dlp
# Verify yt-dlp installation
RUN /app/bin/yt-dlp --version || echo "yt-dlp not installed correctly"
# Create a wrapper script for yt-dlp that tries multiple locations
RUN echo '#!/bin/bash\n\
if [ -x "/app/bin/yt-dlp" ]; then\n\
exec /app/bin/yt-dlp "$@"\n\
elif [ -x "/usr/local/bin/yt-dlp" ]; then\n\
exec /usr/local/bin/yt-dlp "$@"\n\
elif [ -x "/opt/stacks/nickclips/bin/yt-dlp" ]; then\n\
exec /opt/stacks/nickclips/bin/yt-dlp "$@"\n\
else\n\
echo "Error: yt-dlp not found in standard locations" >&2\n\
exit 1\n\
fi' > /app/bin/yt-dlp-wrapper && \
chmod a+rx /app/bin/yt-dlp-wrapper && \
ln -sf /app/bin/yt-dlp-wrapper /usr/local/bin/yt-dlp-wrapper
# Add bin directory to PATH
ENV PATH="/app/bin:${PATH}"
# Set working directory
WORKDIR /app
# Copy requirements file
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY . .
# Create necessary directories
RUN mkdir -p uploads/original uploads/processed uploads/thumbnails uploads/hls && \
chmod -R 755 uploads
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV FLASK_APP=main.py
# Expose port
EXPOSE 5000
# Create startup script
RUN echo '#!/bin/bash\npython migrations.py\ngunicorn --bind 0.0.0.0:5000 --workers 4 main:app' > /app/start.sh && \
chmod +x /app/start.sh
# Run the application with migrations
CMD ["/app/start.sh"]