Skip to content

Commit

Permalink
add deployment environments and disable webhook on local
Browse files Browse the repository at this point in the history
  • Loading branch information
loukylor committed Dec 31, 2024
1 parent a38fba8 commit d9371a9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ WORKDIR /data
# Run the app on container startup
EXPOSE 8080/tcp
ENV DOTNET_GCHeapHardLimit=0xF424000
ENV DOTNET_ENVIRONMENT=Production
ENTRYPOINT [ "dotnet", "/TrickFireDiscordBot/TrickFireDiscordBot.dll", "/TrickFireDiscordBot/" ]
10 changes: 10 additions & 0 deletions TrickFireDiscordBot/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"profiles": {
"TrickFireDiscordBot": {
"commandName": "Project",
"environmentVariables": {
"DOTNET_ENVIRONMENT": "Development"
}
}
}
}
14 changes: 13 additions & 1 deletion TrickFireDiscordBot/Services/WebhookListener.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System.Net;
Expand Down Expand Up @@ -66,6 +67,17 @@ public override void Dispose()

public static void Register(IHostApplicationBuilder builder)
{
if (builder.Environment.IsDevelopment())
{
// I'm going to assume most people can't listen on every ip on their
// dev machine, nor receive data from trickfirediscordbot.fly.dev
// So just initialize it as a singleton, which doesn't receive start
// events
builder.Services
.AddSingleton<WebhookListener>();
return;
}

builder.Services
.AddInjectableHostedService<WebhookListener>()
.ConfigureTypeSection<WebhookListenerOptions>(builder.Configuration);
Expand Down

0 comments on commit d9371a9

Please sign in to comment.