Youtube-Transcript / Dockerfile
hamza2923's picture
Update Dockerfile
9ee640f verified
raw
history blame
1.97 kB
# Use Python 3.10 slim base image
FROM python:3.10-slim
# Environment variables to optimize Python
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Set working directory
WORKDIR /app
# Install dependencies, including those required for Google Chrome
RUN apt-get update && apt-get install -y \
wget \
curl \
unzip \
gnupg \
ca-certificates \
fonts-liberation \
libappindicator3-1 \
libasound2 \
libatk-bridge2.0-0 \
libatk1.0-0 \
libcups2 \
libdbus-1-3 \
libgdk-pixbuf2.0-0 \
libnspr4 \
libnss3 \
libx11-xcb1 \
libxcomposite1 \
libxdamage1 \
libxrandr2 \
xdg-utils \
libgbm1 \
libvulkan1 \
--no-install-recommends && \
rm -rf /var/lib/apt/lists/*
# Install Google Chrome stable
RUN wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \
dpkg -i google-chrome-stable_current_amd64.deb && \
apt-get -fy install && \
rm google-chrome-stable_current_amd64.deb
# Install ChromeDriver
RUN CHROME_VERSION=$(google-chrome --version | grep -oP '\d+\.\d+\.\d+' | head -1) && \
echo "Detected Chrome version: $CHROME_VERSION" && \
CHROMEDRIVER_VERSION=$(curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_VERSION%%.*}") && \
echo "Matching ChromeDriver version: $CHROMEDRIVER_VERSION" && \
wget -q -O /tmp/chromedriver.zip "https://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip" && \
unzip /tmp/chromedriver.zip -d /usr/local/bin/ && \
chmod +x /usr/local/bin/chromedriver && \
rm /tmp/chromedriver.zip
# Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY . /app
# Expose port for FastAPI
EXPOSE 7860
# Ensure ChromeDriver is in PATH
ENV PATH="/usr/local/bin:$PATH"
# Run FastAPI application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]