Skip to content

Commit

Permalink
Update docker images v4 (#3072)
Browse files Browse the repository at this point in the history
* Update docker images for Functions V4

* Remove Python 3.6 Dockerfile and add Java Dockerfile to .csproj

* Update Python 3.7 Dockerfile and add Java and PowerShell versions

* Corrected expected output for InitTests
  • Loading branch information
michaelpeng36 authored Jun 13, 2022
1 parent 1080324 commit 587e44b
Show file tree
Hide file tree
Showing 17 changed files with 93 additions and 56 deletions.
4 changes: 2 additions & 2 deletions src/Azure.Functions.Cli/Actions/LocalActions/InitAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
{
Expand Down
35 changes: 22 additions & 13 deletions src/Azure.Functions.Cli/Azure.Functions.Cli.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk" InitialTargets="ExcludeWorkersFromReadyToRun">
<Project Sdk="Microsoft.NET.Sdk" InitialTargets="ExcludeWorkersFromReadyToRun">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
Expand Down Expand Up @@ -55,23 +55,32 @@
<EmbeddedResource Include="StaticResources\Dockerfile.dotnetIsolated">
<LogicalName>$(AssemblyName).Dockerfile.dotnetIsolated</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="StaticResources\Dockerfile.python36">
<LogicalName>$(AssemblyName).Dockerfile.python36</LogicalName>
<EmbeddedResource Include="StaticResources\Dockerfile.java8">
<LogicalName>$(AssemblyName).Dockerfile.java8</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="StaticResources\Dockerfile.python37">
<LogicalName>$(AssemblyName).Dockerfile.python37</LogicalName>
<EmbeddedResource Include="StaticResources\Dockerfile.java11">
<LogicalName>$(AssemblyName).Dockerfile.java11</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="StaticResources\Dockerfile.python38">
<LogicalName>$(AssemblyName).Dockerfile.python38</LogicalName>
<EmbeddedResource Include="StaticResources\Dockerfile.node14">
<LogicalName>$(AssemblyName).Dockerfile.node14</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="StaticResources\Dockerfile.python39">
<LogicalName>$(AssemblyName).Dockerfile.python39</LogicalName>
<EmbeddedResource Include="StaticResources\Dockerfile.node16">
<LogicalName>$(AssemblyName).Dockerfile.node16</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="StaticResources\Dockerfile.powershell">
<LogicalName>$(AssemblyName).Dockerfile.powershell</LogicalName>
<EmbeddedResource Include="StaticResources\Dockerfile.powershell7">
<LogicalName>$(AssemblyName).Dockerfile.powershell7</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="StaticResources\Dockerfile.node">
<LogicalName>$(AssemblyName).Dockerfile.node</LogicalName>
<EmbeddedResource Include="StaticResources\Dockerfile.powershell7.2">
<LogicalName>$(AssemblyName).Dockerfile.powershell7.2</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="StaticResources\Dockerfile.python3.7">
<LogicalName>$(AssemblyName).Dockerfile.python3.7</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="StaticResources\Dockerfile.python3.8">
<LogicalName>$(AssemblyName).Dockerfile.python3.8</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="StaticResources\Dockerfile.python3.9">
<LogicalName>$(AssemblyName).Dockerfile.python3.9</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="StaticResources\Dockerfile.typescript">
<LogicalName>$(AssemblyName).Dockerfile.typescript</LogicalName>
Expand Down
4 changes: 1 addition & 3 deletions src/Azure.Functions.Cli/Helpers/PythonHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,6 @@ public static Task<string> GetDockerInitFileContent(WorkerLanguageVersionInfo in
{
switch (info?.Minor)
{
case 6:
return StaticResources.DockerfilePython36;
case 7:
return StaticResources.DockerfilePython37;
case 8:
Expand All @@ -501,7 +499,7 @@ public static Task<string> GetDockerInitFileContent(WorkerLanguageVersionInfo in
return StaticResources.DockerfilePython39;
}
}
return StaticResources.DockerfilePython36;
return StaticResources.DockerfilePython37;
}

private static string GetBuildNativeDepsEnvironmentImage(WorkerLanguageVersionInfo info)
Expand Down
4 changes: 2 additions & 2 deletions src/Azure.Functions.Cli/StaticResources/Dockerfile.csx.dotnet
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 1 addition & 2 deletions src/Azure.Functions.Cli/StaticResources/Dockerfile.custom
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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 && \
Expand All @@ -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
Expand Down
18 changes: 18 additions & 0 deletions src/Azure.Functions.Cli/StaticResources/Dockerfile.java8
Original file line number Diff line number Diff line change
@@ -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"]
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/Azure.Functions.Cli/StaticResources/Dockerfile.typescript
Original file line number Diff line number Diff line change
@@ -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
Expand Down
18 changes: 12 additions & 6 deletions src/Azure.Functions.Cli/StaticResources/StaticResources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,23 @@ private static async Task<string> GetValue(string name)

public static Task<string> DockerfileDotnetIsolated => GetValue("Dockerfile.dotnetIsolated");

public static Task<string> DockerfilePython36 => GetValue("Dockerfile.python36");
public static Task<string> DockerfileJava8 => GetValue("Dockerfile.java8");

public static Task<string> DockerfilePython37 => GetValue("Dockerfile.python37");
public static Task<string> DockerfileJava11 => GetValue("Dockerfile.java11");

public static Task<string> DockerfilePython38 => GetValue("Dockerfile.python38");
public static Task<string> DockerfilePython37 => GetValue("Dockerfile.python3.7");

public static Task<string> DockerfilePython39 => GetValue("Dockerfile.python39");
public static Task<string> DockerfilePython38 => GetValue("Dockerfile.python3.8");

public static Task<string> DockerfilePowershell => GetValue("Dockerfile.powershell");
public static Task<string> DockerfilePython39 => GetValue("Dockerfile.python3.9");

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

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

public static Task<string> DockerfileNode14 => GetValue("Dockerfile.node14");

public static Task<string> DockerfileNode16 => GetValue("Dockerfile.node16");

public static Task<string> DockerfileTypescript => GetValue("Dockerfile.typescript");

Expand Down
16 changes: 8 additions & 8 deletions test/Azure.Functions.Cli.Tests/E2E/InitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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" }
Expand Down Expand Up @@ -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" }
Expand Down Expand Up @@ -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"
}
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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" }
Expand Down

0 comments on commit 587e44b

Please sign in to comment.