So i have a .NET app I can run on docker just fine using a docker-compose up --build
, but once I do a deployment to fly, I get something along the lines of the below. I’ve tried lots of different iterations to no avail. Check out the repo here
File Highlights
Program.cs
namespace RecipeManagement;
using Autofac.Extensions.DependencyInjection;
using Serilog;
using System.Reflection;
using System.Threading.Tasks;
using RecipeManagement.Extensions.Host;
public class Program
{
public async static Task Main(string[] args)
{
var host = CreateHostBuilder(args).Build();
host.AddLoggingConfiguration();
try
{
Log.Information("Starting application");
await host.RunAsync();
}
catch (Exception e)
{
Log.Error(e, "The application failed to start correctly");
throw;
}
finally
{
Log.Information("Shutting down application");
Log.CloseAndFlush();
}
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseSerilog()
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup(typeof(Startup).GetTypeInfo().Assembly.FullName)
.UseContentRoot(Directory.GetCurrentDirectory())
.UseKestrel();
});
}
Dockerfile
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY ["RecipeManagement.csproj", "./"]
RUN dotnet restore "./RecipeManagement.csproj"
# Copy everything else and build
COPY . ./
RUN dotnet build "RecipeManagement.csproj" -c Release -o /app/build
FROM build-env AS publish
RUN dotnet publish "RecipeManagement.csproj" -c Release -o /app/out
# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:6.0
COPY --from=publish /app/out .
ENV ASPNETCORE_URLS=https://+:8080
EXPOSE 8080
EXPOSE 443
ENTRYPOINT ["dotnet", "RecipeManagement.dll"]
fly.toml
app = "weathered-fog-7393"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []
[env]
ASPNETCORE_ENVIRONMENT = "Development"
ASPNETCORE_Kestrel__Certificates__Default__Path = "/https/aspnetappcert.pfx"
ASPNETCORE_Kestrel__Certificates__Default__Password = "password"
[experimental]
allowed_public_ports = []
auto_rollback = true
[[services]]
http_checks = []
internal_port = 8080
processes = ["app"]
protocol = "tcp"
script_checks = []
[services.concurrency]
hard_limit = 25
soft_limit = 20
type = "connections"
[[services.ports]]
handlers = ["tls", "http"]
port = 443
[[services.tcp_checks]]
grace_period = "1s"
interval = "15s"
restart_limit = 0
timeout = "2s"
The Error
Recent Events
TIMESTAMP TYPE MESSAGE
2022-01-09T01:17:05Z Received Task received by client
2022-01-09T01:17:05Z Task Setup Building Task Directory
2022-01-09T01:17:06Z Started Task started by client
2022-01-09T01:17:10Z Terminated Exit Code: 134
2022-01-09T01:17:10Z Restarting Task restarting in 1.030703432s
2022-01-09T01:17:16Z Started Task started by client
2022-01-09T01:17:20Z Terminated Exit Code: 134
2022-01-09T01:17:20Z Restarting Task restarting in 1.217449511s
2022-01-09T01:17:26Z Started Task started by client
2022-01-09T01:17:30Z Terminated Exit Code: 134
2022-01-09T01:17:30Z Not Restarting Exceeded allowed attempts 2 in interval 5m0s and mode is "fail"
2022-01-09T01:17:30Z Alloc Unhealthy Unhealthy because of failed task
2022-01-09T01:17:31Z Killing Sent interrupt. Waiting 5s before force killing
2022-01-09T01:17:29.000 [info] at Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.LoadDefaultCert()
2022-01-09T01:17:29.000 [info] at Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.Reload()
2022-01-09T01:17:29.000 [info] at Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.Load()
2022-01-09T01:17:29.000 [info] at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.BindAsync(CancellationToken cancellationToken)
2022-01-09T01:17:29.000 [info] at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
2022-01-09T01:17:29.000 [info] at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
2022-01-09T01:17:29.000 [info] at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
2022-01-09T01:17:29.000 [info] at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
2022-01-09T01:17:29.000 [info] at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
2022-01-09T01:17:29.000 [info] at RecipeManagement.Program.Main(String[] args) in /app/Program.cs:line 19
2022-01-09T01:17:29.000 [info] [01:17:29 INF] Shutting down application
2022-01-09T01:17:29.000 [info] Unhandled exception. Interop+Crypto+OpenSslCryptographicException: error:2006D080:BIO routines:BIO_new_file:no such file
2022-01-09T01:17:29.000 [info] at Interop.Crypto.CheckValidOpenSslHandle(SafeHandle handle)
2022-01-09T01:17:29.000 [info] at Internal.Cryptography.Pal.OpenSslX509CertificateReader.FromFile(String fileName, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags)
2022-01-09T01:17:29.000 [info] at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(String fileName, String password, X509KeyStorageFlags keyStorageFlags)
2022-01-09T01:17:29.000 [info] at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(String fileName, String password)
2022-01-09T01:17:29.000 [info] at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Certificates.CertificateConfigLoader.LoadCertificate(CertificateConfig certInfo, String endpointName)
2022-01-09T01:17:29.000 [info] at Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.LoadDefaultCert()
2022-01-09T01:17:29.000 [info] at Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.Reload()
2022-01-09T01:17:29.000 [info] at Microsoft.AspNetCore.Server.Kestrel.KestrelConfigurationLoader.Load()
2022-01-09T01:17:29.000 [info] at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.BindAsync(CancellationToken cancellationToken)
2022-01-09T01:17:29.000 [info] at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
2022-01-09T01:17:29.000 [info] at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
2022-01-09T01:17:29.000 [info] at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
2022-01-09T01:17:29.000 [info] at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
2022-01-09T01:17:29.000 [info] at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
2022-01-09T01:17:29.000 [info] at RecipeManagement.Program.Main(String[] args) in /app/Program.cs:line 19
2022-01-09T01:17:29.000 [info] at RecipeManagement.Program.<Main>(String[] args)
2022-01-09T01:17:29.000 [info] Main child exited with signal (with signal 'SIGABRT', core dumped? false)
2022-01-09T01:17:29.000 [info] Starting clean up.