Skip to content

Add .NET Core Samples#362

Merged
richlander merged 38 commits intomasterfrom
samples
Feb 26, 2018
Merged

Add .NET Core Samples#362
richlander merged 38 commits intomasterfrom
samples

Conversation

@richlander
Copy link
Copy Markdown
Member

@richlander richlander commented Feb 12, 2018

  • Moved samples from https://github.com/dotnet/dotnet-docker-samples
  • Took a different approach from the original samples (which had many top-level directories). The new approach has many Dockerfiles in the same directory. I also took more opportunities to make the examples more OS-agnostic.
  • I factored out instructions that have use for multiple scenarios.

Copy link
Copy Markdown
Member

@MichaelSimons MichaelSimons left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the overall change. My comments are pretty minor.

Comment thread samples/README.md
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.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should dotnet-nightly be listed as well? The Alpine based samples have a dependency on it.

Comment thread samples/README.md Outdated
### 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.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(nit) uses two dashes -- whereas the others only use one.

Comment thread samples/README.md Outdated

### 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).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these readme links go to the dotnet-docker-arm32.md?

Comment thread samples/dotnetapp/README.md Outdated
```console
cd samples
cd dotnetapp
docker build -t dotnetapp .
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I sometimes lean toward including --pull to avoid any issues customers may hit with old images lingering around.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me too.

## 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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was expecting a section that mentions and links to the self contained readme.

Comment thread samples/dotnetapp/.dockerignore Outdated
@@ -0,0 +1,5 @@
bin/
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a similar .dockerignore should exist for the aspnetapp.

@@ -0,0 +1,71 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't the solutions include all of the Dockerfiles?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread samples/aspnetapp/README.md Outdated

## 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.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MacOS would also work too?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it just Linux that won't work?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested it everywhere. It works. I somehow got the idea it wouldn't. Updated text.

Comment thread samples/aspnetapp/README.md Outdated
* [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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to call out this includes ASP.NET samples? In this context it seems useful.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean the .NET Framework Samples?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - the .NET Framework Docker samples include full fx ASP.NET samples.

Comment thread samples/dotnetapp/Dockerfile.arm32 Outdated
@@ -0,0 +1,33 @@
FROM microsoft/dotnet:sdk AS build
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread samples/README.md Outdated

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.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wording - either copy/pasting in more delete functionality or deleting it Seems like the first delete should be removed.

Comment thread samples/README.md Outdated
Type the following command to run a sample with [Docker](https://www.docker.com/products/docker):

```console
docker run microsoft/dotnet-samples
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider adding the use of --rm

Comment thread samples/README.md Outdated
## 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).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should call out ASP.NET in the description - This sample builds and runs an ASP.NET application...

Comment thread samples/README.md Outdated

* [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).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't expecting (for web applications, see microsoft/aspnet)

Comment thread samples/dotnetapp/tests/ConsoleTests.cs Outdated

namespace Tests
{
public class ConsoleTests
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to not align the name of the two test classes with the classes they are intended to test? ConsoleUtilsTests and StringUtilsTests?

Comment thread samples/dotnetapp/README.md Outdated
* [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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basic

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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should include .dockerignore and Dockerfile.

@@ -0,0 +1,19 @@
FROM microsoft/dotnet:2.0-sdk AS build
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not base the sample on the aspnetcore images?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread samples/aspnetapp/README.md Outdated
* [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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@MichaelSimons
Copy link
Copy Markdown
Member

@richlander
Copy link
Copy Markdown
Member Author

richlander commented Feb 25, 2018

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.

@richlander
Copy link
Copy Markdown
Member Author

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.

Copy link
Copy Markdown
Member

@MichaelSimons MichaelSimons left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - few minor comments

Comment thread samples/README.DockerHub.md Outdated

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.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"?

Comment thread samples/README.DockerHub.md Outdated

### 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).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The link doesn't seem right.

Comment thread samples/README.DockerHub.md Outdated
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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should include --rm

Comment thread samples/dotnetapp/README.md Outdated

## 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.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a little odd that both the hyperlinks that are so close together point to the same thing.

Comment thread samples/dotnetapp/Dockerfile.basic Outdated
@@ -0,0 +1,20 @@
FROM microsoft/dotnet:sdk AS build
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be 2.0-sdk versus sdk

Comment thread samples/dotnetapp/dotnetapp/Program.cs Outdated
ConsoleUtils.PrintStringWithRandomColor(bot);

WriteLine("**Environment**");
WriteLine($"Platform: .NET Core 2.0");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still not crazy about this hard coded value. It seems misleading when used in the Alpine scenario which is based on 2.1.

Comment thread samples/dotnetapp/push-image-to-acr.md Outdated

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.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like how this is called out more in the push-image-to-dockerhub.md

Comment thread samples/aspnetapp/.dockerignore Outdated
# directories
bin/
obj/
out/
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why this isn't broken out into a separate md file like what was doen for the dotnetapp?

Comment thread samples/aspnetapp/README.md Outdated
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.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about providing a link to the View the ASP.NET Core app in a running container on Windows section?

Copy link
Copy Markdown
Member

@MichaelSimons MichaelSimons left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants