-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d6f0c9a
commit 33361c4
Showing
20 changed files
with
212 additions
and
129 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM nginx | ||
COPY nginx/nginx.prod.conf /etc/nginx/nginx.conf | ||
COPY nginx/devstore.conf /etc/nginx/conf.d/devstore.conf | ||
COPY nginx/nerdstore-certificate.pem /etc/nginx | ||
COPY nginx/nerdstore-certificate.key /etc/nginx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
|
||
upstream web-mvc { | ||
server web-mvc:5001; | ||
} | ||
|
||
upstream rabbitmq { | ||
least_conn; | ||
server devstore-rabbit:15672; | ||
} | ||
|
||
server { | ||
listen 80; | ||
server_name $hostname; | ||
|
||
location /rabbitmq/ { | ||
rewrite ^/rabbitmq/(.*)$ /$1 break; | ||
proxy_pass http://rabbitmq; | ||
proxy_buffering off; | ||
proxy_set_header Host $http_host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
} | ||
|
||
location / { | ||
# Google doesn't like 302 redirects, so we use a 301 here | ||
return 301 https://$host:7501$request_uri; | ||
} | ||
} | ||
|
||
server { | ||
listen 443 ssl; | ||
server_name $hostname; | ||
|
||
ssl_protocols TLSv1.2 TLSv1.3; | ||
ssl_ciphers HIGH:!aNULL:!MD5; | ||
|
||
ssl_certificate /etc/nginx/nerdstore-certificate.pem; | ||
ssl_certificate_key /etc/nginx/nerdstore-certificate.key; | ||
|
||
location /rabbitmq/ { | ||
return 302 http://$host:7500$request_uri; | ||
} | ||
|
||
location / { | ||
proxy_pass http://web-mvc; | ||
proxy_redirect off; | ||
proxy_http_version 1.1; | ||
proxy_set_header Connection keep-alive; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
proxy_set_header X-Forwarded-Host $server_name; | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/building-blocks/DevStore.WebAPI.Core/DatabaseFlavor/ContextConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System; | ||
using System.Linq; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace DevStore.WebAPI.Core.DatabaseFlavor; | ||
|
||
/// <summary> | ||
/// SqlServer configuration | ||
/// </summary> | ||
public static class ContextConfiguration | ||
{ | ||
|
||
/// <summary> | ||
/// ASP.NET Identity Context config | ||
/// </summary> | ||
public static IServiceCollection PersistStore<TContext>(this IServiceCollection services, Action<DbContextOptionsBuilder> databaseConfig) where TContext : DbContext | ||
{ | ||
// Add a DbContext to store Keys. SigningCredentials and DataProtectionKeys | ||
if (services.All(x => x.ServiceType != typeof(TContext))) | ||
services.AddDbContext<TContext>(databaseConfig); | ||
return services; | ||
} | ||
|
||
|
||
} |
9 changes: 9 additions & 0 deletions
9
src/building-blocks/DevStore.WebAPI.Core/DatabaseFlavor/DatabaseType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace DevStore.WebAPI.Core.DatabaseFlavor; | ||
|
||
public enum DatabaseType | ||
{ | ||
SqlServer, | ||
MySql, | ||
Postgre, | ||
Sqlite, | ||
} |
43 changes: 43 additions & 0 deletions
43
src/building-blocks/DevStore.WebAPI.Core/DatabaseFlavor/ProviderConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
using System.Reflection; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.Extensions.Configuration; | ||
using MySqlConnector; | ||
|
||
namespace DevStore.WebAPI.Core.DatabaseFlavor; | ||
|
||
public class ProviderConfiguration | ||
{ | ||
private readonly string _connectionString; | ||
public static ProviderConfiguration With; | ||
private static readonly string MigrationAssembly = typeof(ProviderConfiguration).GetTypeInfo().Assembly.GetName().Name; | ||
|
||
public static void Build(string connString) | ||
{ | ||
if (With is null) | ||
With = new ProviderConfiguration(connString); | ||
} | ||
|
||
public ProviderConfiguration(string connString) => _connectionString = connString; | ||
|
||
public Action<DbContextOptionsBuilder> SqlServer => | ||
options => options.UseSqlServer(_connectionString, sql => sql.MigrationsAssembly(MigrationAssembly)); | ||
|
||
public Action<DbContextOptionsBuilder> MySql => | ||
options => options.UseMySql(_connectionString, ServerVersion.AutoDetect(_connectionString), sql => sql.MigrationsAssembly(MigrationAssembly)); | ||
|
||
public Action<DbContextOptionsBuilder> Postgre => | ||
options => options.UseNpgsql(_connectionString, sql => sql.MigrationsAssembly(MigrationAssembly)); | ||
|
||
public Action<DbContextOptionsBuilder> Sqlite => | ||
options => options.UseSqlite(_connectionString, sql => sql.MigrationsAssembly(MigrationAssembly)); | ||
|
||
|
||
/// <summary> | ||
/// it's just a tuple. Returns 2 parameters. | ||
/// Trying to improve readability at ConfigureServices | ||
/// </summary> | ||
public static (DatabaseType, string) DetectDatabase(IConfiguration configuration) => ( | ||
configuration.GetValue<DatabaseType>("AppSettings:DatabaseType"), | ||
configuration.GetConnectionString("DefaultConnection")); | ||
} |
Oops, something went wrong.