# Copyright (C) 2018-2026 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

ARG REGISTRY="docker.io"
FROM ${REGISTRY}/library/ubuntu:22.04

USER root

# APT configuration
RUN echo 'Acquire::Retries "10";' > /etc/apt/apt.conf && \
    echo 'APT::Get::Assume-Yes "true";' >> /etc/apt/apt.conf && \
    echo 'APT::Get::Fix-Broken "true";' >> /etc/apt/apt.conf && \
    echo 'APT::Get::no-install-recommends "true";' >> /etc/apt/apt.conf

ENV DEBIAN_FRONTEND="noninteractive" \
    TZ="Europe/London"

RUN apt-get update && \
    apt-get install software-properties-common && \
    add-apt-repository --yes --no-update ppa:git-core/ppa && \
    add-apt-repository --yes --no-update ppa:deadsnakes/ppa && \
    apt-get update && \
    apt-get install \
    curl \
    git \
    gpg-agent \
    tzdata \
    # parallel gzip
    pigz \
    # Python
    python3.15-nogil \
    python3.15-venv \
    python3.15-dev \
    && \
    rm -rf /var/lib/apt/lists/*

# Install openvino dependencies
ADD scripts/install_dependencies/install_openvino_dependencies.sh /install_openvino_dependencies.sh
RUN chmod +x /install_openvino_dependencies.sh && \
    /install_openvino_dependencies.sh && \
    rm -rf /var/lib/apt/lists/*

# Setup pip
ENV PIP_VERSION="24.0"
# pip 24.0 is incompatible with Python 3.15 (abstract importlib.metadata Distribution.locate_file)
ENV PIP_VERSION_PY315="26.2.1"
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && \
    python3 get-pip.py --no-cache-dir pip==${PIP_VERSION} && \
    python3.15t get-pip.py --no-cache-dir pip==${PIP_VERSION_PY315} && \
    rm -f get-pip.py

# Use Python 3.15 free-threading as default instead of Python 3.10
# Using venv here 'cause other methods to switch the default Python on Ubuntu 22 break both system and wheels build
RUN python3.15t -m venv venv
ENV PATH="/venv/bin:$PATH"

ENV PIP_INSTALL_PATH=/venv/lib/python3.15t/site-packages
