-
Notifications
You must be signed in to change notification settings - Fork 458
[DRAFT] adding python313 dockerfile locally #4611
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lets name folder There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
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); | ||
} | ||
|
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 |
There was a problem hiding this comment.
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, isLocalThen 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
There was a problem hiding this comment.
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