diff --git a/OMC.Docker.sln b/OMC.Docker.sln new file mode 100644 index 0000000..b3044ed --- /dev/null +++ b/OMC.Docker.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27004.2005 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OMC.DockerApi", "OMC.DockerApi\OMC.DockerApi.csproj", "{54C24714-3E44-4EF1-A9B3-C37863091B5A}" +EndProject +Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{CD9984A8-3373-4BEF-A101-7BF6084A5AFD}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {54C24714-3E44-4EF1-A9B3-C37863091B5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {54C24714-3E44-4EF1-A9B3-C37863091B5A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {54C24714-3E44-4EF1-A9B3-C37863091B5A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {54C24714-3E44-4EF1-A9B3-C37863091B5A}.Release|Any CPU.Build.0 = Release|Any CPU + {CD9984A8-3373-4BEF-A101-7BF6084A5AFD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CD9984A8-3373-4BEF-A101-7BF6084A5AFD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CD9984A8-3373-4BEF-A101-7BF6084A5AFD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CD9984A8-3373-4BEF-A101-7BF6084A5AFD}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {8D51562E-35CD-46E6-B452-C28D3442B50B} + EndGlobalSection +EndGlobal diff --git a/OMC.DockerApi/.dockerignore b/OMC.DockerApi/.dockerignore new file mode 100644 index 0000000..d8f8175 --- /dev/null +++ b/OMC.DockerApi/.dockerignore @@ -0,0 +1,3 @@ +* +!obj/Docker/publish/* +!obj/Docker/empty/ diff --git a/OMC.DockerApi/Controllers/ValuesController.cs b/OMC.DockerApi/Controllers/ValuesController.cs new file mode 100644 index 0000000..eea642b --- /dev/null +++ b/OMC.DockerApi/Controllers/ValuesController.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; + +namespace OMC.DockerApi.Controllers +{ + [Route("api/[controller]")] + public class ValuesController : Controller + { + // GET api/values + [HttpGet] + public IEnumerable Get() + { + return new string[] { "value1", "value2" }; + } + + // GET api/values/5 + [HttpGet("{id}")] + public string Get(int id) + { + return "value"; + } + + // POST api/values + [HttpPost] + public void Post([FromBody]string value) + { + } + + // PUT api/values/5 + [HttpPut("{id}")] + public void Put(int id, [FromBody]string value) + { + } + + // DELETE api/values/5 + [HttpDelete("{id}")] + public void Delete(int id) + { + } + } +} diff --git a/OMC.DockerApi/Dockerfile b/OMC.DockerApi/Dockerfile new file mode 100644 index 0000000..fc39328 --- /dev/null +++ b/OMC.DockerApi/Dockerfile @@ -0,0 +1,6 @@ +FROM microsoft/aspnetcore:2.0 +ARG source +WORKDIR /app +EXPOSE 80 +COPY ${source:-obj/Docker/publish} . +ENTRYPOINT ["dotnet", "OMC.DockerApi.dll"] diff --git a/OMC.DockerApi/OMC.DockerApi.csproj b/OMC.DockerApi/OMC.DockerApi.csproj new file mode 100644 index 0000000..4724675 --- /dev/null +++ b/OMC.DockerApi/OMC.DockerApi.csproj @@ -0,0 +1,20 @@ + + + + netcoreapp2.0 + ..\docker-compose.dcproj + + + + + + + + + + + + + + + diff --git a/OMC.DockerApi/Program.cs b/OMC.DockerApi/Program.cs new file mode 100644 index 0000000..7b99428 --- /dev/null +++ b/OMC.DockerApi/Program.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; + +namespace OMC.DockerApi +{ + public class Program + { + public static void Main(string[] args) + { + BuildWebHost(args).Run(); + } + + public static IWebHost BuildWebHost(string[] args) => + WebHost.CreateDefaultBuilder(args) + .UseStartup() + .Build(); + } +} diff --git a/OMC.DockerApi/Properties/launchSettings.json b/OMC.DockerApi/Properties/launchSettings.json new file mode 100644 index 0000000..cefd58f --- /dev/null +++ b/OMC.DockerApi/Properties/launchSettings.json @@ -0,0 +1,29 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:24476/", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "api/values", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "OMC.DockerApi": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "api/values", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "http://localhost:24477/" + } + } +} diff --git a/OMC.DockerApi/Startup.cs b/OMC.DockerApi/Startup.cs new file mode 100644 index 0000000..d646925 --- /dev/null +++ b/OMC.DockerApi/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.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; + +namespace OMC.DockerApi +{ + public class Startup + { + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + services.AddMvc(); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IHostingEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.UseMvc(); + } + } +} diff --git a/OMC.DockerApi/appsettings.Development.json b/OMC.DockerApi/appsettings.Development.json new file mode 100644 index 0000000..fa8ce71 --- /dev/null +++ b/OMC.DockerApi/appsettings.Development.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "IncludeScopes": false, + "LogLevel": { + "Default": "Debug", + "System": "Information", + "Microsoft": "Information" + } + } +} diff --git a/OMC.DockerApi/appsettings.json b/OMC.DockerApi/appsettings.json new file mode 100644 index 0000000..26bb0ac --- /dev/null +++ b/OMC.DockerApi/appsettings.json @@ -0,0 +1,15 @@ +{ + "Logging": { + "IncludeScopes": false, + "Debug": { + "LogLevel": { + "Default": "Warning" + } + }, + "Console": { + "LogLevel": { + "Default": "Warning" + } + } + } +} diff --git a/docker-compose.ci.build.yml b/docker-compose.ci.build.yml new file mode 100644 index 0000000..c6e749c --- /dev/null +++ b/docker-compose.ci.build.yml @@ -0,0 +1,9 @@ +version: '3' + +services: + ci-build: + image: microsoft/aspnetcore-build:1.0-2.0 + volumes: + - .:/src + working_dir: /src + command: /bin/bash -c "dotnet restore ./OMC.Docker.sln && dotnet publish ./OMC.Docker.sln -c Release -o ./obj/Docker/publish" diff --git a/docker-compose.dcproj b/docker-compose.dcproj new file mode 100644 index 0000000..302e061 --- /dev/null +++ b/docker-compose.dcproj @@ -0,0 +1,18 @@ + + + + 2.0 + Linux + cd9984a8-3373-4bef-a101-7bf6084a5afd + True + http://localhost:{ServicePort}/api/values + omc.dockerapi + + + + + docker-compose.yml + + + + \ No newline at end of file diff --git a/docker-compose.override.yml b/docker-compose.override.yml new file mode 100644 index 0000000..34517f5 --- /dev/null +++ b/docker-compose.override.yml @@ -0,0 +1,8 @@ +version: '3' + +services: + omc.dockerapi: + environment: + - ASPNETCORE_ENVIRONMENT=Development + ports: + - "80" diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..3b613b6 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,8 @@ +version: '3' + +services: + omc.dockerapi: + image: omc.dockerapi + build: + context: ./OMC.DockerApi + dockerfile: Dockerfile