Add .NET Core Samples#362
Conversation
MichaelSimons
left a comment
There was a problem hiding this comment.
I like the overall change. My comments are pretty minor.
| See the following related .NET Core Docker Hub repos: | ||
|
|
||
| * [microsoft/aspnetcore](https://hub.docker.com/r/microsoft/aspnetcore/) for ASP.NET Core images. | ||
| * [microsoft/dotnet](https://hub.docker.com/r/microsoft/dotnet/) for .NET Core images. |
There was a problem hiding this comment.
Should dotnet-nightly be listed as well? The Alpine based samples have a dependency on it.
| ### Optimizing Container Size | ||
|
|
||
| * [.NET Core Alpine Docker Sample](dotnetapp/README.md) - This [sample](dotnetapp/Dockerfile.alpine) builds, tests and runs an application using Alpine. | ||
| * [.NET Core self-contained Sample](dotnetapp/dotnet-docker-selfcontained.md) -- This sample builds and runs an application as a self-contained application. |
There was a problem hiding this comment.
(nit) uses two dashes -- whereas the others only use one.
|
|
||
| ### ARM32 / Raspberry Pi | ||
|
|
||
| * [.NET Core ARM32 Docker Sample](dotnetapp/README.md) - This [sample](dotnetapp/Dockerfile.arm32) builds and runs an application with Debian on ARM32 (works on Raspberry Pi). |
There was a problem hiding this comment.
Should these readme links go to the dotnet-docker-arm32.md?
| ```console | ||
| cd samples | ||
| cd dotnetapp | ||
| docker build -t dotnetapp . |
There was a problem hiding this comment.
I sometimes lean toward including --pull to avoid any issues customers may hit with old images lingering around.
| ## Build and run the sample for ARM32 | ||
|
|
||
| You can build and run the sample for [ARM32 and Raspberry Pi](dotnet-docker-arm32.md) with [Build .NET Core Applications for Raspberry Pi with Docker](dotnet-docker-arm32.md) instructions. | ||
|
|
There was a problem hiding this comment.
I was expecting a section that mentions and links to the self contained readme.
| @@ -0,0 +1,5 @@ | |||
| bin/ | |||
There was a problem hiding this comment.
I think a similar .dockerignore should exist for the aspnetapp.
| @@ -0,0 +1,71 @@ | |||
| Microsoft Visual Studio Solution File, Format Version 12.00 | |||
There was a problem hiding this comment.
Why don't the solutions include all of the Dockerfiles?
There was a problem hiding this comment.
I guess it is a question of what the SLN is should represent ... should it represent all of the assets (like you are suggesting) or be a more typical SLN with just typical assets (not duplicate Dockerfiles). Certainly, it should contain at least a Dockerfile. Thoughts?
There was a problem hiding this comment.
My viewpoint was not necessarily that a sln would ever have this many Dockerfiles. I do see customers as possibly having more than one in which case all Dockerfiles would be included. In this particular case, I don't want customers to open the sln and overlook the permutations of the Dockerfiles included in the sample.
|
|
||
| ## Build and run the sample for Linux ARM32 with Docker | ||
|
|
||
| You need to build the [sample](Dockerfile.arm32) on Windows. This requirement is due to the .NET Core SDK not being currently supported on ARM32. The instructions assume that you are in the root of the repository. |
There was a problem hiding this comment.
MacOS would also work too?
There was a problem hiding this comment.
Is it just Linux that won't work?
There was a problem hiding this comment.
Tested it everywhere. It works. I somehow got the idea it wouldn't. Updated text.
| * [ASP.NET Core Getting Started Tutorials](https://www.asp.net/get-started) | ||
| * [.NET Core Production Docker sample](../dotnetapp-prod/README.md) | ||
| * [.NET Core Docker samples](../README.md) | ||
| * [.NET Framework Docker samples](https://github.com/Microsoft/dotnet-framework-docker-samples) No newline at end of file |
There was a problem hiding this comment.
Would it make sense to call out this includes ASP.NET samples? In this context it seems useful.
There was a problem hiding this comment.
Do you mean the .NET Framework Samples?
There was a problem hiding this comment.
Yes - the .NET Framework Docker samples include full fx ASP.NET samples.
| @@ -0,0 +1,33 @@ | |||
| FROM microsoft/dotnet:sdk AS build | |||
There was a problem hiding this comment.
It may be a good idea to include linux in the filename since the Dockerfile is tied to linux. Trying to build it in a Windows container environment has a little strange behavior as the first stage will succeed.
|
|
||
| The samples show various ways to use .NET Core and Docker together. You can use the samples as the basis of your own Docker images or just to play. | ||
|
|
||
| The samples exercise various levels of functionality. The [.NET Core Docker sample](dotnetapp/README.md) includes the most functionality, including build and unit testing. Other samples do less. You can decide what is the right level of functionality for your use case, either copy/pasting in more delete functionality or deleting it. The samples include instructions on how to build them, with and without Docker. |
There was a problem hiding this comment.
wording - either copy/pasting in more delete functionality or deleting it Seems like the first delete should be removed.
| Type the following command to run a sample with [Docker](https://www.docker.com/products/docker): | ||
|
|
||
| ```console | ||
| docker run microsoft/dotnet-samples |
There was a problem hiding this comment.
consider adding the use of --rm
| ## ARM32 / Raspberry Pi | ||
|
|
||
| * [.NET Core ARM32 Docker Sample](dotnetapp/dotnet-docker-arm32.md) - This [sample](dotnetapp/Dockerfile.linux-arm32) builds and runs an application with Debian on ARM32 (works on Raspberry Pi). | ||
| * [ASP.NET Core ARM32 Docker Sample](aspnetapp/README.md) - This [sample](aspnetapp/Dockerfile.linux-arm32) builds and runs an application with Debian on ARM32 (works on Raspberry Pi). |
There was a problem hiding this comment.
Should call out ASP.NET in the description - This sample builds and runs an ASP.NET application...
|
|
||
| * [microsoft/aspnet](https://hub.docker.com/r/microsoft/aspnet/) for ASP.NET Web Forms and MVC images. | ||
| * [microsoft/dotnet-framework](https://hub.docker.com/r/microsoft/dotnet-framework/) for .NET Framework images (for web applications, see microsoft/aspnet). | ||
| * [microsoft/dotnet-framework-build](https://hub.docker.com/r/microsoft/dotnet-framework-build/) for .NET Framework images (for web applications, see microsoft/aspnet). |
There was a problem hiding this comment.
I wasn't expecting (for web applications, see microsoft/aspnet)
|
|
||
| namespace Tests | ||
| { | ||
| public class ConsoleTests |
There was a problem hiding this comment.
Any reason to not align the name of the two test classes with the classes they are intended to test? ConsoleUtilsTests and StringUtilsTests?
| * [Multi-arch sample with build and unit testing](Dockerfile) | ||
| * [Multi-arch basic sample](Dockerfile.basic) | ||
| * [Alpine sample with build and unit testing](Dockerfile.alpine) | ||
| * [Alpine basic sample, with Globalization enabled](Dockerfile.alpinewithglobalization) |
| VisualStudioVersion = 15.0.26124.0 | ||
| MinimumVisualStudioVersion = 15.0.26124.0 | ||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "aspnetapp", "aspnetapp\aspnetapp.csproj", "{5FDCC1ED-9F59-47ED-969D-5E463CDD8D52}" | ||
| EndProject |
There was a problem hiding this comment.
Should include .dockerignore and Dockerfile.
| @@ -0,0 +1,19 @@ | |||
| FROM microsoft/dotnet:2.0-sdk AS build | |||
There was a problem hiding this comment.
Why not base the sample on the aspnetcore images?
There was a problem hiding this comment.
cause the final result is nearly 100MB diff, due to this line: https://github.com/aspnet/aspnet-docker/blob/master/2.0/stretch/runtime/Dockerfile#L8. This will only get worse for 2.0. For 2.1, it will be different.
There was a problem hiding this comment.
Really, 100MB? I'm surprised. I would have thought it would be about equal because you end up publishing those assemblies in your local publish directory when setting /p:PublishWithAspNetCoreTargetManifest="false".
Also, you lose out on crossgen and fast startup by not using the runtime store.
| * [ASP.NET Core Getting Started Tutorials](https://www.asp.net/get-started) | ||
| * [.NET Core Production Docker sample](../dotnetapp-prod/README.md) | ||
| * [.NET Core Docker samples](../README.md) | ||
| * [.NET Framework and and ASP.NET Docker samples](https://github.com/Microsoft/dotnet-framework-docker-samples) No newline at end of file |
There was a problem hiding this comment.
Perhaps it would be more appropriate to use and and and here instead of just and and 😸
| @@ -0,0 +1,71 @@ | |||
| Microsoft Visual Studio Solution File, Format Version 12.00 | |||
There was a problem hiding this comment.
My viewpoint was not necessarily that a sln would ever have this many Dockerfiles. I do see customers as possibly having more than one in which case all Dockerfiles would be included. In this particular case, I don't want customers to open the sln and overlook the permutations of the Dockerfiles included in the sample.
|
This PR fixes the following issues: |
|
I think that I've resolved all of your feedback now @MichaelSimons . Thanks for all of it! I also made several other changes that you'll notice. |
|
I just added a README.DockerHub.md. I updated the tags to demonstrate what I think we need. I know that your manifest tool will generate the same content. This file is intended to be a spec and a placeholder. |
MichaelSimons
left a comment
There was a problem hiding this comment.
LGTM - few minor comments
|
|
||
| This repo contains samples that demonstrate various .NET Core Docker configurations. | ||
|
|
||
| You can see the source for these samples at [dotnet/dotnet-docker/samples](https://github.com/dotnet/dotnet-docker/tree/master/samples/README.md) on GitHub. They can be updated by pull request. |
There was a problem hiding this comment.
This doesn't read well to me - "They can be updated by pull request." How about something like "They can be updated by creating a pull request"?
|
|
||
| ### Issues | ||
|
|
||
| If you have any problems with or questions about this image, please contact us through a [GitHub issue](https://github.com/dotnet/dotnet-docker/samples/issues). |
There was a problem hiding this comment.
The link doesn't seem right.
| The `dotnetapp` tag is a sample console application that depends on the [.NET Core Runtime image](https://hub.docker.com/r/microsoft/dotnet). You can run it in a container by running the following command. | ||
|
|
||
| ```console | ||
| docker run microsoft/dotnet-samples:dotnetapp |
|
|
||
| ## Build and run the sample for ARM32 | ||
|
|
||
| You can build and run the sample for [ARM32 and Raspberry Pi](dotnet-docker-arm32.md) with [Build .NET Core Applications for Raspberry Pi with Docker](dotnet-docker-arm32.md) instructions. |
There was a problem hiding this comment.
It is a little odd that both the hyperlinks that are so close together point to the same thing.
| @@ -0,0 +1,20 @@ | |||
| FROM microsoft/dotnet:sdk AS build | |||
There was a problem hiding this comment.
I think this should be 2.0-sdk versus sdk
| ConsoleUtils.PrintStringWithRandomColor(bot); | ||
|
|
||
| WriteLine("**Environment**"); | ||
| WriteLine($"Platform: .NET Core 2.0"); |
There was a problem hiding this comment.
Still not crazy about this hard coded value. It seems misleading when used in the Alpine scenario which is based on 2.1.
|
|
||
| The following example demonstrates how to create a private ACR Registry. Once an image is in ACR, it is easy to deploy it to ACI. | ||
|
|
||
| The instructions use example values that need to be changed to for your environment, specifically the password location, the registry name and the user account. More simply, make sure to change "rich" and "richlander" to something else. |
There was a problem hiding this comment.
I like how this is called out more in the push-image-to-dockerhub.md
| # directories | ||
| bin/ | ||
| obj/ | ||
| out/ |
There was a problem hiding this comment.
I question if the two .dockerignore files have the correct paths specified for bin, obj, and out. I think they should all be prefixed with **/. Right now it you build the app locally, the bin and obj are getting copied into the image from the host because the app is in a subfolder of where the .dockerignore files reside.
| 172.25.157.148 | ||
| ``` | ||
|
|
||
| ## Build and run the sample for Linux ARM32 with Docker |
There was a problem hiding this comment.
Curious why this isn't broken out into a separate md file like what was doen for the dotnetapp?
| docker run --rm -p 8000:80 --name aspnetcore_sample microsoft/dotnet-samples:aspnetapp | ||
| ``` | ||
|
|
||
| After the application starts, navigate to `http://localhost:8000` in your web browser. You need to navigate to the application via IP address instead of `localhost` for Windows containers, which is demonstrated in one of the following sections. |
There was a problem hiding this comment.
How about providing a link to the View the ASP.NET Core app in a running container on Windows section?
Uh oh!
There was an error while loading. Please reload this page.