Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Cli/func/Azure.Functions.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@
<EmbeddedResource Include="StaticResources\Dockerfile.python3.13">
<LogicalName>$(AssemblyName).Dockerfile.python3.13</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="StaticResources\Dockerfile.python313buildenv">
<LogicalName>$(AssemblyName).Dockerfile.python313buildenv</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="StaticResources\Dockerfile.javascript">
<LogicalName>$(AssemblyName).Dockerfile.javascript</LogicalName>
</EmbeddedResource>
Expand Down
16 changes: 14 additions & 2 deletions src/Cli/func/Helpers/PythonHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,20 @@ private static async Task RestorePythonRequirementsDocker(string functionAppRoot
dockerImage = await ChoosePythonBuildEnvImage();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this (ChoosePythonBuildEnvImage) should handle returning the local docker file name.

public const string LinuxPython313ImageAmd64 = "mcr.microsoft.com/azure-functions/python:4-python3.13-buildenv";

Can be replaced with something like local/python3.13-buildenv

ChoosePythonBuildEnvImage can be updated to return a tuple: imageName, isLocal

Then here below on line 503, we can check ifLocal = true and handle the image that way - this makes it more generic and not just for 313

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a quick thought - feel free to clean this up for something that makes more sense but the change should ensure we make these changes easy to expand on in future

}

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");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets name folder python313-buildenv-docker?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code in this block and be broken out into its own method i.e. BuildLocalDockerImage(imageName)

And find a way to connect image name to the static resource.

Code in here should be generic for any local build docker image and not just for DockerfilePython313buildenv

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);
}
Expand Down
43 changes: 43 additions & 0 deletions src/Cli/func/StaticResources/Dockerfile.python313buildenv
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions src/Cli/func/StaticResources/StaticResources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public static class StaticResources

public static Task<string> DockerfilePython313 => GetValue("Dockerfile.python3.13");

public static Task<string> DockerfilePython313buildenv => GetValue("Dockerfile.python313buildenv");

public static Task<string> DockerfilePowershell7 => GetValue("Dockerfile.powershell7");

public static Task<string> DockerfilePowershell72 => GetValue("Dockerfile.powershell7.2");
Expand Down