Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local deployment on par with future prod #306

Merged
merged 36 commits into from
Sep 6, 2021
Merged

Conversation

DmyMi
Copy link
Contributor

@DmyMi DmyMi commented Aug 30, 2021

Disclaimer

Lots of changes, but more than half of them are due to moving files from one namespace to another.

This is a first set of changes. Rest will mostly include changes to compose files & nginx config.

Contents

  • Add api versioning (with backward compatibility so frontend can transition seamlessly) to easily support breaking changes to production later. As per MS Recommendations & example on the internet
  • Add reverse proxy configuration with optional base path as per MS Documentation. Depending on final deployment we will either have a single host & basepath or two virtual hosts & no basepath. This change allows to work with both approaches without changing any part of application except appsettings & some env variables.
  • Refactor delay in Program.cs and increased it to 5 seconds so that Identity won't spam SQL with requests on startup.
  • Add first iteration of Nginx config for local deployment in compose
  • Add Compose environment settings for local compose deployments.
  • Add local automated dev environment to simulate production. It works using a single set of tools & one command on MacOS (tested on Big Sur 11.5), Linux (tested on Ubuntu 20.04.3) & Windows 10 (but on Windows work means it doesn't ~50% of time, depending on Win10 build :) )
  • Add supplementary scripts (powershell & bash) to support local dev environment
  • Add first iteration of Readme & with aforementioned environment launch docs

services.Configure<ForwardedHeadersOptions>(options =>
{
options.ForwardedHeaders =
ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be moved to appconfig.json smth like a 'ProxyConfig' section ?

/// </summary>
public static IApplicationBuilder UseProxy(this IApplicationBuilder app, IConfiguration configuration)
{
string basePath = configuration["REVERSE_PROXY_BASEPATH"];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move REVERSE_PROXY_BASEPATH into the public constant of the configuration section ?

@@ -17,6 +17,8 @@ namespace OutOfSchool.IdentityServer
{
public class Program
{
private static readonly int CHECK_CONNECTIVITY_DELAY = 5000;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can use const instead of static readonly here.

Console.WriteLine("Waiting for db connection");
Task.Delay(CHECK_CONNECTIVITY_DELAY).Wait();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Console.WriteLine("Waiting for db connection"); looks like logger.Trace
Also, should we add a timeout or cancellation for the wait mechanism ?

@@ -0,0 +1,36 @@
{
"ConnectionStrings": {
"DefaultConnection": "Server=sql-server; Database=Master;User Id=SA;Password=Oos-password1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we are using internal main MSSQL database (Database=Master) for our project ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will update this in next PR.

{
string swaggerEndpoint;

string basePath = configuration["REVERSE_PROXY_BASEPATH"];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've seen REVERSE_PROXY_BASEPATH before, please move to const

<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="5.6.3" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="5.6.3" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="5.6.3" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.1.3" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have a document with all third party libraries we are using ?
e.g. output of the Get-Package | select Id, Version, LicenseUrl running from vs console

{
[ApiController]
[ApiVersion("1.0")]
[Route("api/v{version:apiVersion}/[controller]/[action]")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of changing each and every Controller couldn't routing be configured via Conventional routing ? (In Startup.Configure)

@@ -107,7 +109,7 @@ public async Task<IActionResult> GetByFilter([FromQuery] WorkshopFilter filter)
{
if (string.IsNullOrWhiteSpace(filter.City))
{
filter.City = "���";
filter.City = "Київ";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Київ" - should be Default_City constant introduced somewhere, but not in WorkshopController

@DmyMi DmyMi force-pushed the feature/compose_stack branch from ea5efb0 to d39e05f Compare September 6, 2021 07:29
@sonarqubecloud
Copy link

sonarqubecloud bot commented Sep 6, 2021

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 43 Code Smells

75.1% 75.1% Coverage
0.0% 0.0% Duplication

@DmyMi DmyMi merged commit 2b1134a into develop Sep 6, 2021
@DmyMi DmyMi deleted the feature/compose_stack branch September 6, 2021 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants