Deploying .NET Core application to droplet using Dokku.

April 25, 2018 2.1k views
Dokku Ubuntu 16.04

I am attempting to install Dokku on my droplet and use it to host a .NET Core website application through Dokku's ability to deal with Dockerfiles on the fly.

This is the test repository I am trying to use:
https://github.com/dotnet/dotnet-docker/tree/master/samples/aspnetapp

After going through the standard process of setting up the application via SSH on my droplet, I then created a local git repository and commit and pushed what was needed, resulting in the output below.

From what I can see, dokku picked up on the dockerfile fine and the .NET Core build process went through fine. However once I navigate to my droplet on the port, I get the "We're sorry, but something went wrong. If you are the application owner check the logs for more information" message.

$ git push aspnetapp master
Counting objects: 104, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (97/97), done.
Writing objects: 100% (104/104), 533.39 KiB | 4.44 MiB/s, done.
Total 104 (delta 7), reused 0 (delta 0)
-----> Cleaning up...
-----> Building aspnetapp from dockerfile...
-----> Setting config vars
       DOKKU_DOCKERFILE_ENTRYPOINT:  ENTRYPOINT ["dotnet", "aspnetapp.dll"]
remote: build context to Docker daemon  2.447MB
Step 1/13 : FROM microsoft/dotnet:2.0-sdk AS build
 ---> 7cae39fff25f
Step 2/13 : WORKDIR /app
Removing intermediate container 34bf02c4c3e5
 ---> 5c84b1cb1d6a
Step 3/13 : COPY *.sln .
 ---> c7d6f8ca8169
Step 4/13 : COPY aspnetapp/*.csproj ./aspnetapp/
 ---> e7cf68c9cb51
Step 5/13 : RUN dotnet restore
 ---> Running in 618e9ca85ae4
  Restoring packages for /app/aspnetapp/aspnetapp.csproj...
  Installing System.Data.SqlClient 4.4.0.
  Installing Microsoft.EntityFrameworkCore.SqlServer 2.0.1.
  Installing Microsoft.Extensions.Caching.SqlServer 2.0.0.
  Installing Microsoft.Extensions.Identity.Core 2.0.1.
  Installing Microsoft.VisualStudio.Web.BrowserLink 2.0.1.
  Installing Microsoft.Extensions.Logging.EventSource 2.0.0.
  Installing Microsoft.Extensions.Logging.Console 2.0.0.
  Installing Microsoft.Extensions.Logging.AzureAppServices 2.0.0.
  Installing Microsoft.Extensions.Logging 2.0.0.
  Installing Microsoft.Extensions.Localization 2.0.1.
  Installing Microsoft.Extensions.Identity.Stores 2.0.1.
  Installing Microsoft.Extensions.Logging.TraceSource 2.0.0.
  Installing Microsoft.Extensions.WebEncoders 2.0.0.
  Installing Microsoft.Extensions.Logging.Configuration 2.0.0.
  Installing Microsoft.Extensions.Hosting.Abstractions 2.0.1.
  Installing Microsoft.Extensions.DiagnosticAdapter 2.0.0.
  Installing Microsoft.EntityFrameworkCore.Tools 2.0.1.
  Installing Microsoft.EntityFrameworkCore.Sqlite.Core 2.0.1.
  Installing Microsoft.EntityFrameworkCore 2.0.1.
  Installing Microsoft.AspNetCore.Razor.Language 2.0.1.
  Installing Microsoft.Extensions.Configuration.UserSecrets 2.0.0.
  Installing Microsoft.Extensions.Configuration.CommandLine 2.0.0.
  Installing Microsoft.Extensions.Configuration.AzureKeyVault 2.0.0.
  Installing Microsoft.EntityFrameworkCore.InMemory 2.0.1.
  Installing Microsoft.AspNetCore.Routing 2.0.1.
  Installing Microsoft.Extensions.Caching.Memory 2.0.0.
  Installing Microsoft.Extensions.Caching.Abstractions 2.0.0.
  Installing Microsoft.Data.Sqlite.Core 2.0.0.
  Installing Microsoft.AspNetCore.ResponseCaching.Abstractions 2.0.1.
  Installing Microsoft.AspNetCore.Server.Kestrel.Https 2.0.1.
  Installing Microsoft.AspNetCore.StaticFiles 2.0.1.
  Installing Microsoft.AspNetCore.Razor.Runtime 2.0.1.
  Installing Microsoft.AspNetCore.Mvc.RazorPages 2.0.2.
  Installing Microsoft.AspNetCore.Mvc.Abstractions 2.0.2.
  Installing Microsoft.AspNetCore.Mvc.Localization 2.0.2.
  Installing Microsoft.AspNetCore.Mvc.Razor.Extensions 2.0.1.
  Installing Microsoft.AspNetCore.ResponseCompression 2.0.1.
  Installing Microsoft.AspNetCore.Rewrite 2.0.1.
  Installing Microsoft.AspNetCore.Mvc.TagHelpers 2.0.2.
  Installing Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions 2.0.1.
  Installing Microsoft.AspNetCore.NodeServices 2.0.2.
  Installing Microsoft.AspNetCore.Localization.Routing 2.0.1.
  Installing Microsoft.AspNetCore.Mvc.Razor 2.0.2.
  Installing Microsoft.AspNetCore.Mvc.Formatters.Json 2.0.2.
  Installing Microsoft.AspNetCore.MiddlewareAnalysis 2.0.1.
  Installing Microsoft.AspNetCore.Identity 2.0.1.
  Installing Microsoft.AspNetCore.Identity.EntityFrameworkCore 2.0.1.
  Installing Microsoft.AspNetCore.Mvc.Razor.ViewCompilation 2.0.2.
  Installing Microsoft.Extensions.Logging.Debug 2.0.0.
  Installing Microsoft.Extensions.Options.ConfigurationExtensions 2.0.0.
  Installing Microsoft.Extensions.FileProviders.Composite 2.0.0.
  Installing Microsoft.Extensions.FileProviders.Embedded 2.0.0.
  Installing Microsoft.EntityFrameworkCore.Sqlite 2.0.1.
  Installing Microsoft.EntityFrameworkCore.Relational 2.0.1.
  Installing Microsoft.EntityFrameworkCore.Design 2.0.1.
  Installing Microsoft.Extensions.Options 2.0.0.
  Installing Microsoft.Extensions.Configuration.Ini 2.0.0.
  Installing Microsoft.CodeAnalysis.Razor 2.0.1.
  Installing Microsoft.AspNetCore.All 2.0.5.
  Installing Microsoft.AspNetCore.Authentication.MicrosoftAccount 2.0.1.
  Installing Microsoft.AspNetCore.Authorization.Policy 2.0.1.
  Installing Microsoft.AspNetCore.Authentication.JwtBearer 2.0.1.
  Installing Microsoft.Extensions.Configuration.Abstractions 2.0.0.
  Installing Microsoft.AspNetCore.Authentication.Cookies 2.0.1.
  Installing Microsoft.AspNetCore.Antiforgery 2.0.1.
  Installing Microsoft.AspNetCore.Authentication.Abstractions 2.0.1.
  Installing Microsoft.Extensions.FileProviders.Abstractions 2.0.0.
  Installing Microsoft.AspNetCore.Hosting.Server.Abstractions 2.0.1.
  Installing Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv 2.0.1.
  Installing Microsoft.AspNetCore.CookiePolicy 2.0.1.
  Installing Microsoft.Extensions.FileSystemGlobbing 2.0.0.
  Installing Microsoft.Extensions.Configuration.EnvironmentVariables 2.0.0.
  Installing Microsoft.Extensions.Configuration 2.0.0.
  Installing Microsoft.AspNetCore.Server.IISIntegration 2.0.1.
  Installing Microsoft.AspNetCore.Mvc.ViewFeatures 2.0.2.
  Installing Microsoft.AspNetCore.Server.Kestrel 2.0.1.
  Installing Microsoft.Extensions.FileProviders.Physical 2.0.0.
  Installing Microsoft.AspNetCore.DataProtection.Extensions 2.0.1.
  Installing Microsoft.AspNetCore 2.0.1.
  Installing Microsoft.AspNetCore.Cryptography.KeyDerivation 2.0.1.
  Installing Microsoft.AspNetCore.AzureAppServicesIntegration 2.0.1.
  Installing Microsoft.Net.Http.Headers 2.0.1.
  Installing Microsoft.AspNetCore.Diagnostics.Abstractions 2.0.1.
  Installing Microsoft.AspNetCore.Html.Abstractions 2.0.0.
  Installing Microsoft.AspNetCore.HttpOverrides 2.0.1.
  Installing Microsoft.AspNetCore.Authentication.Core 2.0.1.
  Installing Microsoft.AspNetCore.Mvc.Formatters.Xml 2.0.2.
  Installing Microsoft.AspNetCore.Mvc.DataAnnotations 2.0.2.
  Installing Microsoft.AspNetCore.Authentication.Google 2.0.1.
  Installing Microsoft.AspNetCore.Authentication.Twitter 2.0.1.
  Installing Microsoft.AspNetCore.Authentication.Facebook 2.0.1.
  Installing Microsoft.AspNetCore.Cors 2.0.1.
  Installing Microsoft.AspNetCore.DataProtection.Abstractions 2.0.1.
  Installing Microsoft.AspNetCore.Authentication.OAuth 2.0.1.
  Installing Microsoft.AspNetCore.Hosting.Abstractions 2.0.1.
  Installing Microsoft.AspNetCore.Authorization 2.0.1.
  Installing Microsoft.AspNetCore.Http.Extensions 2.0.1.
  Installing Microsoft.AspNetCore.Mvc.Cors 2.0.2.
  Installing Microsoft.AspNetCore.Cryptography.Internal 2.0.1.
  Installing Microsoft.AspNetCore.Http.Features 2.0.1.
  Installing Microsoft.AspNetCore.Authentication 2.0.1.
  Installing Microsoft.AspNetCore.AzureAppServices.HostingStartup 2.0.1.
  Installing Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore 2.0.1.
  Installing Microsoft.AspNetCore.Localization 2.0.1.
  Installing Microsoft.AspNetCore.Mvc.Core 2.0.2.
  Installing Microsoft.AspNetCore.Http 2.0.1.
  Installing Microsoft.AspNetCore.Http.Abstractions 2.0.1.
  Installing Microsoft.AspNetCore.Mvc 2.0.2.
  Installing Microsoft.AspNetCore.Hosting 2.0.1.
  Installing Microsoft.AspNetCore.Routing.Abstractions 2.0.1.
  Installing Microsoft.AspNetCore.Session 2.0.1.
  Installing Microsoft.Extensions.Configuration.FileExtensions 2.0.0.
  Installing Microsoft.AspNetCore.Mvc.ApiExplorer 2.0.2.
  Installing Microsoft.Extensions.Logging.Abstractions 2.0.0.
  Installing Microsoft.AspNetCore.WebUtilities 2.0.1.
  Installing Microsoft.AspNetCore.Authentication.OpenIdConnect 2.0.1.
  Installing Microsoft.AspNetCore.SpaServices 2.0.2.
  Installing Microsoft.Extensions.Configuration.Binder 2.0.0.
  Installing Microsoft.Extensions.Configuration.Json 2.0.0.
  Installing Microsoft.Extensions.Caching.Redis 2.0.0.
  Installing Microsoft.AspNetCore.DataProtection 2.0.1.
  Installing Microsoft.Extensions.Configuration.Xml 2.0.0.
  Installing Microsoft.AspNetCore.ApplicationInsights.HostingStartup 2.0.1.
  Installing Microsoft.AspNetCore.DataProtection.AzureStorage 2.0.1.
  Installing Microsoft.AspNetCore.Diagnostics 2.0.1.
  Installing Microsoft.AspNetCore.Server.HttpSys 2.0.1.
  Installing Microsoft.AspNetCore.ResponseCaching 2.0.1.
  Installing Microsoft.Data.Sqlite 2.0.0.
  Installing Microsoft.AspNetCore.WebSockets 2.0.1.
  Installing Microsoft.AspNetCore.Razor 2.0.1.
  Installing Microsoft.AspNetCore.Server.Kestrel.Core 2.0.1.
  Installing Microsoft.AspNetCore.Owin 2.0.1.
  Installing Microsoft.Extensions.Localization.Abstractions 2.0.1.
  Generating MSBuild file /app/aspnetapp/obj/aspnetapp.csproj.nuget.g.props.
  Generating MSBuild file /app/aspnetapp/obj/aspnetapp.csproj.nuget.g.targets.
  Restore completed in 5.57 sec for /app/aspnetapp/aspnetapp.csproj.
  Restoring packages for /app/aspnetapp/aspnetapp.csproj...
  Installing Microsoft.DotNet.Watcher.Tools 2.0.0.
  Restore completed in 817.77 ms for /app/aspnetapp/aspnetapp.csproj.
  Restoring packages for /app/aspnetapp/aspnetapp.csproj...
  Installing Microsoft.NETCore.DotNetAppHost 2.0.5.
  Installing Microsoft.NETCore.DotNetHostResolver 2.0.5.
  Installing Microsoft.NETCore.DotNetHostPolicy 2.0.5.
  Installing Microsoft.NETCore.App 2.0.5.
  Installing Microsoft.VisualStudio.Web.CodeGeneration.Contracts 2.0.2.
  Installing Microsoft.VisualStudio.Web.CodeGeneration.Tools 2.0.2.
  Restore completed in 3.59 sec for /app/aspnetapp/aspnetapp.csproj.
Removing intermediate container 618e9ca85ae4
 ---> 60d28209e187
Step 6/13 : COPY aspnetapp/. ./aspnetapp/
 ---> 9ae1f2caba6f
Step 7/13 : WORKDIR /app/aspnetapp
Removing intermediate container 120a08a3bc38
 ---> f429af2434d0
Step 8/13 : RUN dotnet publish -o out /p:PublishWithAspNetCoreTargetManifest="fa                                                                                                                                  lse"
 ---> Running in fa289c0b678c
remote: t (R) Build Engine version 15.6.84.34536 for .NET Core
remote: t (C) Microsoft Corporation. All rights reserved.

  Restore completed in 64.8 ms for /app/aspnetapp/aspnetapp.csproj.
  Restore completed in 13.55 ms for /app/aspnetapp/aspnetapp.csproj.
  Restore completed in 21.51 ms for /app/aspnetapp/aspnetapp.csproj.
  aspnetapp -> /app/aspnetapp/bin/Debug/netcoreapp2.0/aspnetapp.dll
  aspnetapp -> /app/aspnetapp/out/
Removing intermediate container fa289c0b678c
 ---> 4c53e8ba33b6
Step 9/13 : FROM microsoft/dotnet:2.0-runtime AS runtime
 ---> baa2c71aa21f
Step 10/13 : ENV ASPNETCORE_URLS http://+:80
 ---> Running in d349458e6c73
Removing intermediate container d349458e6c73
 ---> 22f20319d8e1
Step 11/13 : WORKDIR /app
Removing intermediate container ee0c40dd5c55
 ---> 09cc52135d48
Step 12/13 : COPY --from=build /app/aspnetapp/out ./
 ---> deebe5266c8f
Step 13/13 : ENTRYPOINT ["dotnet", "aspnetapp.dll"]
 ---> Running in fa7c9fd5fb85
Removing intermediate container fa7c9fd5fb85
 ---> d0e5047a8939
Successfully built d0e5047a8939
Successfully tagged dokku/aspnetapp:latest
-----> Releasing aspnetapp (dokku/aspnetapp:latest)...
-----> Deploying aspnetapp (dokku/aspnetapp:latest)...
-----> Attempting to run scripts.dokku.predeploy from app.json (if defined)
-----> No Procfile found in app image
-----> DOKKU_SCALE file not found in app image. Generating one based on Procfile                                                                                                                                  ...
-----> New DOKKU_SCALE file generated
=====> web=1
-----> Attempting pre-flight checks
       For more efficient zero downtime deployments, create a file CHECKS.
       See http://dokku.viewdocs.io/dokku/deployment/zero-downtime-deploys/ for                                                                                                                                   examples
       CHECKS file not found in container: Running simple container check...
-----> Waiting for 10 seconds ...
-----> Default container check successful!
-----> Running post-deploy
=====> no global VHOST set. disabling vhost support
-----> Skipping DOKKU_PROXY_PORT, it is not set in the environment
-----> Skipping DOKKU_PROXY_SSL_PORT, it is not set in the environment
-----> Skipping DOKKU_PROXY_PORT_MAP, it is not set in the environment
-----> Setting config vars
       NO_VHOST:  1
-----> no proxy port set. setting to random open high port
-----> Setting config vars
       DOKKU_PROXY_PORT:  49466
-----> Setting config vars
       DOKKU_PROXY_PORT_MAP:  http:49466:5000
-----> Creating http nginx.conf
-----> Running nginx-pre-reload
       Reloading nginx
-----> Setting config vars
       DOKKU_APP_RESTORE:  1
=====> Renaming container (81065261a1fb) focused_goldberg to aspnetapp.web.1
-----> Attempting to run scripts.dokku.postdeploy from app.json (if defined)
=====> Application deployed:
       http://IP:49466

To IP:aspnetapp
 * [new branch]      master -> master

I'm baffled as to which logs in general I should be checking (the standard dokku logs have nothing abnormal in them):

root@karam-ubuntu-1:/# dokku logs aspnetapp -t
2018-04-25T23:05:07.859795954Z app[web.1]: warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
2018-04-25T23:05:07.859885914Z app[web.1]:       No XML encryptor configured. Key {86346413-ffaa-4b02-b03e-6fcc1cbfedf2} may be persisted to storage in unencrypted form.
2018-04-25T23:05:08.326810287Z app[web.1]: Hosting environment: Production
2018-04-25T23:05:08.326976164Z app[web.1]: Content root path: /app
2018-04-25T23:05:08.327333461Z app[web.1]: Now listening on: http://[::]:80
2018-04-25T23:05:08.327439230Z app[web.1]: Application started. Press Ctrl+C to shut down.

And I can't spot any clues during the deployment/git push process.

Any ideas?

2 comments
  • I am seeing this error in my aspnet error logs that seems to occur when I try to access the site:
    2018/04/26 09:06:57 [error] 20253#20253: *115 connect() failed (111: Connection refused) while connecting to upstream, client: 109.111.215.168, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "http://172.17.0.2:5000/favicon.ico", host: "167.99.92.116:64911", referrer: "http://167.99.92.116:64911/"

    Doing curl http://172.17.0.2:5000 results in:
    curl: (7) Failed to connect to 172.17.0.127 port 5000: No route to host

    Could this error be that my application is deploying fine, but there is a problem with whatever Nginx configuration has been done during the automated Dokku dockerfile deployment process?

  • Did you try to link a Postgres database to your Dokku .Net Core App? I got 400 bad request after linking a database and implement a POST API.

1 Answer

Fixed the issue.
My dockerfile had ENV ASPNETCORE_URLS http://*:80 instead of pointing at the default port 5000.

  • Did you link a database to the app? If so does it work magically or do you need to change the connection string ?

Have another answer? Share your knowledge.