diff --git a/src/Cli/func/Azure.Functions.Cli.csproj b/src/Cli/func/Azure.Functions.Cli.csproj index 2843ab4e0..66e039c5e 100644 --- a/src/Cli/func/Azure.Functions.Cli.csproj +++ b/src/Cli/func/Azure.Functions.Cli.csproj @@ -98,6 +98,9 @@ $(AssemblyName).Dockerfile.python3.13 + + $(AssemblyName).Dockerfile.python313buildenv + $(AssemblyName).Dockerfile.javascript diff --git a/src/Cli/func/Helpers/PythonHelpers.cs b/src/Cli/func/Helpers/PythonHelpers.cs index 2afb69abe..809cb727e 100644 --- a/src/Cli/func/Helpers/PythonHelpers.cs +++ b/src/Cli/func/Helpers/PythonHelpers.cs @@ -500,8 +500,20 @@ private static async Task RestorePythonRequirementsDocker(string functionAppRoot dockerImage = await ChoosePythonBuildEnvImage(); } - if (string.IsNullOrEmpty(dockerSkipPullFlagSetting) || - !(dockerSkipPullFlagSetting.Equals("true", StringComparison.OrdinalIgnoreCase) || dockerSkipPullFlagSetting == "1")) + if (dockerImage == Constants.DockerImages.LinuxPython313ImageAmd64) + { + // creating temp folder for Dockerfile + string tempDir = Path.Combine(Path.GetTempPath(), "python313-docker"); + Directory.CreateDirectory(tempDir); + string tempDockerfile = Path.Combine(tempDir, "Dockerfile"); + + // Writing Dockerfile content using FileSystemHelpers + string dockerfileContent = await StaticResources.DockerfilePython313buildenv; + await FileSystemHelpers.WriteAllTextToFileAsync(tempDockerfile, dockerfileContent); + await DockerHelpers.DockerBuild(dockerImage, tempDir); + } + else if (string.IsNullOrEmpty(dockerSkipPullFlagSetting) || + !(dockerSkipPullFlagSetting.Equals("true", StringComparison.OrdinalIgnoreCase) || dockerSkipPullFlagSetting == "1")) { await DockerHelpers.DockerPull(dockerImage); } diff --git a/src/Cli/func/StaticResources/Dockerfile.python313buildenv b/src/Cli/func/StaticResources/Dockerfile.python313buildenv new file mode 100644 index 000000000..1f89826ec --- /dev/null +++ b/src/Cli/func/StaticResources/Dockerfile.python313buildenv @@ -0,0 +1,43 @@ +FROM mcr.microsoft.com/oryx/python:3.13-debian-bookworm-20250724.1 + +ENV LANG=C.UTF-8 \ + ACCEPT_EULA=Y \ + AzureWebJobsScriptRoot=/home/site/wwwroot \ + HOME=/home \ + FUNCTIONS_WORKER_RUNTIME=python \ + ASPNETCORE_URLS=http://+:80 \ + DOTNET_RUNNING_IN_CONTAINER=true \ + DOTNET_USE_POLLING_FILE_WATCHER=true + +# Install Python dependencies +RUN curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor --batch --yes -o /usr/share/keyrings/microsoft-prod.gpg && \ + apt-get update && \ + apt-get install -y wget apt-transport-https curl gnupg2 locales && \ + echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections && \ + echo "deb [arch=amd64] https://packages.microsoft.com/debian/12/prod bookworm main" | tee /etc/apt/sources.list.d/mssql-release.list && \ + # Needed for libss3 and in turn MS SQL + echo 'deb http://security.debian.org/debian-security bookworm-security main' >> /etc/apt/sources.list && \ + curl https://packages.microsoft.com/config/debian/12/prod.list | tee /etc/apt/sources.list.d/mssql-release.list && \ + # install MS SQL related packages.pinned version in PR # 1012. + echo 'en_US.UTF-8 UTF-8' > /etc/locale.gen && \ + locale-gen && \ + apt-get update && \ + # MS SQL related packages: unixodbc msodbcsql18 mssql-tools + ACCEPT_EULA=Y apt-get install -y unixodbc msodbcsql18 mssql-tools18 && \ + # OpenCV dependencies:libglib2.0-0 libsm6 libxext6 libxrender-dev xvfb + apt-get install -y libglib2.0-0 libsm6 libxext6 libxrender-dev xvfb && \ + # .NET Core dependencies: ca-certificates libc6 libgcc1 libgssapi-krb5-2 libicu72 libssl3 libstdc++6 zlib1g + # Azure ML dependencies: liblttng-ust0 + # OpenMP dependencies: libgomp1 + # binutils: binutils + apt-get install -y --no-install-recommends ca-certificates \ + libc6 libgcc1 libgssapi-krb5-2 libicu72 libssl3 libstdc++6 zlib1g && \ + apt-get install -y libglib2.0-0 libsm6 libxext6 libxrender-dev xvfb binutils \ + libgomp1 liblttng-ust1 && \ + rm -rf /var/lib/apt/lists/* + +RUN apt-get update && \ + apt-get install -y build-essential libssl-dev zlib1g-dev libbz2-dev \ + libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \ + xz-utils tk-dev libffi-dev liblzma-dev python3-openssl git unixodbc-dev dh-autoreconf \ + libcurl4-openssl-dev libssl-dev python3-dev libevent-dev python3-openssl squashfs-tools unzip \ No newline at end of file diff --git a/src/Cli/func/StaticResources/StaticResources.cs b/src/Cli/func/StaticResources/StaticResources.cs index 4bd7c0317..3f70f5311 100644 --- a/src/Cli/func/StaticResources/StaticResources.cs +++ b/src/Cli/func/StaticResources/StaticResources.cs @@ -48,6 +48,8 @@ public static class StaticResources public static Task DockerfilePython313 => GetValue("Dockerfile.python3.13"); + public static Task DockerfilePython313buildenv => GetValue("Dockerfile.python313buildenv"); + public static Task DockerfilePowershell7 => GetValue("Dockerfile.powershell7"); public static Task DockerfilePowershell72 => GetValue("Dockerfile.powershell7.2");