Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgerlag committed Jun 7, 2019
1 parent 74a9577 commit 685a653
Show file tree
Hide file tree
Showing 13 changed files with 94 additions and 64 deletions.
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.dockerignore
.env
.git
.gitignore
.vs
.vscode
*/bin
*/obj
**/.toolstarget
5 changes: 1 addition & 4 deletions Conductor.Domain/Conductor.Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="SharpYaml" Version="1.6.5" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\workflow-core\src\WorkflowCore\WorkflowCore.csproj" />
<PackageReference Include="WorkflowCore" Version="1.9.3" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion Conductor.Steps/Conductor.Steps.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\workflow-core\src\WorkflowCore\WorkflowCore.csproj" />
<PackageReference Include="WorkflowCore" Version="1.9.3" />
</ItemGroup>

</Project>
14 changes: 4 additions & 10 deletions Conductor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Scratch", "Scratch", "{29F7
1.yaml = 1.yaml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WorkflowCore", "WorkflowCore", "{50A4A1A7-403C-4B9E-BF53-FA6C1840086B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WorkflowCore", "..\workflow-core\src\WorkflowCore\WorkflowCore.csproj", "{692E5594-87E7-4BD8-8746-A6C33562A056}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B3E1C72D-C63A-4A85-AAC1-AF7C1F072907}"
ProjectSection(SolutionItems) = preProject
Dockerfile = Dockerfile
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -42,17 +43,10 @@ Global
{C9DA979C-9D97-4D8B-B297-C0DEC68C9490}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C9DA979C-9D97-4D8B-B297-C0DEC68C9490}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C9DA979C-9D97-4D8B-B297-C0DEC68C9490}.Release|Any CPU.Build.0 = Release|Any CPU
{692E5594-87E7-4BD8-8746-A6C33562A056}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{692E5594-87E7-4BD8-8746-A6C33562A056}.Debug|Any CPU.Build.0 = Debug|Any CPU
{692E5594-87E7-4BD8-8746-A6C33562A056}.Release|Any CPU.ActiveCfg = Release|Any CPU
{692E5594-87E7-4BD8-8746-A6C33562A056}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{692E5594-87E7-4BD8-8746-A6C33562A056} = {50A4A1A7-403C-4B9E-BF53-FA6C1840086B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B88BB9DA-8644-464E-820C-100F799AD7E2}
EndGlobalSection
Expand Down
9 changes: 8 additions & 1 deletion Conductor/Conductor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,23 @@
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<UserSecretsId>0b178d89-9937-49c8-b1f1-efb5f96e516d</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<None Remove="Dockerfile" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.4.10" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />
<PackageReference Include="WorkflowCore" Version="1.9.3" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\workflow-core\src\WorkflowCore\WorkflowCore.csproj" />
<ProjectReference Include="..\Conductor.Domain\Conductor.Domain.csproj" />
<ProjectReference Include="..\Conductor.Steps\Conductor.Steps.csproj" />
<ProjectReference Include="..\Conductor.Storage\Conductor.Storage.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion Conductor/Conductor.csproj.user
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<WebStackScaffolding_IsReferencingScriptLibrariesSelected>True</WebStackScaffolding_IsReferencingScriptLibrariesSelected>
<WebStackScaffolding_LayoutPageFile />
<WebStackScaffolding_IsAsyncSelected>False</WebStackScaffolding_IsAsyncSelected>
<ActiveDebugProfile>Conductor</ActiveDebugProfile>
<ActiveDebugProfile>Docker</ActiveDebugProfile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
Expand Down
2 changes: 1 addition & 1 deletion Conductor/Controllers/EventController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public EventController(IWorkflowController workflowController)
}

[HttpPost("{name}/{key}")]
public async Task Post(string name, string key, [FromBody] JObject data)
public async Task Post(string name, string key, [FromBody] object data)
{
await _workflowController.PublishEvent(name, key, data);
Response.StatusCode = 204;
Expand Down
37 changes: 0 additions & 37 deletions Conductor/Formatters/RawRequestBodyInputFormatter.cs

This file was deleted.

5 changes: 3 additions & 2 deletions Conductor/Formatters/YamlRequestBodyInputFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ namespace Conductor.Formatters
{
public class YamlRequestBodyInputFormatter : InputFormatter
{
public override bool CanRead(InputFormatterContext context)
public YamlRequestBodyInputFormatter()
{
return (context.HttpContext.Request.ContentType == "application/x-yaml");
SupportedMediaTypes.Add("application/x-yaml");
SupportedMediaTypes.Add("application/yaml");
}

public override async Task<InputFormatterResult> ReadRequestBodyAsync(InputFormatterContext context)
Expand Down
30 changes: 30 additions & 0 deletions Conductor/Formatters/YamlRequestBodyOutputFormatter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Conductor.Domain.Models;
using Microsoft.AspNetCore.Mvc.Formatters;
using SharpYaml.Serialization;

namespace Conductor.Formatters
{
public class YamlRequestBodyOutputFormatter : OutputFormatter
{

public YamlRequestBodyOutputFormatter()
{
SupportedMediaTypes.Add("application/x-yaml");
SupportedMediaTypes.Add("application/yaml");
}

public override async Task WriteResponseBodyAsync(OutputFormatterWriteContext context)
{
var response = context.HttpContext.Response;
var serializer = new Serializer();
var body = Encoding.UTF8.GetBytes(serializer.Serialize(context.Object));
await response.Body.WriteAsync(body, 0, body.Length);
}
}
}
17 changes: 11 additions & 6 deletions Conductor/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:61924",
"sslPort": 44340
}
},
"$schema": "http://json.schemastore.org/launchsettings.json",
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
Expand All @@ -21,10 +21,15 @@
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "api/values",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"applicationUrl": "https://localhost:5001;http://localhost:5000"
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/api/values"
}
}
}
3 changes: 2 additions & 1 deletion Conductor/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public void ConfigureServices(IServiceCollection services)
{
services.AddMvc(options =>
{
options.InputFormatters.Insert(0, new YamlRequestBodyInputFormatter());
options.InputFormatters.Add(new YamlRequestBodyInputFormatter());
options.OutputFormatters.Add(new YamlRequestBodyOutputFormatter());
})
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

Expand Down
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM microsoft/dotnet:2.2-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM microsoft/dotnet:2.2-sdk AS build
WORKDIR /src
COPY ["Conductor/Conductor.csproj", "Conductor/"]
COPY ["Conductor.Steps/Conductor.Steps.csproj", "Conductor.Steps/"]
COPY ["Conductor.Domain/Conductor.Domain.csproj", "Conductor.Domain/"]
COPY ["Conductor.Storage/Conductor.Storage.csproj", "Conductor.Storage/"]
RUN dotnet restore "Conductor/Conductor.csproj"
COPY . .
WORKDIR "/src/Conductor"
RUN dotnet build "Conductor.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "Conductor.csproj" -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "Conductor.dll"]

0 comments on commit 685a653

Please sign in to comment.