Browse Source

Added support for docker build arguments (#521)

* Added support for docker build arguments

* fixed whitespace issue? #511

* Additional tests

* Update src/Microsoft.Tye.Core/ApplicationFactory.cs

Co-authored-by: Justin Kotalik <jukotali@microsoft.com>

* Update src/Microsoft.Tye.Core/Serialization/ConfigServiceParser.cs

Co-authored-by: Justin Kotalik <jukotali@microsoft.com>

* Update test/E2ETest/TyeBuildTests.Dockerfile.cs

Co-authored-by: Justin Kotalik <jukotali@microsoft.com>

* Moved below DockerFile to keep ordering consistent.

* refactored HandleServiceDockerArgsNameMapping

* Use a stringbuilder for concatenation

* Removed appsettings development file

* Removed launchSettings file

* duplicate parameters test

* Multiple build args test

* small nits

Co-authored-by: Oscar Yahoo <ossent@yahoo.co.uk>
Co-authored-by: Justin Kotalik <jukotali@microsoft.com>
jkotalik/fixAzureFunctions
Oscar 6 years ago
committed by GitHub
parent
commit
9cbf1fdbc0
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      src/Microsoft.Tye.Core/ApplicationFactory.cs
  2. 1
      src/Microsoft.Tye.Core/ConfigModel/ConfigService.cs
  3. 3
      src/Microsoft.Tye.Core/DockerFileServiceBuilder.cs
  4. 32
      src/Microsoft.Tye.Core/Serialization/ConfigServiceParser.cs
  5. 10
      src/Microsoft.Tye.Hosting/DockerRunner.cs
  6. 1
      src/Microsoft.Tye.Hosting/Model/DockerRunInfo.cs
  7. 3
      src/tye/ApplicationBuilderExtensions.cs
  8. 2
      test/E2ETest/Microsoft.Tye.E2ETests.csproj
  9. 124
      test/E2ETest/TyeBuildTests.Dockerfile.cs
  10. 4
      test/E2ETest/testassets/projects/single-phase-dockerfile-args-duplicates/Dockerfile
  11. 26
      test/E2ETest/testassets/projects/single-phase-dockerfile-args-duplicates/Program.cs
  12. 27
      test/E2ETest/testassets/projects/single-phase-dockerfile-args-duplicates/Properties/launchSettings.json
  13. 40
      test/E2ETest/testassets/projects/single-phase-dockerfile-args-duplicates/Startup.cs
  14. 10
      test/E2ETest/testassets/projects/single-phase-dockerfile-args-duplicates/appsettings.json
  15. 8
      test/E2ETest/testassets/projects/single-phase-dockerfile-args-duplicates/single-phase-dockerfile-args.csproj
  16. 13
      test/E2ETest/testassets/projects/single-phase-dockerfile-args-duplicates/tye.yaml
  17. 4
      test/E2ETest/testassets/projects/single-phase-dockerfile-args/Dockerfile
  18. 26
      test/E2ETest/testassets/projects/single-phase-dockerfile-args/Program.cs
  19. 27
      test/E2ETest/testassets/projects/single-phase-dockerfile-args/Properties/launchSettings.json
  20. 40
      test/E2ETest/testassets/projects/single-phase-dockerfile-args/Startup.cs
  21. 10
      test/E2ETest/testassets/projects/single-phase-dockerfile-args/appsettings.json
  22. 8
      test/E2ETest/testassets/projects/single-phase-dockerfile-args/single-phase-dockerfile-args.csproj
  23. 12
      test/E2ETest/testassets/projects/single-phase-dockerfile-args/tye.yaml
  24. 4
      test/E2ETest/testassets/projects/single-phase-dockerfile-multi-args/Dockerfile
  25. 26
      test/E2ETest/testassets/projects/single-phase-dockerfile-multi-args/Program.cs
  26. 27
      test/E2ETest/testassets/projects/single-phase-dockerfile-multi-args/Properties/launchSettings.json
  27. 40
      test/E2ETest/testassets/projects/single-phase-dockerfile-multi-args/Startup.cs
  28. 10
      test/E2ETest/testassets/projects/single-phase-dockerfile-multi-args/appsettings.json
  29. 8
      test/E2ETest/testassets/projects/single-phase-dockerfile-multi-args/single-phase-dockerfile-multi-args.csproj
  30. 14
      test/E2ETest/testassets/projects/single-phase-dockerfile-multi-args/tye.yaml
  31. 15
      test/UnitTests/TyeDeserializationValidationTests.cs

3
src/Microsoft.Tye.Core/ApplicationFactory.cs

@ -133,7 +133,8 @@ namespace Microsoft.Tye
Replicas = configService.Replicas ?? 1,
DockerFile = Path.Combine(source.DirectoryName, configService.DockerFile),
// Supplying an absolute path with trailing slashes fails for DockerFileContext when calling docker build, so trim trailing slash.
DockerFileContext = GetDockerFileContext(source, configService)
DockerFileContext = GetDockerFileContext(source, configService),
BuildArgs = configService.DockerFileArgs
};
service = dockerFile;

1
src/Microsoft.Tye.Core/ConfigModel/ConfigService.cs

@ -22,6 +22,7 @@ namespace Microsoft.Tye.ConfigModel
public bool External { get; set; }
public string? Image { get; set; }
public string? DockerFile { get; set; }
public Dictionary<string, string> DockerFileArgs { get; set; } = new Dictionary<string, string>();
public string? DockerFileContext { get; set; }
public string? Project { get; set; }
public string? Include { get; set; }

3
src/Microsoft.Tye.Core/DockerFileServiceBuilder.cs

@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
namespace Microsoft.Tye
{
public class DockerFileServiceBuilder : ProjectServiceBuilder
@ -14,6 +16,7 @@ namespace Microsoft.Tye
public string Image { get; set; }
public string? DockerFile { get; set; }
public Dictionary<string, string> BuildArgs { get; set; } = new Dictionary<string, string>();
public string? DockerFileContext { get; set; }
}

32
src/Microsoft.Tye.Core/Serialization/ConfigServiceParser.cs

@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Linq;
using Microsoft.Tye.ConfigModel;
using YamlDotNet.RepresentationModel;
@ -46,6 +47,14 @@ namespace Tye.Serialization
case "dockerFile":
service.DockerFile = YamlParser.GetScalarValue(key, child.Value);
break;
case "dockerFileArgs":
if (child.Value.NodeType != YamlNodeType.Sequence)
{
throw new TyeYamlException(child.Value.Start, CoreStrings.FormatExpectedYamlSequence(key));
}
HandleDockerFileArgs((child.Value as YamlSequenceNode)!, service.DockerFileArgs);
break;
case "dockerFileContext":
service.DockerFileContext = YamlParser.GetScalarValue(key, child.Value);
break;
@ -399,6 +408,14 @@ namespace Tye.Serialization
buildProperties.Add(buildProperty);
}
}
private static void HandleDockerFileArgs(YamlSequenceNode yamlSequenceNode, Dictionary<string, string> dockerArguments)
{
foreach (var child in yamlSequenceNode.Children)
{
YamlParser.ThrowIfNotYamlMapping(child);
HandleServiceDockerArgsNameMapping((YamlMappingNode)child, dockerArguments);
}
}
private static void HandleServiceConfiguration(YamlSequenceNode yamlSequenceNode, List<ConfigConfigurationSource> configuration)
{
@ -459,5 +476,20 @@ namespace Tye.Serialization
tags.Add(tag);
}
}
private static void HandleServiceDockerArgsNameMapping(YamlMappingNode yamlMappingNode, IDictionary<string, string> dockerArguments)
{
foreach (var child in yamlMappingNode!.Children)
{
var key = YamlParser.GetScalarValue(child.Key);
var value = YamlParser.GetScalarValue(key, child.Value);
if (string.IsNullOrEmpty(key) || string.IsNullOrEmpty(value))
{
throw new TyeYamlException(child.Key.Start, CoreStrings.FormatUnrecognizedKey(key));
}
dockerArguments.Add(key, value);
}
}
}
}

10
src/Microsoft.Tye.Hosting/DockerRunner.cs

@ -8,6 +8,7 @@ using System.IO;
using System.Linq;
using System.Net;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
@ -468,9 +469,16 @@ namespace Microsoft.Tye.Hosting
service.Logs.OnNext(data);
}
var arguments = new StringBuilder($"build \"{docker.DockerFileContext?.FullName}\" -t {dockerImage} -f \"{docker.DockerFile}\"");
foreach (var buildArg in docker.BuildArgs)
{
arguments.Append($" --build-arg {buildArg.Key}={buildArg.Value}");
}
var dockerBuildResult = await ProcessUtil.RunAsync(
$"docker",
$"build \"{docker.DockerFileContext?.FullName}\" -t {dockerImage} -f \"{docker.DockerFile}\"",
arguments.ToString(),
outputDataReceived: Log,
errorDataReceived: Log,
workingDirectory: docker.WorkingDirectory,

1
src/Microsoft.Tye.Hosting/Model/DockerRunInfo.cs

@ -26,6 +26,7 @@ namespace Microsoft.Tye.Hosting.Model
public List<DockerVolume> VolumeMappings { get; } = new List<DockerVolume>();
public string? Args { get; }
public Dictionary<string, string> BuildArgs { get; set; } = new Dictionary<string, string>();
public string Image { get; }

3
src/tye/ApplicationBuilderExtensions.cs

@ -51,7 +51,8 @@ namespace Microsoft.Tye
{
var dockerRunInfo = new DockerRunInfo(dockerFile.Image, dockerFile.Args)
{
IsAspNet = dockerFile.IsAspNet
IsAspNet = dockerFile.IsAspNet,
BuildArgs = dockerFile.BuildArgs
};
if (!string.IsNullOrEmpty(dockerFile.DockerFile))

2
test/E2ETest/Microsoft.Tye.E2ETests.csproj

@ -32,7 +32,7 @@
</ItemGroup>
<ItemGroup>
<None Remove="testassets\generate\dockerfile.yaml" />
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="16.6.1" />
</ItemGroup>
</Project>

124
test/E2ETest/TyeBuildTests.Dockerfile.cs

@ -86,5 +86,129 @@ namespace E2ETest
await DockerAssert.DeleteDockerImagesAsync(output, imageName);
}
}
[ConditionalFact]
[SkipIfDockerNotRunning]
public async Task TyeBuild_SinglePhase_ExistingDockerfileWithBuildArgs()
{
var projectName = "single-phase-dockerfile-args";
var environment = "production";
var imageName = "test/web";
await DockerAssert.DeleteDockerImagesAsync(output, imageName);
using var projectDirectory = CopyTestProjectDirectory(projectName);
Assert.True(File.Exists(Path.Combine(projectDirectory.DirectoryPath, "Dockerfile")), "Dockerfile should exist.");
var projectFile = new FileInfo(Path.Combine(projectDirectory.DirectoryPath, "tye.yaml"));
var outputContext = new OutputContext(sink, Verbosity.Debug);
var application = await ApplicationFactory.CreateAsync(outputContext, projectFile);
application.Registry = new ContainerRegistry("test");
try
{
await BuildHost.ExecuteBuildAsync(outputContext, application, environment, interactive: false);
Assert.Single(application.Services.Single().Outputs.OfType<DockerImageOutput>());
var builder = (DockerFileServiceBuilder)application.Services.First();
var valuePair = builder.BuildArgs.First();
Assert.Equal("pat", valuePair.Key);
Assert.Equal("thisisapat", valuePair.Value);
await DockerAssert.AssertImageExistsAsync(output, imageName);
}
finally
{
await DockerAssert.DeleteDockerImagesAsync(output, imageName);
}
}
[ConditionalFact]
[SkipIfDockerNotRunning]
public async Task TyeBuild_SinglePhase_ExistingDockerfileWithBuildArgsDuplicateArgs()
{
var projectName = "single-phase-dockerfile-args";
var environment = "production";
var imageName = "test/web";
await DockerAssert.DeleteDockerImagesAsync(output, imageName);
using var projectDirectory = CopyTestProjectDirectory(projectName);
Assert.True(File.Exists(Path.Combine(projectDirectory.DirectoryPath, "Dockerfile")), "Dockerfile should exist.");
var projectFile = new FileInfo(Path.Combine(projectDirectory.DirectoryPath, "tye.yaml"));
var outputContext = new OutputContext(sink, Verbosity.Debug);
var application = await ApplicationFactory.CreateAsync(outputContext, projectFile);
application.Registry = new ContainerRegistry("test");
try
{
await BuildHost.ExecuteBuildAsync(outputContext, application, environment, interactive: false);
Assert.Single(application.Services.Single().Outputs.OfType<DockerImageOutput>());
var builder = (DockerFileServiceBuilder)application.Services.First();
var valuePair = builder.BuildArgs.First();
Assert.Equal("pat", valuePair.Key);
Assert.Equal("thisisapat", valuePair.Value);
await DockerAssert.AssertImageExistsAsync(output, imageName);
}
finally
{
await DockerAssert.DeleteDockerImagesAsync(output, imageName);
}
}
[ConditionalFact]
[SkipIfDockerNotRunning]
public async Task TyeBuild_SinglePhase_ExistingDockerfileWithBuildArgsMultiArgs()
{
var projectName = "single-phase-dockerfile-multi-args";
var environment = "production";
var imageName = "test/web";
await DockerAssert.DeleteDockerImagesAsync(output, imageName);
using var projectDirectory = CopyTestProjectDirectory(projectName);
Assert.True(File.Exists(Path.Combine(projectDirectory.DirectoryPath, "Dockerfile")), "Dockerfile should exist.");
var projectFile = new FileInfo(Path.Combine(projectDirectory.DirectoryPath, "tye.yaml"));
var outputContext = new OutputContext(sink, Verbosity.Debug);
var application = await ApplicationFactory.CreateAsync(outputContext, projectFile);
application.Registry = new ContainerRegistry("test");
try
{
await BuildHost.ExecuteBuildAsync(outputContext, application, environment, interactive: false);
Assert.Single(application.Services.Single().Outputs.OfType<DockerImageOutput>());
var builder = (DockerFileServiceBuilder)application.Services.First();
var valuePair = builder.BuildArgs.ElementAt(0);
Assert.Equal(3, builder.BuildArgs.Count);
Assert.Equal("pat", valuePair.Key);
Assert.Equal("thisisapat", valuePair.Value);
valuePair = builder.BuildArgs.ElementAt(1);
Assert.Equal("number_of_replicas", valuePair.Key);
Assert.Equal("2", valuePair.Value);
valuePair = builder.BuildArgs.ElementAt(2);
Assert.Equal("number_of_shards", valuePair.Key);
Assert.Equal("5", valuePair.Value);
await DockerAssert.AssertImageExistsAsync(output, imageName);
}
finally
{
await DockerAssert.DeleteDockerImagesAsync(output, imageName);
}
}
}
}

4
test/E2ETest/testassets/projects/single-phase-dockerfile-args-duplicates/Dockerfile

@ -0,0 +1,4 @@
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
WORKDIR /app
COPY . /app
ENTRYPOINT ["dotnet", "single-phase-dockerfile-args.dll"]

26
test/E2ETest/testassets/projects/single-phase-dockerfile-args-duplicates/Program.cs

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace single_phase_dockerfile
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}

27
test/E2ETest/testassets/projects/single-phase-dockerfile-args-duplicates/Properties/launchSettings.json

@ -0,0 +1,27 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:15313",
"sslPort": 44306
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"single_phase_dockerfile": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

40
test/E2ETest/testassets/projects/single-phase-dockerfile-args-duplicates/Startup.cs

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace single_phase_dockerfile
{
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapGet("/", context =>
{
return context.Response.WriteAsync("Hello World!");
});
});
}
}
}

10
test/E2ETest/testassets/projects/single-phase-dockerfile-args-duplicates/appsettings.json

@ -0,0 +1,10 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}

8
test/E2ETest/testassets/projects/single-phase-dockerfile-args-duplicates/single-phase-dockerfile-args.csproj

@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>single_phase_dockerfile_args</RootNamespace>
</PropertyGroup>
</Project>

13
test/E2ETest/testassets/projects/single-phase-dockerfile-args-duplicates/tye.yaml

@ -0,0 +1,13 @@
# tye application configuration file
# read all about it at https://github.com/dotnet/tye
#
# when you've given us a try, we'd love to know what you think:
# https://aka.ms/AA7q20u
#
name: single-phase-dockerfile-args
services:
- name: web
dockerFile: Dockerfile
dockerFileArgs:
- pat: thisisapat
- pat: thisisapat

4
test/E2ETest/testassets/projects/single-phase-dockerfile-args/Dockerfile

@ -0,0 +1,4 @@
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
WORKDIR /app
COPY . /app
ENTRYPOINT ["dotnet", "single-phase-dockerfile-args.dll"]

26
test/E2ETest/testassets/projects/single-phase-dockerfile-args/Program.cs

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace single_phase_dockerfile
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}

27
test/E2ETest/testassets/projects/single-phase-dockerfile-args/Properties/launchSettings.json

@ -0,0 +1,27 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:15313",
"sslPort": 44306
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"single_phase_dockerfile": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

40
test/E2ETest/testassets/projects/single-phase-dockerfile-args/Startup.cs

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace single_phase_dockerfile
{
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapGet("/", context =>
{
return context.Response.WriteAsync("Hello World!");
});
});
}
}
}

10
test/E2ETest/testassets/projects/single-phase-dockerfile-args/appsettings.json

@ -0,0 +1,10 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}

8
test/E2ETest/testassets/projects/single-phase-dockerfile-args/single-phase-dockerfile-args.csproj

@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>single_phase_dockerfile_args</RootNamespace>
</PropertyGroup>
</Project>

12
test/E2ETest/testassets/projects/single-phase-dockerfile-args/tye.yaml

@ -0,0 +1,12 @@
# tye application configuration file
# read all about it at https://github.com/dotnet/tye
#
# when you've given us a try, we'd love to know what you think:
# https://aka.ms/AA7q20u
#
name: single-phase-dockerfile-args
services:
- name: web
dockerFile: Dockerfile
dockerFileArgs:
- pat: thisisapat

4
test/E2ETest/testassets/projects/single-phase-dockerfile-multi-args/Dockerfile

@ -0,0 +1,4 @@
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
WORKDIR /app
COPY . /app
ENTRYPOINT ["dotnet", "single-phase-dockerfile-args.dll"]

26
test/E2ETest/testassets/projects/single-phase-dockerfile-multi-args/Program.cs

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace single_phase_dockerfile
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}

27
test/E2ETest/testassets/projects/single-phase-dockerfile-multi-args/Properties/launchSettings.json

@ -0,0 +1,27 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:15313",
"sslPort": 44306
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"single_phase_dockerfile": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

40
test/E2ETest/testassets/projects/single-phase-dockerfile-multi-args/Startup.cs

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace single_phase_dockerfile
{
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapGet("/", context =>
{
return context.Response.WriteAsync("Hello World!");
});
});
}
}
}

10
test/E2ETest/testassets/projects/single-phase-dockerfile-multi-args/appsettings.json

@ -0,0 +1,10 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}

8
test/E2ETest/testassets/projects/single-phase-dockerfile-multi-args/single-phase-dockerfile-multi-args.csproj

@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>single_phase_dockerfile_args</RootNamespace>
</PropertyGroup>
</Project>

14
test/E2ETest/testassets/projects/single-phase-dockerfile-multi-args/tye.yaml

@ -0,0 +1,14 @@
# tye application configuration file
# read all about it at https://github.com/dotnet/tye
#
# when you've given us a try, we'd love to know what you think:
# https://aka.ms/AA7q20u
#
name: single-phase-dockerfile-args
services:
- name: web
dockerFile: Dockerfile
dockerFileArgs:
- pat: thisisapat
number_of_replicas: 2
number_of_shards: 5

15
test/UnitTests/TyeDeserializationValidationTests.cs

@ -273,5 +273,20 @@ services:
var exception = Assert.Throws<TyeYamlException>(() => app.Validate());
Assert.Contains(errorMessage, exception.Message);
}
[Fact]
public void DockerFileWithArgs()
{
var input = @"
services:
- name: web
dockerFile: Dockerfile
dockerFileArgs:
- pat: thisisapat";
using var parser = new YamlParser(input);
var app = parser.ParseConfigApplication();
app.Validate();
}
}
}

Loading…
Cancel
Save