Skip to content

Instantly share code, notes, and snippets.

View glennc's full-sized avatar

Glenn Condron glennc

View GitHub Profile
@glennc
glennc / logs
Last active August 20, 2019 04:54
Code for systemd post
Jul 30 01:05:14 glennc-systemd testapp[44516]: Microsoft.Hosting.Lifetime[0] Application started. Hosting environment: Production; Content root path: /
Jul 30 01:05:15 glennc-systemd testapp[44516]: testapp.Worker[0] Worker running at: 07/30/2019 01:05:15 +00:00
Jul 30 01:05:16 glennc-systemd testapp[44516]: testapp.Worker[0] Worker running at: 07/30/2019 01:05:16 +00:00
Jul 30 01:05:17 glennc-systemd testapp[44516]: testapp.Worker[0] Worker running at: 07/30/2019 01:05:17 +00:00
Jul 30 01:05:18 glennc-systemd testapp[44516]: testapp.Worker[0] Worker running at: 07/30/2019 01:05:18 +00:00
Jul 30 01:05:19 glennc-systemd testapp[44516]: testapp.Worker[0] Worker running at: 07/30/2019 01:05:19 +00:00
Jul 30 01:05:20 glennc-systemd testapp[44516]: testapp.Worker[0] Worker running at: 07/30/2019 01:05:20 +00:00
Jul 30 01:05:21 glennc-systemd testapp[44516]: testapp.Worker[0] Worker running at: 07/30/2019 01:05:21 +00:00
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.DependencyInjection;
@glennc
glennc / test.cs
Created June 21, 2018 16:56
AutomaticDecompression
services.AddHttpClient("test")
.ConfigurePrimaryHttpMessageHandler(() =>
{
var handler = new HttpClientHandler();
handler.AutomaticDecompression = System.Net.DecompressionMethods.Deflate;
return handler;
});
@glennc
glennc / configure_switch.cs
Last active February 27, 2018 23:01
MVC compatibility post
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); // Give me the 2.1 behaviors
}
@glennc
glennc / arm.json
Last active July 17, 2018 15:16
2.1 Preview1 On Azure Post
{
"type": "siteextensions",
"name": "AspNetCoreRuntime",
"apiVersion": "2015-04-01",
"location": "[resourceGroup().location]",
"properties": {
"version": "[parameters('aspnetcoreVersion')]"
},
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', parameters('siteName'))]"
@glennc
glennc / alpha1code.js
Created October 9, 2017 22:45
SignalR Alpha2
hubConnection.onClosed = function(e) {...}
@glennc
glennc / connection.cs
Last active November 10, 2017 07:51
SignalRAnnouncement
var connection = new HubConnectionBuilder()
.WithUrl("http://localhost:5000/chat")
.WithConsoleLogger()
.Build();
connection.On<string>("Send", data =>
{
Console.WriteLine($"Received: {data}");
});
asdasd

This proposal captures the potential use of an ASP.NET specific Docker image that builds on what microsoft/dotnet already provides.

We could build 2 images:

###microsoft/aspnet: This image would be optimised for you to load your already compiled ASP.NET applications into.

  • Contains the same as the microsoft/dotnet:1.0.0-core, just a runtime and OS pre-reqs.
  • Contains a runtime cache of native assembly images. This cache would contain the closure of all or most of the packages that the ASP.NET team ships. ASP.NET packages + all their dependencies.
  • In benchmarks we have shown that including all ASP.NET assemblies in a runtime cache increase the image size-on-disk by ~10mb whilst improving the start time of a container running MVC Music Store by ~32% (around a 3 second improvement). This improvement represents the time taken to JIT the applications dependencies.

When using .NET and Docker some folks have been confused by the number of available images. To understand what each images is for, you need to understand the two different ways that you can choose to deploy a .NET Core application as well as some of the different ways people use containers.

Let's start with the different ways you can deploy .NET apps:

  1. Portable

    This is the default way to deploy and run an ASP.NET Core application. When you build a portable application then the output of dotnet publish is a .dll that you can run using dotnet <appName>.dll. However, you don't need the entire CLI just to run your already built .dll. You don't need restore, build, etc. You only need the dotnet command that can run your app.

  2. Standalone