Skip to content

Commit

Permalink
cleaning up docker file and other various things before starting on a…
Browse files Browse the repository at this point in the history
…ngular
  • Loading branch information
LewkyB committed Jan 23, 2022
1 parent f3ae3da commit 2b994a8
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 44 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
**/env.acme-companion
**/.nginx
LICENSE
README.md
1 change: 1 addition & 0 deletions .env.acme-companion-example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DEFAULT_EMAIL=<Fill email for letsencypt https>
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ config.json
*.userosscache
*.sln.docstates

# nginx-proxy
.env.acme-companion
.nginx

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

Expand Down Expand Up @@ -455,3 +459,4 @@ $RECYCLE.BIN/
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
/Dockerfile.original
3 changes: 1 addition & 2 deletions Program.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<IServiceScopeFactory>();
Expand Down
19 changes: 2 additions & 17 deletions Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<SubredditContext>(options =>
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -147,9 +134,6 @@ public void ConfigureServices(IServiceCollection services)

app.UseMiniProfiler();

// TODO: not sure what this is yet
//app.UseW3CLogging();

app.UseStatusCodePages();
}
else
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Views/subreddit/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<div class="columns">

@foreach (string subreddit in Model)
@foreach (var subreddit in Model)
{
if (counter > 0 && counter % 4 == 0)
{
Expand All @@ -14,7 +14,7 @@
}
<div class="column text-center">
@*TODO: how to get rid of subreddit and just make it default*@
<a href="~/Subreddit/@subreddit/Links/desc">@subreddit</a>
<a href="~/Subreddit/@subreddit/Links">@subreddit</a>
</div>

counter++;
Expand Down
2 changes: 1 addition & 1 deletion appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
},
"ConnectionStrings": {
"PostgreSQL": "host=db;database=SubredditDb;username=postgres;password=postgres",
"Redis": "redis:6379,abortConnect=False"
"Redis": "redis,abortConnect=False"
}
}
8 changes: 2 additions & 6 deletions docker-compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
- "80"
6 changes: 1 addition & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand Down
12 changes: 1 addition & 11 deletions nlog.config
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogLevel="Info"
internalLogFile="c:\temp\internal-nlog-AspNetCore.txt">
autoReload="true">

<!-- enable asp.net core layout renderers -->
<extensions>
Expand All @@ -29,13 +27,5 @@
<!--All logs, including from Microsoft-->
<logger name="*" minlevel="Debug" writeTo="lifetimeConsole" />

<!--Output hosting lifetime messages to console target for faster startup detection -->
<logger name="Microsoft.Hosting.Lifetime" minlevel="Info" writeTo="lifetimeConsole, ownFile-web" final="true" />

<!--Skip non-critical Microsoft logs and so log only own logs (BlackHole) -->
<logger name="Microsoft.*" maxlevel="Info" final="true" />
<logger name="System.Net.Http.*" maxlevel="Info" final="true" />

<logger name="*" minlevel="Trace" writeTo="ownFile-web" />
</rules>
</nlog>

0 comments on commit 2b994a8

Please sign in to comment.