From 3df4f3a206b09d97635eceb6ea57a650c4cbf527 Mon Sep 17 00:00:00 2001 From: Charles Lowell Date: Thu, 23 Feb 2017 09:34:00 -0800 Subject: [PATCH 1/7] Configure service URLs via environment variables --- docker-compose.override.yml | 6 ++++++ src/Services/Basket/Basket.API/Program.cs | 9 ++------- src/Services/Catalog/Catalog.API/Program.cs | 9 ++------- src/Services/Identity/Identity.API/Program.cs | 7 +------ src/Services/Ordering/Ordering.API/Program.cs | 9 ++------- src/Web/WebMVC/Program.cs | 7 +------ src/Web/WebSPA/Program.cs | 6 ++---- 7 files changed, 16 insertions(+), 37 deletions(-) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 909cf4172..4ec82286e 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -5,6 +5,7 @@ services: basket.api: environment: - ASPNETCORE_ENVIRONMENT=Development + - ASPNETCORE_URLS=http://0.0.0.0:5103 - ConnectionString=basket.data #- identityUrl=http://13.88.8.119:5105 #Remote: VM Needs to have public access at 5105. - identityUrl=http://identity.api:5105 #Local: You need to open your local dev-machine firewall at range 5100-5105. at range 5100-5105. @@ -14,6 +15,7 @@ services: catalog.api: environment: - ASPNETCORE_ENVIRONMENT=Development + - ASPNETCORE_URLS=http://0.0.0.0:5101 - ConnectionString=Server=sql.data;Database=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word #- ExternalCatalogBaseUrl=http://13.88.8.119:5101 #Remote: VM Needs to have public access at 5105. - ExternalCatalogBaseUrl=http://localhost:5101 #Local: You need to open your local dev-machine firewall at range 5100-5105. at range 5100-5105. @@ -23,6 +25,7 @@ services: identity.api: environment: - ASPNETCORE_ENVIRONMENT=Development + - ASPNETCORE_URLS=http://0.0.0.0:5105 - SpaClient=http://localhost:5104 - ConnectionStrings__DefaultConnection=Server=sql.data;Database=Microsoft.eShopOnContainers.Service.IdentityDb;User Id=sa;Password=Pass@word #- MvcClient=http://13.88.8.119:5100 #Remote: VM Needs to have public access at 5105. @@ -33,6 +36,7 @@ services: ordering.api: environment: - ASPNETCORE_ENVIRONMENT=Development + - ASPNETCORE_URLS=http://0.0.0.0:5102 - ConnectionString=Server=sql.data;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word #- identityUrl=http://13.88.8.119:5105 #Remote: VM Needs to have public access at 5105. - identityUrl=http://identity.api:5105 #Local: You need to open your local dev-machine firewall at range 5100-5105. at range 5100-5105. @@ -42,6 +46,7 @@ services: webspa: environment: - ASPNETCORE_ENVIRONMENT=Development + - ASPNETCORE_URLS=http://0.0.0.0:5104 - CatalogUrl=http://localhost:5101 - OrderingUrl=http://localhost:5102 #- IdentityUrl=http://13.88.8.119:5105 #Remote: VM Needs to have public access at 5105. @@ -53,6 +58,7 @@ services: webmvc: environment: - ASPNETCORE_ENVIRONMENT=Development + - ASPNETCORE_URLS=http://0.0.0.0:5100 - CatalogUrl=http://catalog.api:5101 - OrderingUrl=http://ordering.api:5102 #- IdentityUrl=http://13.88.8.119:5105 #Remote: VM Needs to have public access at 5105. diff --git a/src/Services/Basket/Basket.API/Program.cs b/src/Services/Basket/Basket.API/Program.cs index a3ac96b49..d2b305ce8 100644 --- a/src/Services/Basket/Basket.API/Program.cs +++ b/src/Services/Basket/Basket.API/Program.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Builder; +using System.IO; namespace Microsoft.eShopOnContainers.Services.Basket.API { @@ -15,7 +11,6 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API var host = new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) - .UseUrls("http://0.0.0.0:5103") .UseIISIntegration() .UseStartup() .Build(); diff --git a/src/Services/Catalog/Catalog.API/Program.cs b/src/Services/Catalog/Catalog.API/Program.cs index 6226dc389..b2e338b8c 100644 --- a/src/Services/Catalog/Catalog.API/Program.cs +++ b/src/Services/Catalog/Catalog.API/Program.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Builder; +using System.IO; namespace Microsoft.eShopOnContainers.Services.Catalog.API { @@ -14,7 +10,6 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API { var host = new WebHostBuilder() .UseKestrel() - .UseUrls("http://0.0.0.0:5101") .UseIISIntegration() .UseContentRoot(Directory.GetCurrentDirectory()) .UseWebRoot("Pics") diff --git a/src/Services/Identity/Identity.API/Program.cs b/src/Services/Identity/Identity.API/Program.cs index 48531ae65..eb999639b 100644 --- a/src/Services/Identity/Identity.API/Program.cs +++ b/src/Services/Identity/Identity.API/Program.cs @@ -1,9 +1,5 @@ -using System; -using System.Collections.Generic; +using Microsoft.AspNetCore.Hosting; using System.IO; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Hosting; namespace eShopOnContainers.Identity { @@ -13,7 +9,6 @@ namespace eShopOnContainers.Identity { var host = new WebHostBuilder() .UseKestrel() - .UseUrls("http://0.0.0.0:5105") .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup() diff --git a/src/Services/Ordering/Ordering.API/Program.cs b/src/Services/Ordering/Ordering.API/Program.cs index d5daf106e..1a9d705d4 100644 --- a/src/Services/Ordering/Ordering.API/Program.cs +++ b/src/Services/Ordering/Ordering.API/Program.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Builder; +using System.IO; namespace Microsoft.eShopOnContainers.Services.Ordering.API { @@ -15,7 +11,6 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.API var host = new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) - .UseUrls("http://0.0.0.0:5102") .UseIISIntegration() .UseStartup() .Build(); diff --git a/src/Web/WebMVC/Program.cs b/src/Web/WebMVC/Program.cs index 848e17679..6775c071c 100644 --- a/src/Web/WebMVC/Program.cs +++ b/src/Web/WebMVC/Program.cs @@ -1,9 +1,5 @@ -using System; -using System.Collections.Generic; +using Microsoft.AspNetCore.Hosting; using System.IO; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Hosting; namespace Microsoft.eShopOnContainers.WebMVC { @@ -14,7 +10,6 @@ namespace Microsoft.eShopOnContainers.WebMVC var host = new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) - .UseUrls("http://0.0.0.0:5100") .UseIISIntegration() .UseStartup() .Build(); diff --git a/src/Web/WebSPA/Program.cs b/src/Web/WebSPA/Program.cs index ffad0461e..3759baa3b 100644 --- a/src/Web/WebSPA/Program.cs +++ b/src/Web/WebSPA/Program.cs @@ -1,6 +1,5 @@ -using System.IO; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; +using Microsoft.AspNetCore.Hosting; +using System.IO; namespace eShopConContainers.WebSPA { @@ -11,7 +10,6 @@ namespace eShopConContainers.WebSPA var host = new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) - .UseUrls("http://0.0.0.0:5104") .UseIISIntegration() .UseStartup() .Build(); From 7755f3061876f3d36f948c63164852e9248094bb Mon Sep 17 00:00:00 2001 From: Charles Lowell Date: Thu, 23 Feb 2017 10:02:35 -0800 Subject: [PATCH 2/7] Use relative paths & URLs --- .../Identity/Identity.API/wwwroot/css/site.css | 4 ++-- src/Web/WebMVC/Controllers/AccountController.cs | 11 ++++++++--- src/Web/WebMVC/Views/Catalog/Index.cshtml | 4 ++-- .../Views/Shared/Components/Cart/Default.cshtml | 2 +- src/Web/WebMVC/Views/Shared/_Layout.cshtml | 4 ++-- src/Web/WebMVC/Views/Shared/_LoginPartial.cshtml | 6 +++--- src/Web/WebMVC/wwwroot/css/app.css | 2 +- 7 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/Services/Identity/Identity.API/wwwroot/css/site.css b/src/Services/Identity/Identity.API/wwwroot/css/site.css index a95381dc8..c8dcea80a 100644 --- a/src/Services/Identity/Identity.API/wwwroot/css/site.css +++ b/src/Services/Identity/Identity.API/wwwroot/css/site.css @@ -42,13 +42,13 @@ @font-face { font-family: Montserrat; font-weight: 400; - src: url("/fonts/Montserrat-Regular.eot?") format("eot"),url("/fonts/Montserrat-Regular.woff") format("woff"),url("/fonts/Montserrat-Regular.ttf") format("truetype"),url("/fonts/Montserrat-Regular.svg#Montserrat") format("svg") + src: url("../fonts/Montserrat-Regular.eot?") format("eot"),url("../fonts/Montserrat-Regular.woff") format("woff"),url("../fonts/Montserrat-Regular.ttf") format("truetype"),url("../fonts/Montserrat-Regular.svg#Montserrat") format("svg") } @font-face { font-family: Montserrat; font-weight: 700; - src: url("/fonts/Montserrat-Bold.eot?") format("eot"),url("/fonts/Montserrat-Bold.woff") format("woff"),url("/fonts/Montserrat-Bold.ttf") format("truetype"),url("/fonts/Montserrat-Bold.svg#Montserrat") format("svg") + src: url("../fonts/Montserrat-Bold.eot?") format("eot"),url("../fonts/Montserrat-Bold.woff") format("woff"),url("../fonts/Montserrat-Bold.ttf") format("truetype"),url("../fonts/Montserrat-Bold.svg#Montserrat") format("svg") } body { diff --git a/src/Web/WebMVC/Controllers/AccountController.cs b/src/Web/WebMVC/Controllers/AccountController.cs index 0f14cf45f..b6506c2d1 100644 --- a/src/Web/WebMVC/Controllers/AccountController.cs +++ b/src/Web/WebMVC/Controllers/AccountController.cs @@ -33,15 +33,20 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers ViewData["access_token"] = token.Value; } - return Redirect("/"); + // "Catalog" because UrlHelper doesn't support nameof() for controllers + // https://github.com/aspnet/Mvc/issues/5853 + return RedirectToAction(nameof(CatalogController.Index), "Catalog"); } public IActionResult Signout() { HttpContext.Authentication.SignOutAsync("Cookies"); HttpContext.Authentication.SignOutAsync("oidc"); - - return new SignOutResult("oidc", new AuthenticationProperties { RedirectUri = "/" }); + + // "Catalog" because UrlHelper doesn't support nameof() for controllers + // https://github.com/aspnet/Mvc/issues/5853 + var homeUrl = Url.Action(nameof(CatalogController.Index), "Catalog"); + return new SignOutResult("oidc", new AuthenticationProperties { RedirectUri = homeUrl }); } } } diff --git a/src/Web/WebMVC/Views/Catalog/Index.cshtml b/src/Web/WebMVC/Views/Catalog/Index.cshtml index 439293111..8fe288fd8 100644 --- a/src/Web/WebMVC/Views/Catalog/Index.cshtml +++ b/src/Web/WebMVC/Views/Catalog/Index.cshtml @@ -4,7 +4,7 @@ }
- +
@@ -17,7 +17,7 @@ - + diff --git a/src/Web/WebMVC/Views/Shared/Components/Cart/Default.cshtml b/src/Web/WebMVC/Views/Shared/Components/Cart/Default.cshtml index e8699f930..6be55d67a 100644 --- a/src/Web/WebMVC/Views/Shared/Components/Cart/Default.cshtml +++ b/src/Web/WebMVC/Views/Shared/Components/Cart/Default.cshtml @@ -10,7 +10,7 @@ asp-action="Index">
- +
@Model.ItemsCount diff --git a/src/Web/WebMVC/Views/Shared/_Layout.cshtml b/src/Web/WebMVC/Views/Shared/_Layout.cshtml index f7eda24ef..28eada0d0 100644 --- a/src/Web/WebMVC/Views/Shared/_Layout.cshtml +++ b/src/Web/WebMVC/Views/Shared/_Layout.cshtml @@ -34,7 +34,7 @@
- +
@@ -51,7 +51,7 @@
- +
diff --git a/src/Web/WebMVC/Views/Shared/_LoginPartial.cshtml b/src/Web/WebMVC/Views/Shared/_LoginPartial.cshtml index 0d987d9fe..38659cc06 100644 --- a/src/Web/WebMVC/Views/Shared/_LoginPartial.cshtml +++ b/src/Web/WebMVC/Views/Shared/_LoginPartial.cshtml @@ -13,7 +13,7 @@
@User.FindFirst(x => x.Type == "preferred_username").Value
- +
@@ -23,14 +23,14 @@ asp-action="Index">
My orders
- +
Log Out
- +
diff --git a/src/Web/WebMVC/wwwroot/css/app.css b/src/Web/WebMVC/wwwroot/css/app.css index 6975836e2..55cbd66aa 100644 --- a/src/Web/WebMVC/wwwroot/css/app.css +++ b/src/Web/WebMVC/wwwroot/css/app.css @@ -1,7 +1,7 @@ @font-face { font-family: Montserrat; font-weight: 400; - src: url(".../fonts/Montserrat-Regular.eot?") format("eot"), url("../fonts/Montserrat-Regular.woff") format("woff"), url("../fonts/Montserrat-Regular.ttf") format("truetype"), url("../fonts/Montserrat-Regular.svg#Montserrat") format("svg"); + src: url("../fonts/Montserrat-Regular.eot?") format("eot"), url("../fonts/Montserrat-Regular.woff") format("woff"), url("../fonts/Montserrat-Regular.ttf") format("truetype"), url("../fonts/Montserrat-Regular.svg#Montserrat") format("svg"); } @font-face { From 75d5c3695a6f501f0c174848c8f278f5ddf8983b Mon Sep 17 00:00:00 2001 From: Charles Lowell Date: Fri, 24 Feb 2017 11:21:28 -0800 Subject: [PATCH 3/7] Fix Identity.API and WebMVC publishing - upgrade BundlerMinifier.Core dependencies (fixes a globbing bug) - ensure minification includes all css - only copy what's needed in production to the publish directory --- .../Identity/Identity.API/Identity.API.csproj | 29 ++++++++++-------- .../Identity.API/Views/Shared/_Layout.cshtml | 12 ++++++-- .../Identity/Identity.API/bundleconfig.json | 2 +- src/Web/WebMVC/Views/Shared/_Layout.cshtml | 2 +- src/Web/WebMVC/WebMVC.csproj | 30 +++++++++---------- src/Web/WebMVC/bundleconfig.json | 2 +- src/Web/WebMVC/wwwroot/css/app.min.css | 1 - src/Web/WebMVC/wwwroot/css/site.min.css | 1 + 8 files changed, 44 insertions(+), 35 deletions(-) delete mode 100644 src/Web/WebMVC/wwwroot/css/app.min.css diff --git a/src/Services/Identity/Identity.API/Identity.API.csproj b/src/Services/Identity/Identity.API/Identity.API.csproj index b810aae66..2f56fd38d 100644 --- a/src/Services/Identity/Identity.API/Identity.API.csproj +++ b/src/Services/Identity/Identity.API/Identity.API.csproj @@ -14,18 +14,17 @@ - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - + + + + + + + + + + + @@ -66,7 +65,7 @@ - + @@ -78,4 +77,8 @@ + + + + diff --git a/src/Services/Identity/Identity.API/Views/Shared/_Layout.cshtml b/src/Services/Identity/Identity.API/Views/Shared/_Layout.cshtml index 5086d12ec..9d0a5ce8a 100644 --- a/src/Services/Identity/Identity.API/Views/Shared/_Layout.cshtml +++ b/src/Services/Identity/Identity.API/Views/Shared/_Layout.cshtml @@ -6,8 +6,16 @@ eShopOnContainers Identity - - + + + + + + + +