FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY . .
RUN dotnet restore
RUN dotnet publish -c Release -o /app

FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY --from=build /app .

RUN apt-get update && \
    apt-get install -y python3-pip && \
    pip3 install yt-dlp && \
    mkdir /app/temp && \
    chmod 777 /app/temp && \
    which yt-dlp || (echo "yt-dlp not found" && exit 1)

EXPOSE 80
ENTRYPOINT ["dotnet", "YTExtractor.dll"]