FROM php:8.2-apache-bookworm

ENV TZ=Asia/Seoul \
    APP_ROOT=/var/www/it7/html \
    PY_VENV=/opt/it7-nvidia-venv

RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    python3 \
    python3-pip \
    python3-venv \
    ffmpeg \
    aria2 \
    curl \
    ca-certificates && \
    docker-php-ext-install mysqli && \
    python3 -m venv "${PY_VENV}" && \
    "${PY_VENV}/bin/pip" install --no-cache-dir --upgrade pip && \
    "${PY_VENV}/bin/pip" install --no-cache-dir yt-dlp websockets && \
    mkdir -p /var/www/it7/html && \
    rm -rf /var/www/html && \
    ln -s "${APP_ROOT}" /var/www/html && \
    a2enmod rewrite headers && \
    rm -rf /var/lib/apt/lists/*

WORKDIR /var/www/it7/html

CMD ["apache2-foreground"]
