diff --git a/src/Azure.Functions.Cli/Actions/LocalActions/InitAction.cs b/src/Azure.Functions.Cli/Actions/LocalActions/InitAction.cs index 6dadcee48..2771d1281 100644 --- a/src/Azure.Functions.Cli/Actions/LocalActions/InitAction.cs +++ b/src/Azure.Functions.Cli/Actions/LocalActions/InitAction.cs @@ -342,7 +342,7 @@ private static async Task WriteDockerfile(WorkerRuntime workerRuntime, string la } else { - await WriteFiles("Dockerfile", await StaticResources.DockerfileNode); + await WriteFiles("Dockerfile", await StaticResources.DockerfileNode16); } } else if (workerRuntime == Helpers.WorkerRuntime.python) @@ -351,7 +351,7 @@ private static async Task WriteDockerfile(WorkerRuntime workerRuntime, string la } else if (workerRuntime == Helpers.WorkerRuntime.powershell) { - await WriteFiles("Dockerfile", await StaticResources.DockerfilePowershell); + await WriteFiles("Dockerfile", await StaticResources.DockerfilePowershell7); } else if(workerRuntime == Helpers.WorkerRuntime.custom) { diff --git a/src/Azure.Functions.Cli/Azure.Functions.Cli.csproj b/src/Azure.Functions.Cli/Azure.Functions.Cli.csproj index a8c22148d..15bcedae4 100644 --- a/src/Azure.Functions.Cli/Azure.Functions.Cli.csproj +++ b/src/Azure.Functions.Cli/Azure.Functions.Cli.csproj @@ -1,4 +1,4 @@ - + Exe net6.0 @@ -55,23 +55,32 @@ $(AssemblyName).Dockerfile.dotnetIsolated - - $(AssemblyName).Dockerfile.python36 + + $(AssemblyName).Dockerfile.java8 - - $(AssemblyName).Dockerfile.python37 + + $(AssemblyName).Dockerfile.java11 - - $(AssemblyName).Dockerfile.python38 + + $(AssemblyName).Dockerfile.node14 - - $(AssemblyName).Dockerfile.python39 + + $(AssemblyName).Dockerfile.node16 - - $(AssemblyName).Dockerfile.powershell + + $(AssemblyName).Dockerfile.powershell7 - - $(AssemblyName).Dockerfile.node + + $(AssemblyName).Dockerfile.powershell7.2 + + + $(AssemblyName).Dockerfile.python3.7 + + + $(AssemblyName).Dockerfile.python3.8 + + + $(AssemblyName).Dockerfile.python3.9 $(AssemblyName).Dockerfile.typescript diff --git a/src/Azure.Functions.Cli/Helpers/PythonHelpers.cs b/src/Azure.Functions.Cli/Helpers/PythonHelpers.cs index ea2fe3f60..9f5cc9eab 100644 --- a/src/Azure.Functions.Cli/Helpers/PythonHelpers.cs +++ b/src/Azure.Functions.Cli/Helpers/PythonHelpers.cs @@ -491,8 +491,6 @@ public static Task GetDockerInitFileContent(WorkerLanguageVersionInfo in { switch (info?.Minor) { - case 6: - return StaticResources.DockerfilePython36; case 7: return StaticResources.DockerfilePython37; case 8: @@ -501,7 +499,7 @@ public static Task GetDockerInitFileContent(WorkerLanguageVersionInfo in return StaticResources.DockerfilePython39; } } - return StaticResources.DockerfilePython36; + return StaticResources.DockerfilePython37; } private static string GetBuildNativeDepsEnvironmentImage(WorkerLanguageVersionInfo info) diff --git a/src/Azure.Functions.Cli/StaticResources/Dockerfile.csx.dotnet b/src/Azure.Functions.Cli/StaticResources/Dockerfile.csx.dotnet index 92af08d90..98f651082 100644 --- a/src/Azure.Functions.Cli/StaticResources/Dockerfile.csx.dotnet +++ b/src/Azure.Functions.Cli/StaticResources/Dockerfile.csx.dotnet @@ -1,6 +1,6 @@ # To enable ssh & remote debugging on app service change the base image to the one below -# FROM mcr.microsoft.com/azure-functions/dotnet:3.0-appservice -FROM mcr.microsoft.com/azure-functions/dotnet:3.0 +# FROM mcr.microsoft.com/azure-functions/dotnet:4-appservice +FROM mcr.microsoft.com/azure-functions/dotnet:4 ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ AzureFunctionsJobHost__Logging__Console__IsEnabled=true diff --git a/src/Azure.Functions.Cli/StaticResources/Dockerfile.custom b/src/Azure.Functions.Cli/StaticResources/Dockerfile.custom index 98c6fae97..21d3e12b9 100644 --- a/src/Azure.Functions.Cli/StaticResources/Dockerfile.custom +++ b/src/Azure.Functions.Cli/StaticResources/Dockerfile.custom @@ -1,5 +1,4 @@ -# To enable ssh & remote debugging on app service change the base image to the one below -FROM mcr.microsoft.com/azure-functions/dotnet:3.0-appservice +FROM mcr.microsoft.com/azure-functions/dotnet:4-appservice ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ AzureFunctionsJobHost__Logging__Console__IsEnabled=true diff --git a/src/Azure.Functions.Cli/StaticResources/Dockerfile.java b/src/Azure.Functions.Cli/StaticResources/Dockerfile.java11 similarity index 71% rename from src/Azure.Functions.Cli/StaticResources/Dockerfile.java rename to src/Azure.Functions.Cli/StaticResources/Dockerfile.java11 index e918ea7fe..7dee857f7 100644 --- a/src/Azure.Functions.Cli/StaticResources/Dockerfile.java +++ b/src/Azure.Functions.Cli/StaticResources/Dockerfile.java11 @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/azure-functions/java:3.0-java8-build AS installer-env +FROM mcr.microsoft.com/azure-functions/java:4-java11-build AS installer-env COPY . /src/java-function-app RUN cd /src/java-function-app && \ @@ -9,8 +9,8 @@ cp -a . /home/site/wwwroot # To enable ssh & remote debugging on app service change the base image to the one below -# FROM mcr.microsoft.com/azure-functions/java:3.0-java8-appservice -FROM mcr.microsoft.com/azure-functions/java:3.0-java8 +# FROM mcr.microsoft.com/azure-functions/java:4-java11-appservice +FROM mcr.microsoft.com/azure-functions/java:4-java11 ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ AzureFunctionsJobHost__Logging__Console__IsEnabled=true diff --git a/src/Azure.Functions.Cli/StaticResources/Dockerfile.java8 b/src/Azure.Functions.Cli/StaticResources/Dockerfile.java8 new file mode 100644 index 000000000..8dda0d28e --- /dev/null +++ b/src/Azure.Functions.Cli/StaticResources/Dockerfile.java8 @@ -0,0 +1,18 @@ +FROM mcr.microsoft.com/azure-functions/java:4-java8-build AS installer-env + +COPY . /src/java-function-app +RUN cd /src/java-function-app && \ + mkdir -p /home/site/wwwroot && \ + mvn clean package && \ + cd ./target/azure-functions/ && \ + cd $(ls -d */|head -n 1) && \ + cp -a . /home/site/wwwroot + +# To enable ssh & remote debugging on app service change the base image to the one below +# FROM mcr.microsoft.com/azure-functions/java:4-java8-appservice +FROM mcr.microsoft.com/azure-functions/java:4-java8 + +ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ + AzureFunctionsJobHost__Logging__Console__IsEnabled=true + +COPY --from=installer-env ["/home/site/wwwroot", "/home/site/wwwroot"] diff --git a/src/Azure.Functions.Cli/StaticResources/Dockerfile.node b/src/Azure.Functions.Cli/StaticResources/Dockerfile.node14 similarity index 69% rename from src/Azure.Functions.Cli/StaticResources/Dockerfile.node rename to src/Azure.Functions.Cli/StaticResources/Dockerfile.node14 index a330b5eec..2f09eb508 100644 --- a/src/Azure.Functions.Cli/StaticResources/Dockerfile.node +++ b/src/Azure.Functions.Cli/StaticResources/Dockerfile.node14 @@ -1,6 +1,6 @@ # To enable ssh & remote debugging on app service change the base image to the one below -# FROM mcr.microsoft.com/azure-functions/node:3.0-appservice -FROM mcr.microsoft.com/azure-functions/node:3.0 +# FROM mcr.microsoft.com/azure-functions/node:4-node14-appservice +FROM mcr.microsoft.com/azure-functions/node:4-node14 ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ AzureFunctionsJobHost__Logging__Console__IsEnabled=true diff --git a/src/Azure.Functions.Cli/StaticResources/Dockerfile.python36 b/src/Azure.Functions.Cli/StaticResources/Dockerfile.node16 similarity index 53% rename from src/Azure.Functions.Cli/StaticResources/Dockerfile.python36 rename to src/Azure.Functions.Cli/StaticResources/Dockerfile.node16 index 8cd399de6..38be8b570 100644 --- a/src/Azure.Functions.Cli/StaticResources/Dockerfile.python36 +++ b/src/Azure.Functions.Cli/StaticResources/Dockerfile.node16 @@ -1,11 +1,11 @@ # To enable ssh & remote debugging on app service change the base image to the one below -# FROM mcr.microsoft.com/azure-functions/python:3.0-python3.6-appservice -FROM mcr.microsoft.com/azure-functions/python:3.0-python3.6 +# FROM mcr.microsoft.com/azure-functions/node:4-node16-appservice +FROM mcr.microsoft.com/azure-functions/node:4-node16 ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ AzureFunctionsJobHost__Logging__Console__IsEnabled=true -COPY requirements.txt / -RUN pip install -r /requirements.txt - COPY . /home/site/wwwroot + +RUN cd /home/site/wwwroot && \ + npm install \ No newline at end of file diff --git a/src/Azure.Functions.Cli/StaticResources/Dockerfile.powershell b/src/Azure.Functions.Cli/StaticResources/Dockerfile.powershell7 similarity index 61% rename from src/Azure.Functions.Cli/StaticResources/Dockerfile.powershell rename to src/Azure.Functions.Cli/StaticResources/Dockerfile.powershell7 index 8fdd1ab16..13e9100bd 100644 --- a/src/Azure.Functions.Cli/StaticResources/Dockerfile.powershell +++ b/src/Azure.Functions.Cli/StaticResources/Dockerfile.powershell7 @@ -1,6 +1,6 @@ # To enable ssh & remote debugging on app service change the base image to the one below -# FROM mcr.microsoft.com/azure-functions/powershell:3.0-appservice -FROM mcr.microsoft.com/azure-functions/powershell:3.0 +# FROM mcr.microsoft.com/azure-functions/powershell:4-powershell7-appservice +FROM mcr.microsoft.com/azure-functions/powershell:4-powershell7 ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ AzureFunctionsJobHost__Logging__Console__IsEnabled=true diff --git a/src/Azure.Functions.Cli/StaticResources/Dockerfile.powershell7.2 b/src/Azure.Functions.Cli/StaticResources/Dockerfile.powershell7.2 new file mode 100644 index 000000000..425e38d81 --- /dev/null +++ b/src/Azure.Functions.Cli/StaticResources/Dockerfile.powershell7.2 @@ -0,0 +1,7 @@ +# To enable ssh & remote debugging on app service change the base image to the one below +# FROM mcr.microsoft.com/azure-functions/powershell:4-powershell7.2-appservice +FROM mcr.microsoft.com/azure-functions/powershell:4-powershell7.2 +ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ + AzureFunctionsJobHost__Logging__Console__IsEnabled=true + +COPY . /home/site/wwwroot diff --git a/src/Azure.Functions.Cli/StaticResources/Dockerfile.python37 b/src/Azure.Functions.Cli/StaticResources/Dockerfile.python3.7 similarity index 68% rename from src/Azure.Functions.Cli/StaticResources/Dockerfile.python37 rename to src/Azure.Functions.Cli/StaticResources/Dockerfile.python3.7 index 9880c4621..a211ae36c 100644 --- a/src/Azure.Functions.Cli/StaticResources/Dockerfile.python37 +++ b/src/Azure.Functions.Cli/StaticResources/Dockerfile.python3.7 @@ -1,6 +1,6 @@ # To enable ssh & remote debugging on app service change the base image to the one below -# FROM mcr.microsoft.com/azure-functions/python:3.0-python3.7-appservice -FROM mcr.microsoft.com/azure-functions/python:3.0-python3.7 +# FROM mcr.microsoft.com/azure-functions/python:4-python3.7-appservice +FROM mcr.microsoft.com/azure-functions/python:4-python3.7 ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ AzureFunctionsJobHost__Logging__Console__IsEnabled=true diff --git a/src/Azure.Functions.Cli/StaticResources/Dockerfile.python39 b/src/Azure.Functions.Cli/StaticResources/Dockerfile.python3.8 similarity index 68% rename from src/Azure.Functions.Cli/StaticResources/Dockerfile.python39 rename to src/Azure.Functions.Cli/StaticResources/Dockerfile.python3.8 index 04d2cf5cc..3d94c7ed5 100644 --- a/src/Azure.Functions.Cli/StaticResources/Dockerfile.python39 +++ b/src/Azure.Functions.Cli/StaticResources/Dockerfile.python3.8 @@ -1,6 +1,6 @@ # To enable ssh & remote debugging on app service change the base image to the one below -# FROM mcr.microsoft.com/azure-functions/python:3.0-python3.9-appservice -FROM mcr.microsoft.com/azure-functions/python:3.0-python3.9 +# FROM mcr.microsoft.com/azure-functions/python:4-python3.8-appservice +FROM mcr.microsoft.com/azure-functions/python:4-python3.8 ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ AzureFunctionsJobHost__Logging__Console__IsEnabled=true diff --git a/src/Azure.Functions.Cli/StaticResources/Dockerfile.python38 b/src/Azure.Functions.Cli/StaticResources/Dockerfile.python3.9 similarity index 68% rename from src/Azure.Functions.Cli/StaticResources/Dockerfile.python38 rename to src/Azure.Functions.Cli/StaticResources/Dockerfile.python3.9 index 247f690f5..a2be25d93 100644 --- a/src/Azure.Functions.Cli/StaticResources/Dockerfile.python38 +++ b/src/Azure.Functions.Cli/StaticResources/Dockerfile.python3.9 @@ -1,6 +1,6 @@ # To enable ssh & remote debugging on app service change the base image to the one below -# FROM mcr.microsoft.com/azure-functions/python:3.0-python3.8-appservice -FROM mcr.microsoft.com/azure-functions/python:3.0-python3.8 +# FROM mcr.microsoft.com/azure-functions/python:4-python3.9-appservice +FROM mcr.microsoft.com/azure-functions/python:4-python3.9 ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ AzureFunctionsJobHost__Logging__Console__IsEnabled=true diff --git a/src/Azure.Functions.Cli/StaticResources/Dockerfile.typescript b/src/Azure.Functions.Cli/StaticResources/Dockerfile.typescript index a3856316e..a4da9f1d4 100644 --- a/src/Azure.Functions.Cli/StaticResources/Dockerfile.typescript +++ b/src/Azure.Functions.Cli/StaticResources/Dockerfile.typescript @@ -1,6 +1,6 @@ # To enable ssh & remote debugging on app service change the base image to the one below -# FROM mcr.microsoft.com/azure-functions/node:3.0-appservice -FROM mcr.microsoft.com/azure-functions/node:3.0 +# FROM mcr.microsoft.com/azure-functions/node:4-node16-appservice +FROM mcr.microsoft.com/azure-functions/node:4-node16 ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ AzureFunctionsJobHost__Logging__Console__IsEnabled=true diff --git a/src/Azure.Functions.Cli/StaticResources/StaticResources.cs b/src/Azure.Functions.Cli/StaticResources/StaticResources.cs index e9f0b8cd3..65b320c34 100644 --- a/src/Azure.Functions.Cli/StaticResources/StaticResources.cs +++ b/src/Azure.Functions.Cli/StaticResources/StaticResources.cs @@ -37,17 +37,23 @@ private static async Task GetValue(string name) public static Task DockerfileDotnetIsolated => GetValue("Dockerfile.dotnetIsolated"); - public static Task DockerfilePython36 => GetValue("Dockerfile.python36"); + public static Task DockerfileJava8 => GetValue("Dockerfile.java8"); - public static Task DockerfilePython37 => GetValue("Dockerfile.python37"); + public static Task DockerfileJava11 => GetValue("Dockerfile.java11"); - public static Task DockerfilePython38 => GetValue("Dockerfile.python38"); + public static Task DockerfilePython37 => GetValue("Dockerfile.python3.7"); - public static Task DockerfilePython39 => GetValue("Dockerfile.python39"); + public static Task DockerfilePython38 => GetValue("Dockerfile.python3.8"); - public static Task DockerfilePowershell => GetValue("Dockerfile.powershell"); + public static Task DockerfilePython39 => GetValue("Dockerfile.python3.9"); - public static Task DockerfileNode => GetValue("Dockerfile.node"); + public static Task DockerfilePowershell7 => GetValue("Dockerfile.powershell7"); + + public static Task DockerfilePowershell72 => GetValue("Dockerfile.powershell7.2"); + + public static Task DockerfileNode14 => GetValue("Dockerfile.node14"); + + public static Task DockerfileNode16 => GetValue("Dockerfile.node16"); public static Task DockerfileTypescript => GetValue("Dockerfile.typescript"); diff --git a/test/Azure.Functions.Cli.Tests/E2E/InitTests.cs b/test/Azure.Functions.Cli.Tests/E2E/InitTests.cs index b83eca18c..46bdd2446 100644 --- a/test/Azure.Functions.Cli.Tests/E2E/InitTests.cs +++ b/test/Azure.Functions.Cli.Tests/E2E/InitTests.cs @@ -159,8 +159,8 @@ public Task init_with_no_source_control() [Theory] [InlineData("dotnet", "4")] - [InlineData("node", "3.0")] - [InlineData("powershell", "3.0")] + [InlineData("node", "4")] + [InlineData("powershell", "4")] public Task init_with_Dockerfile(string workerRuntime, string version) { return CliTester.Run(new RunConfiguration @@ -192,7 +192,7 @@ await CliTester.Run(new RunConfiguration new FileResult { Name = "Dockerfile", - ContentContains = new[] { $"FROM mcr.microsoft.com/azure-functions/python:3.0-python{worker.Major}.{worker.Minor}" } + ContentContains = new[] { $"FROM mcr.microsoft.com/azure-functions/python:4-python{worker.Major}.{worker.Minor}" } } }, OutputContains = new[] { "Dockerfile" } @@ -229,7 +229,7 @@ public Task init_with_Dockerfile_for_csx() { Name = "Dockerfile", ContentNotContains = new[] { "dotnet publish" }, - ContentContains = new[] { $"FROM mcr.microsoft.com/azure-functions/dotnet:3.0" } + ContentContains = new[] { $"FROM mcr.microsoft.com/azure-functions/dotnet:4" } } }, OutputContains = new[] { "Dockerfile" } @@ -302,7 +302,7 @@ public Task init_ts_app_using_lang(string initCommand) Name = "Dockerfile", ContentContains = new [] { - "mcr.microsoft.com/azure-functions/node:3.0", + "mcr.microsoft.com/azure-functions/node:4", "npm run build" } } @@ -384,8 +384,8 @@ public Task init_ts_app_using_runtime() [Theory] [InlineData("dotnet", "4")] - [InlineData("node", "3.0")] - [InlineData("powershell", "3.0")] + [InlineData("node", "4")] + [InlineData("powershell", "4")] public Task init_docker_only_for_existing_project(string workerRuntime, string version) { return CliTester.Run(new RunConfiguration @@ -423,7 +423,7 @@ public Task init_docker_only_for_csx_project() { Name = "Dockerfile", ContentNotContains = new[] { "dotnet publish" }, - ContentContains = new[] { $"FROM mcr.microsoft.com/azure-functions/dotnet:3.0" } + ContentContains = new[] { $"FROM mcr.microsoft.com/azure-functions/dotnet:4" } } }, OutputContains = new[] { "Dockerfile" }