I have an Azure Functions project built with .NET 6 that is currently running on Kubernetes with a Debian-based OS. I’m migrating this project to .NET 8 and need it to run on an Alpine machine. I’ve updated all my code to follow the .NET 8 isolated worker model, and everything works fine locally and with a specific Dockerfile setup:
FROM mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated8.0 AS base
WORKDIR /home/site/wwwroot
EXPOSE 8080
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["Project/Project.csproj", "Project/"]
RUN dotnet restore "./Project/Project.csproj"
COPY . .
WORKDIR "/src/Project"
RUN dotnet build "./Project.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./Project.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /home/site/wwwroot
COPY --from=publish /app/publish .
ENV AzureWebJobsScriptRoot=/home/site/wwwroot
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
However, the issue is that the operating system in this setup is Debian, but I need it to run on Alpine. When I try to modify the Dockerfile for Alpine, the project fails to work.
#Parameters
ARG dotnetsdkversionalpine=8.0.401-alpine3.20
WORKDIR /src
# Build stage
FROM mcr.microsoft.com/dotnet/sdk:$dotnetsdkversionalpine AS build
WORKDIR /src
RUN apk add --no-cache bash wget
# Verify dotnet is available
RUN dotnet --version
# Copy the project file and restore dependencies
WORKDIR /src
COPY Project/Project.csproj Project/
RUN dotnet restore Project/Project.csproj
# Copy the rest of the files and build the project
COPY . .
WORKDIR "/src/Project"
RUN dotnet build Project.csproj -c Release -o /app/build
# Publish the application
RUN dotnet publish Project.csproj -c Release -o /app/publish /p:UseAppHost=false
# Final stage using the base image
FROM mcr.microsoft.com/dotnet/sdk:$dotnetsdkversionalpin AS final
WORKDIR /home/site/wwwroot
COPY --from=build /app/publish .
ENV AzureWebJobsScriptRoot=/home/site/wwwroot
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
AzureWebJobsSecretStorageType=Files
FUNCTIONS_WORKER_RUNTIME=dotnet-isolated
FUNCTIONS_SECRETS_PATH=/home/site/wwwroot
Is it possible to run my Azure Functions (which are now compatible with the .NET 8 isolated worker model) on Alpine? If so, how can I achieve this?