From 2b994a8b627d21779ad804916ad5e8e966f38062 Mon Sep 17 00:00:00 2001 From: luke brown Date: Sun, 23 Jan 2022 12:21:49 -0600 Subject: [PATCH] cleaning up docker file and other various things before starting on angular --- .dockerignore | 2 ++ .env.acme-companion-example | 1 + .gitignore | 5 +++++ Program.cs | 3 +-- Startup.cs | 19 ++----------------- Views/subreddit/Index.cshtml | 4 ++-- appsettings.json | 2 +- docker-compose.override.yml | 8 ++------ docker-compose.yml | 6 +----- nlog.config | 12 +----------- 10 files changed, 18 insertions(+), 44 deletions(-) create mode 100644 .env.acme-companion-example diff --git a/.dockerignore b/.dockerignore index 3729ff0..c882a40 100644 --- a/.dockerignore +++ b/.dockerignore @@ -21,5 +21,7 @@ **/obj **/secrets.dev.yaml **/values.dev.yaml +**/env.acme-companion +**/.nginx LICENSE README.md \ No newline at end of file diff --git a/.env.acme-companion-example b/.env.acme-companion-example new file mode 100644 index 0000000..fbd0b2c --- /dev/null +++ b/.env.acme-companion-example @@ -0,0 +1 @@ +DEFAULT_EMAIL= \ No newline at end of file diff --git a/.gitignore b/.gitignore index e5883bb..226ec06 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,10 @@ config.json *.userosscache *.sln.docstates +# nginx-proxy +.env.acme-companion +.nginx + # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs @@ -455,3 +459,4 @@ $RECYCLE.BIN/ !.vscode/tasks.json !.vscode/launch.json !.vscode/extensions.json +/Dockerfile.original diff --git a/Program.cs b/Program.cs index 630a145..337b50c 100644 --- a/Program.cs +++ b/Program.cs @@ -1,6 +1,5 @@ using luke_site_mvc.Data; using Microsoft.AspNetCore.Hosting; -using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; @@ -40,7 +39,7 @@ public static async Task Main(string[] args) } } - // right now this isn't used to do any seeding of data, it is only setting up tables + // right now this isn't used to do any seeding of data, it is only setting up tables for miniprofiler private static async Task RunSeedingAsync(IHost host) { var scopeFactory = host.Services.GetService(); diff --git a/Startup.cs b/Startup.cs index 3d2c89d..f593cc3 100644 --- a/Startup.cs +++ b/Startup.cs @@ -3,7 +3,6 @@ using luke_site_mvc.Services.BackgroundServices; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.HttpLogging; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Caching.Distributed; using Microsoft.Extensions.Configuration; @@ -66,7 +65,7 @@ public void ConfigureServices(IServiceCollection services) services.AddStackExchangeRedisCache(options => { options.Configuration = Configuration.GetConnectionString("Redis"); - options.InstanceName = "IRCTube_"; + options.InstanceName = "LukeTube_"; }); services.AddDbContext(options => @@ -105,18 +104,6 @@ public void ConfigureServices(IServiceCollection services) options.IgnoredPaths.Add("/lib/"); }).AddEntityFramework(); - // TODO: not sure what this is yet - //services.AddW3CLogging(logging => - //{ - // logging.LoggingFields = W3CLoggingFields.All; - - // logging.FileSizeLimit = 5 * 1024 * 1024; - // logging.RetainedFileCountLimit = 2; - // logging.FileName = "MyLogFile"; - // logging.LogDirectory = @"C:\logs"; - // logging.FlushInterval = TimeSpan.FromSeconds(2); - //}); - services.AddResponseCaching(); services.AddDatabaseDeveloperPageExceptionFilter(); @@ -147,9 +134,6 @@ public void ConfigureServices(IServiceCollection services) app.UseMiniProfiler(); - // TODO: not sure what this is yet - //app.UseW3CLogging(); - app.UseStatusCodePages(); } else @@ -158,6 +142,7 @@ public void ConfigureServices(IServiceCollection services) // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); + // not sure if this is needed since nginx is handling https app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto diff --git a/Views/subreddit/Index.cshtml b/Views/subreddit/Index.cshtml index 6b80db6..36d852a 100644 --- a/Views/subreddit/Index.cshtml +++ b/Views/subreddit/Index.cshtml @@ -5,7 +5,7 @@
- @foreach (string subreddit in Model) + @foreach (var subreddit in Model) { if (counter > 0 && counter % 4 == 0) { @@ -14,7 +14,7 @@ }
@*TODO: how to get rid of subreddit and just make it default*@ - @subreddit + @subreddit
counter++; diff --git a/appsettings.json b/appsettings.json index 90382aa..5b70cd7 100644 --- a/appsettings.json +++ b/appsettings.json @@ -8,6 +8,6 @@ }, "ConnectionStrings": { "PostgreSQL": "host=db;database=SubredditDb;username=postgres;password=postgres", - "Redis": "redis:6379,abortConnect=False" + "Redis": "redis,abortConnect=False" } } \ No newline at end of file diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 474d6f3..3e6c006 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -4,10 +4,6 @@ services: luke_site_mvc: environment: - ASPNETCORE_ENVIRONMENT=Production - - ASPNETCORE_URLS=https://+:443;http://+:80 + - ASPNETCORE_URLS=http://+:80 ports: - - "80" - - "443" - volumes: - - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro - - ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro \ No newline at end of file + - "80" \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 14d521e..a6b5a9d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,7 +11,7 @@ services: - redis restart: always environment: - - LETSENCRYPT_HOST=luketube.net + - LETSENCRYPT_HOST=luketube.net, www.luketube.net - VIRTUAL_HOST=luketube.net - VIRTUAL_PORT=80 @@ -21,16 +21,12 @@ services: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres POSTGRES_DB: SubredditDb - ports: - - 5432:5432 restart: always volumes: - ./postgres-data:/var/lib/postgresql/data redis: image: redis:6.2.6 - ports: - - 6379:6379 restart: always nginx-proxy: diff --git a/nlog.config b/nlog.config index 2114538..2525223 100644 --- a/nlog.config +++ b/nlog.config @@ -1,9 +1,7 @@  + autoReload="true"> @@ -29,13 +27,5 @@ - - - - - - - -