Skip to content

Commit

Permalink
[WIP] Updates based on review of docs (#508)
Browse files Browse the repository at this point in the history
* Updates based on review of docs

* Add instructions for Windows Server 2016 and ACI

* Update Windows support

* Remove CliReferenceTool references

* Update ASP.NET Core sample

* Update samples per review]

* Update ARM32 and Alpine samples to nightly

* Switch to aspnetcore-runtime image

* Switch most Dockerfiles from dotnet-nightly to dotnet

* Simplify ARM32 self-contained Dockerfile

* Add latest dockerfile

* Update FROM statement

* Update FROM statement for runtime

* Update ARM32 instructions for ASP.NET Core

* Update approach for .latest concept

* Restore only for app project

* Update text for 'preview' Dockerfiles

* Update per feedback on dotnet reference link

* Update ARM32 Dockerfile links in DH README

* Add links between ARM32 topics

* Add usage samples to ARM32 docs

* Update Dockerfile location

* Update per feedback

* Remove target manifest property
  • Loading branch information
richlander committed May 7, 2018
1 parent dc0f2db commit 928292b
Show file tree
Hide file tree
Showing 24 changed files with 249 additions and 149 deletions.
2 changes: 1 addition & 1 deletion .gitignore
@@ -1,7 +1,7 @@
# Build output
[Bb]in/
[Oo]bj/
out/
[Oo]ut/

# cache for misc downloads
artifacts/
Expand Down
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -137,8 +137,8 @@ The [.NET Core Docker samples](https://github.com/dotnet/dotnet-docker/blob/mast

### ARM32 / Raspberry Pi

* [.NET Core ARM32 Docker Sample](https://github.com/dotnet/dotnet-docker/blob/master/samples/dotnetapp/dotnet-docker-arm32.md) - This [sample](https://github.com/dotnet/dotnet-docker/blob/master/samples/dotnetapp/Dockerfile.debian-arm32) builds and runs an application with Debian on ARM32 (works on Raspberry Pi).
* [ASP.NET Core ARM32 Docker Sample](https://github.com/dotnet/dotnet-docker/blob/master/samples/aspnetapp/README.md) - This [sample](https://github.com/dotnet/dotnet-docker/blob/master/samples/aspnetapp/Dockerfile.debian-arm32) builds and runs an ASP.NET Core application with Debian on ARM32 (works on Raspberry Pi).
* [.NET Core ARM32 Docker Sample](https://github.com/dotnet/dotnet-docker/blob/master/samples/dotnetapp/dotnet-docker-arm32.md) - This [sample](https://github.com/dotnet/dotnet-docker/blob/master/samples/dotnetapp/Dockerfile.basic-preview) builds and runs an application with Debian on ARM32 (works on Raspberry Pi).
* [ASP.NET Core ARM32 Docker Sample](https://github.com/dotnet/dotnet-docker/blob/master/samples/aspnetapp/README.md) - This [sample](https://github.com/dotnet/dotnet-docker/blob/master/samples/aspnetapp/Dockerfile.preview) builds and runs an ASP.NET Core application with Debian on ARM32 (works on Raspberry Pi).

## Image variants

Expand Down
11 changes: 7 additions & 4 deletions samples/README.md
Expand Up @@ -6,9 +6,9 @@ The samples exercise various levels of functionality. The [.NET Core Docker samp

## Try a pre-built .NET Core Docker Image

You can quickly try a pre-built [sample .NET Core Docker image](https://hub.docker.com/r/microsoft/dotnet-samples/), based on the [.NET Core sample](dotnetapp/README.md).
You can quickly run a container with a pre-built [.NET Core Docker image](https://hub.docker.com/r/microsoft/dotnet-samples/), based on the [.NET Core console sample](dotnetapp/README.md).

Type the following command to run a sample with [Docker](https://www.docker.com/products/docker):
Type the following [Docker](https://www.docker.com/products/docker) command:

```console
docker run --rm microsoft/dotnet-samples
Expand Down Expand Up @@ -40,11 +40,15 @@ docker run --rm microsoft/dotnet-samples
* [.NET Core ARM32 Docker Sample](dotnetapp/dotnet-docker-arm32.md) - This [sample](dotnetapp/Dockerfile.debian-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.debian-arm32) builds and runs an ASP.NET Core application with Debian on ARM32 (works on Raspberry Pi).

## ARM64

* [.NET Core ARM64 Docker Status](dotnetapp/dotnet-docker-arm64.md)

## .NET Core Resources

More Samples

* [.NET Framework Docker Samples](https://github.com/microsoft/dotnet-framework-docker-samples/)
* [.NET Framework Docker Samples](https://github.com/microsoft/dotnet-framework-docker/blob/master/samples/README.md)

Docs and More Information:

Expand All @@ -66,5 +70,4 @@ Docs and More Information:

* [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.
* [microsoft/dotnet-framework-build](https://hub.docker.com/r/microsoft/dotnet-framework-build/) for building .NET Framework applications with Docker.
* [microsoft/dotnet-framework-samples](https://hub.docker.com/r/microsoft/dotnet-framework-samples/) for .NET Framework and ASP.NET sample images.
5 changes: 2 additions & 3 deletions samples/aspnetapp/Dockerfile
Expand Up @@ -9,11 +9,10 @@ RUN dotnet restore
# copy everything else and build app
COPY aspnetapp/. ./aspnetapp/
WORKDIR /app/aspnetapp
RUN dotnet publish -o out /p:PublishWithAspNetCoreTargetManifest="false"
RUN dotnet publish -c release -o out


FROM microsoft/dotnet:2.0-runtime AS runtime
ENV ASPNETCORE_URLS http://+:80
FROM microsoft/aspnetcore:2.0 AS runtime
WORKDIR /app
COPY --from=build /app/aspnetapp/out ./
ENTRYPOINT ["dotnet", "aspnetapp.dll"]
18 changes: 18 additions & 0 deletions samples/aspnetapp/Dockerfile.alpine-x64
@@ -0,0 +1,18 @@
FROM microsoft/dotnet:2.1-sdk-alpine AS build
WORKDIR /app

# copy csproj and restore as distinct layers
COPY *.sln .
COPY aspnetapp/*.csproj ./aspnetapp/
RUN dotnet restore

# copy everything else and build app
COPY aspnetapp/. ./aspnetapp/
WORKDIR /app/aspnetapp
RUN dotnet publish -c release -o out


FROM microsoft/dotnet:2.1-aspnetcore-runtime-alpine AS runtime
WORKDIR /app
COPY --from=build /app/aspnetapp/out ./
ENTRYPOINT ["dotnet", "aspnetapp.dll"]
Expand Up @@ -7,13 +7,12 @@ COPY aspnetapp/*.csproj ./aspnetapp/
RUN dotnet restore

# copy everything else and build app
COPY . .
COPY aspnetapp/. ./aspnetapp/
WORKDIR /app/aspnetapp
RUN dotnet publish -o out /p:PublishWithAspNetCoreTargetManifest="false"
RUN dotnet publish -c release -o out


FROM microsoft/dotnet:2.0-runtime-stretch-arm32v7 AS runtime
ENV ASPNETCORE_URLS http://+:80
FROM microsoft/aspnetcore:2.0-nanoserver-sac2016 AS runtime
WORKDIR /app
COPY --from=build /app/aspnetapp/out ./
ENTRYPOINT ["dotnet", "aspnetapp.dll"]
18 changes: 18 additions & 0 deletions samples/aspnetapp/Dockerfile.preview
@@ -0,0 +1,18 @@
FROM microsoft/dotnet-nightly:2.1-sdk AS build
WORKDIR /app

# copy csproj and restore as distinct layers
COPY *.sln .
COPY aspnetapp/*.csproj ./aspnetapp/
RUN dotnet restore

# copy everything else and build app
COPY aspnetapp/. ./aspnetapp/
WORKDIR /app/aspnetapp
RUN dotnet publish -c release -o out


FROM microsoft/dotnet-nightly:2.1-aspnetcore-runtime AS runtime
WORKDIR /app
COPY --from=build /app/aspnetapp/out ./
ENTRYPOINT ["dotnet", "aspnetapp.dll"]
37 changes: 29 additions & 8 deletions samples/aspnetapp/README.md
Expand Up @@ -8,15 +8,15 @@ This sample requires [Docker 17.06](https://docs.docker.com/release-notes/docker

## Try a pre-built ASP.NET Core Docker Image

You can quickly try a pre-built [sample ASP.NET Core Docker image](https://hub.docker.com/r/microsoft/dotnet-samples/), based on this sample.
You can quickly run a container with a pre-built [sample ASP.NET Core Docker image](https://hub.docker.com/r/microsoft/dotnet-samples/), based on this [sample](Dockerfile).

Type the following command to run a sample with [Docker](https://www.docker.com/products/docker):

```console
docker run --name aspnetcore_sample --rm -it -p 8000:80 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 the [View the ASP.NET Core app in a running container on Windows](#view-the-aspnet-core-app-in-a-running-container-on-windows) section.
After the application starts, navigate to `http://localhost:8000` in your web browser. On earlier versions of Windows 10 and Windows Server, you need to navigate to the application via IP address instead of `localhost` for Windows containers, which is demonstrated in the [View the ASP.NET Core app in a running container on Windows](#view-the-aspnet-core-app-in-a-running-container-on-windows) section.

## Getting the sample

Expand Down Expand Up @@ -56,11 +56,13 @@ Note: The `-p` argument maps port 8000 on your local machine to port 80 in the c
Multiple variations of this sample have been provided, as follows. Some of these example Dockerfiles are demonstrated later. Specify an alternate Dockerfile via the `-f` argument.

* [Multi-arch sample](Dockerfile)
* [Linux ARM32 (Raspberry Pi) sample](Dockerfile.debian-arm32)
* [Multi-arch sample, using a preview version of .NET Core](Dockerfile.preview)
* [Nanoserver 2016 SAC sample](Dockerfile.nanoserver-sac2016)
* [Alpine sample](Dockerfile.alpine-x64)

### View the ASP.NET Core app in a running container on Windows

After the application starts, navigate to the container IP (as opposed to http://localhost) in your web browser with the the following instructions:
After the ASP.NET Core application starts, navigate to the container IP (as opposed to http://localhost) in your web browser with the the following instructions:

1. Open up another command prompt.
1. Run `docker exec aspnetcore_sample ipconfig`.
Expand Down Expand Up @@ -94,14 +96,34 @@ C:\git\dotnet-docker\samples\aspnetapp>docker inspect -f "{{ .NetworkSettings.Ne

## Deploying to Production vs Development

The approach for running containers differs between development and production.
The approach for running containers differs between development and production.

In production, you will typically start your container with `docker run -d`. This argument starts the container as a service, without any console interaction. You then interact with it through other Docker commands or APIs exposed by the containerized application.

In development, you will typically start containers with `docker run --rm -it`. These arguments enable you to see a console (important when there are errors), terminate the container with `CTRL-C` and cleans up all container resources when the container is termiantes. You also typically don't mind blocking the console. This approach is demonstrated in prior examples in this document.

We recommend that you do not use `--rm` in production. It cleans up container resources, preventing you from collecting logs that may have been captured in a container that has either stopped or crashed.

## Build and run the sample for Alpine X64 with Docker

You can build and run the sample for Alpine using the following instructions. Make sure Docker is set to Linux containers if you are on Windows.

```console
cd samples
cd aspnetapp
docker build --pull -t aspnetapp -f Dockerfile.alpine-x64 .
docker run --name aspnetcore_sample --rm -it -p 8000:80 aspnetapp
```

After the application starts, navigate to `http://localhost:8000` in your web browser.

## Build and run the sample for Ubuntu 18.04 with Docker

You can also build for [Ubuntu 18.04](https://hub.docker.com/_/ubuntu/), with a `bionic` tag. The `bionic` tags are documented at [microsoft/dotnet](https://hub.docker.com/r/microsoft/dotnet/). You would switch to the following tags:

* SDK: 2.1-sdk-bionic
* Runtime:-2.1-aspnetcore-runtime-bionic

## Build and run the sample for Linux ARM32 with Docker

You can build and run the sample for ARM32 and Raspberry Pi with [Build ASP.NET Core Applications for Raspberry Pi with Docker](aspnetcore-docker-arm32.md) instructions.
Expand Down Expand Up @@ -135,14 +157,14 @@ cd out
dotnet aspnetapp.dll
```

Note: The `-c release` argument builds the application in release mode (the default is debug mode). See the [dotnet run reference](https://docs.microsoft.com/dotnet/core/tools/dotnet-run) for more information on commandline parameters.
Note: The `-c release` argument builds the application in release mode (the default is debug mode). See the [dotnet publish reference](https://docs.microsoft.com/dotnet/core/tools/dotnet-publish) for more information on commandline parameters.

## .NET Core Resources

More Samples

* [.NET Core Docker Samples](../README.md)
* [.NET Framework Docker Samples](https://github.com/microsoft/dotnet-framework-docker-samples/)
* [.NET Framework Docker Samples](https://github.com/microsoft/dotnet-framework-docker/blob/master/samples/README.md)

Docs and More Information:

Expand All @@ -164,5 +186,4 @@ Docs and More Information:

* [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.
* [microsoft/dotnet-framework-build](https://hub.docker.com/r/microsoft/dotnet-framework-build/) for building .NET Framework applications with Docker.
* [microsoft/dotnet-framework-samples](https://hub.docker.com/r/microsoft/dotnet-framework-samples/) for .NET Framework and ASP.NET sample images.
10 changes: 5 additions & 5 deletions samples/aspnetapp/aspnet-docker-dev-in-container.md
Expand Up @@ -36,25 +36,25 @@ The instructions assume that you are in the root of the repository. You can use
docker run --rm -it -p 8000:80 -v c:\git\dotnet-docker\samples\aspnetapp:/app/ -w /app/aspnetapp microsoft/dotnet:2.1-sdk dotnet watch run
```

Navigate to the site at `http://localhost:8000` in your browser. You can use CTRL-C to terminate `dotnet watch`. It can take up to 20s to terminate.
Navigate to the site at `http://localhost:8000` in your browser. You can use CTRL-C to terminate `dotnet watch`.

**macOS or Linux** using **Linux containers**

```console
docker run --rm -it -p 8000:80 -v ~/git/dotnet-docker/samples/aspnetapp:/app/ -w /app/aspnetapp microsoft/dotnet:2.1-sdk dotnet watch run
```

Navigate to the site at `http://localhost:8000` in your browser. You can use CTRL-C to terminate `dotnet watch`. It can take up to 20s to terminate.
Navigate to the site at `http://localhost:8000` in your browser. You can use CTRL-C to terminate `dotnet watch`.

**Windows** using **Windows containers**

`dotnet watch run` is not working correctly in containers at this time. The instructions are still documented while we work on enabling this scenario.

```console
docker run --rm -it -p 8000:80 -v c:\git\dotnet-docker\samples\aspnetapp:c:\app\ -w \app\aspnetapp --name aspnetappsample microsoft/dotnet:2.1-sdk dotnet watch run
```

In another command window, type `docker exec aspnetappsample ipconfig`. Navigate to the IP address you see in your browser.
On the latest Windows versions, you can navigate to the site at `http://localhost:8000` in your browser. You can use CTRL-C to terminate `dotnet watch`.

One earlier Windows 10 and Windows Server verisons, you must navigate to the site by IP address. In another command window, type `docker exec aspnetappsample ipconfig`. Navigate to the IP address you see in your browser.

### Updating the site while the container is running

Expand Down
7 changes: 6 additions & 1 deletion samples/aspnetapp/aspnetapp.sln
Expand Up @@ -8,9 +8,14 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1E1C7ABA-885A-4273-811E-B66AD28F9A87}"
ProjectSection(SolutionItems) = preProject
.dockerignore = .dockerignore
aspnet-docker-dev-in-container.md = aspnet-docker-dev-in-container.md
aspnetcore-docker-arm32.md = aspnetcore-docker-arm32.md
deploy-container-to-aci.md = deploy-container-to-aci.md
Directory.Build.props = Directory.Build.props
Dockerfile = Dockerfile
Dockerfile.debian-arm32 = Dockerfile.debian-arm32
Dockerfile.alpine-x64 = Dockerfile.alpine-x64
Dockerfile.nanoserver-sac2016 = Dockerfile.nanoserver-sac2016
Dockerfile.preview = Dockerfile.preview
README.md = README.md
EndProjectSection
EndProject
Expand Down
19 changes: 1 addition & 18 deletions samples/aspnetapp/aspnetapp/aspnetapp.csproj
Expand Up @@ -4,25 +4,8 @@
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>

<PropertyGroup>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
</PropertyGroup>

<ItemGroup>
<None Remove=".dockerignore" />
<None Remove="deploy-container-to-aci.md" />
<None Remove="Dockerfile" />
<None Remove="Dockerfile.debian-arm32" />
<None Remove="README.md" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" />
</ItemGroup>

<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.2" />
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.7" />
</ItemGroup>

</Project>

0 comments on commit 928292b

Please sign in to comment.