Skip to content

Commit

Permalink
Merge branch 'dev' into hot-fix-python
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitkumarr authored Aug 17, 2019
2 parents b7750e7 + f6f2809 commit 8f99a7e
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/Azure.Functions.Cli/Actions/LocalActions/InitAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public override async Task RunAsync()

private async Task InitDockerFileOnly()
{
await WriteDockerfile(GlobalCoreToolsSettings.CurrentWorkerRuntime);
await WriteDockerfile(GlobalCoreToolsSettings.CurrentWorkerRuntime, Csx);
}

private async Task InitFunctionAppProject()
Expand Down Expand Up @@ -181,7 +181,7 @@ private async Task InitFunctionAppProject()
}
if (InitDocker)
{
await WriteDockerfile(workerRuntime);
await WriteDockerfile(workerRuntime, Csx);
}
}

Expand Down Expand Up @@ -301,11 +301,18 @@ private static async Task WriteLocalSettingsJson(WorkerRuntime workerRuntime)
await WriteFiles("local.settings.json", localSettingsJsonContent);
}

private static async Task WriteDockerfile(WorkerRuntime workerRuntime)
private static async Task WriteDockerfile(WorkerRuntime workerRuntime, bool csx)
{
if (workerRuntime == Helpers.WorkerRuntime.dotnet)
{
await WriteFiles("Dockerfile", await StaticResources.DockerfileDotNet);
if (csx)
{
await WriteFiles("Dockerfile", await StaticResources.DockerfileCsxDotNet);
}
else
{
await WriteFiles("Dockerfile", await StaticResources.DockerfileDotNet);
}
}
else if (workerRuntime == Helpers.WorkerRuntime.node)
{
Expand Down
6 changes: 6 additions & 0 deletions src/Azure.Functions.Cli/Azure.Functions.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
<EmbeddedResource Include="StaticResources\ExtensionsProj.csproj.template">
<LogicalName>$(AssemblyName).ExtensionsProj.csproj</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="StaticResources\Dockerfile.csx.dotnet">
<LogicalName>$(AssemblyName).Dockerfile.csx.dotnet</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="StaticResources\Dockerfile.dotnet">
<LogicalName>$(AssemblyName).Dockerfile.dotnet</LogicalName>
</EmbeddedResource>
Expand Down Expand Up @@ -112,6 +115,9 @@
<PackageReference Include="Microsoft.Azure.Functions.PowerShellWorker" Version="0.1.120-preview" />
<PackageReference Include="Microsoft.Azure.WebJobs.Script.WebHost" Version="2.0.12625" />
<PackageReference Include="Microsoft.Azure.Functions.PythonWorkerRunEnvironments" Version="1.0.0-beta20190816.7" />
<PackageReference Include="Microsoft.Azure.Functions.PowerShellWorker" Version="0.1.152-preview" />
<PackageReference Include="Microsoft.Azure.WebJobs.Script.WebHost" Version="2.0.12641" />
<PackageReference Include="Microsoft.Azure.Functions.PythonWorkerRunEnvironments" Version="1.0.0-beta20190816.7" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="YamlDotNet" Version="6.0.0" />
</ItemGroup>
Expand Down
5 changes: 5 additions & 0 deletions src/Azure.Functions.Cli/StaticResources/Dockerfile.csx.dotnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM mcr.microsoft.com/azure-functions/dotnet:2.0
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
AzureFunctionsJobHost__Logging__Console__IsEnabled=true

COPY . /home/site/wwwroot
2 changes: 2 additions & 0 deletions src/Azure.Functions.Cli/StaticResources/StaticResources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ private static async Task<string> GetValue(string name)

public static Task<string> DockerfileDotNet => GetValue("Dockerfile.dotnet");

public static Task<string> DockerfileCsxDotNet => GetValue("Dockerfile.csx.dotnet");

public static Task<string> DockerfilePython => GetValue("Dockerfile.python");

public static Task<string> DockerfileNode => GetValue("Dockerfile.node");
Expand Down
42 changes: 42 additions & 0 deletions test/Azure.Functions.Cli.Tests/E2E/InitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,25 @@ public Task init_with_Dockerfile(string workerRuntime)
}, _output);
}

[Fact]
public Task init_with_Dockerfile_for_csx()
{
return CliTester.Run(new RunConfiguration
{
Commands = new[] { $"init . --worker-runtime dotnet --docker --csx" },
CheckFiles = new[]
{
new FileResult
{
Name = "Dockerfile",
ContentNotContains = new[] { "dotnet publish" },
ContentContains = new[] { $"FROM mcr.microsoft.com/azure-functions/dotnet:2.0" }
}
},
OutputContains = new[] { "Dockerfile" }
}, _output);
}

[Fact]
public Task init_csx_app()
{
Expand Down Expand Up @@ -293,6 +312,29 @@ public Task init_docker_only_for_existing_project(string workerRuntime)
}, _output);
}

[Fact]
public Task init_docker_only_for_csx_project()
{
return CliTester.Run(new RunConfiguration
{
Commands = new[]
{
$"init . --worker-runtime dotnet --csx",
$"init . --docker-only --csx",
},
CheckFiles = new[]
{
new FileResult
{
Name = "Dockerfile",
ContentNotContains = new[] { "dotnet publish" },
ContentContains = new[] { $"FROM mcr.microsoft.com/azure-functions/dotnet:2.0" }
}
},
OutputContains = new[] { "Dockerfile" }
}, _output);
}

[Fact]
public Task init_docker_only_no_project()
{
Expand Down

0 comments on commit 8f99a7e

Please sign in to comment.