Skip to content

Commit 6ce0181

Browse files
authored
Add samples to this repo (#126)
* Start with .NET Core dotnetapp sample * Update for .NET Framework * Add ASP.NET samples * Update for .NET Framework * Updates for aspnetapp * Remove props file -- not yet needed * Update samples for .NET Framework 4.7.2 * Remove 'Core' references * Add infra for building samples and samples DH readme * Fix tag order in readme * Review Edits
1 parent 37b728a commit 6ce0181

File tree

147 files changed

+57516
-10
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+57516
-10
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,22 @@
22
.vscode/
33
.vs
44

5+
# Visual Studio user files
6+
*.csproj.user
7+
58
# Build output
69
[Bb]in/
710
[Oo]bj/
811
[Oo]ut/
912

13+
# packages
14+
[Pp]ackages/
15+
1016
# dotnet install directory
1117
.dotnet/
1218

19+
# Test files
20+
*.trx
21+
1322
# ImageBuilder directory
1423
.Microsoft.DotNet.ImageBuilder

build-pipeline/dotnet-framework-docker-windows-1709-amd64-images.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"inputs": {
1616
"scriptType": "filePath",
1717
"scriptName": "$(Build.SourcesDirectory)\\build-and-test.ps1",
18-
"arguments": "-VersionFilter $(PB_image-builder_versionFilter) -OSFilter $(PB_image-builder_osFilter) -ImageBuilderCustomArgs \"$(image-builder.customArgs)\" -CleanupDocker",
18+
"arguments": "-VersionFilter $(PB_image-builder_versionFilter) -OSFilter $(PB_image-builder_osFilter) -ImageBuilderCustomArgs \"$(imageBuilder.customArgs)\" -CleanupDocker",
1919
"workingFolder": "$(Build.SourcesDirectory)",
2020
"inlineScript": "",
2121
"failOnStandardError": "false"
@@ -66,9 +66,14 @@
6666
"value": "false",
6767
"allowOverride": true
6868
},
69-
"image-builder.customArgs": {
70-
"value": "--push --username $(PB_docker_username) --password $(PB_docker_password) $(PB_image-builder_queueCustomArgs)",
71-
"allowOverride": true
69+
"imageBuilder.customArgs": {
70+
"value": "--manifest $(imageBuilder.manifest) --push --username $(PB_docker_username) --password $(PB_docker_password) $(imageBuilder.pipelineArgs) $(PB_image-builder_queueCustomArgs)"
71+
},
72+
"imageBuilder.manifest": {
73+
"value": "manifest.json"
74+
},
75+
"imageBuilder.pipelineArgs": {
76+
"value": ""
7277
},
7378
"PB_docker_password": {
7479
"value": null,

build-pipeline/dotnet-framework-docker-windows-ltsc2016-amd64-images.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"inputs": {
1616
"scriptType": "filePath",
1717
"scriptName": "$(Build.SourcesDirectory)\\build-and-test.ps1",
18-
"arguments": "-VersionFilter $(PB_image-builder_versionFilter) -OSFilter $(PB_image-builder_osFilter) -ImageBuilderCustomArgs \"$(image-builder.customArgs)\" -CleanupDocker",
18+
"arguments": "-VersionFilter $(PB_image-builder_versionFilter) -OSFilter $(PB_image-builder_osFilter) -ImageBuilderCustomArgs \"$(imageBuilder.customArgs)\" -CleanupDocker",
1919
"workingFolder": "$(Build.SourcesDirectory)",
2020
"inlineScript": "",
2121
"failOnStandardError": "false"
@@ -66,9 +66,14 @@
6666
"value": "false",
6767
"allowOverride": true
6868
},
69-
"image-builder.customArgs": {
70-
"value": "--push --username $(PB_docker_username) --password $(PB_docker_password) $(PB_image-builder_queueCustomArgs)",
71-
"allowOverride": true
69+
"imageBuilder.customArgs": {
70+
"value": "--manifest $(imageBuilder.manifest) --push --username $(PB_docker_username) --password $(PB_docker_password) $(imageBuilder.pipelineArgs) $(PB_image-builder_queueCustomArgs)"
71+
},
72+
"imageBuilder.manifest": {
73+
"value": "manifest.json"
74+
},
75+
"imageBuilder.pipelineArgs": {
76+
"value": ""
7277
},
7378
"PB_docker_password": {
7479
"value": null,
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"Repository": "dotnet-framework-docker",
3+
"Definitions": {
4+
"Path": ".",
5+
"Type": "VSTS",
6+
"BaseUrl": "https://devdiv.visualstudio.com/DefaultCollection",
7+
"SkipBranchAndVersionOverrides": "false"
8+
},
9+
"Pipelines": [
10+
{
11+
"Name": "Build Windows ltsc2016 AMD64 Images",
12+
"Parameters": {
13+
"TreatWarningsAsErrors": "false"
14+
},
15+
"Definitions": [
16+
{
17+
"Name": "dotnet-framework-docker-windows-ltsc2016-amd64-images",
18+
"Parameters": {
19+
"imageBuilder.manifest": "manifest.samples.json",
20+
"imageBuilder.pipelineArgs": "--os-version ltsc2016"
21+
}
22+
}
23+
]
24+
},
25+
{
26+
"Name": "Build Windows 1709 AMD64 Images",
27+
"Parameters": {
28+
"TreatWarningsAsErrors": "false"
29+
},
30+
"Definitions": [
31+
{
32+
"Name": "dotnet-framework-docker-windows-1709-amd64-images",
33+
"Parameters": {
34+
"imageBuilder.manifest": "manifest.samples.json",
35+
"imageBuilder.pipelineArgs": "--os-version 1709"
36+
}
37+
}
38+
]
39+
},
40+
{
41+
"Name": "Post Image Build",
42+
"Parameters": {
43+
"TreatWarningsAsErrors": "false"
44+
},
45+
"Definitions": [
46+
{
47+
"Name": "dotnet-framework-docker-post-image-build"
48+
}
49+
],
50+
"DependsOn": [
51+
"Build Windows 1709 AMD64 Images",
52+
"Build Windows ltsc2016 AMD64 Images"
53+
]
54+
}
55+
]
56+
}

manifest.samples.json

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"repos": [
3+
{
4+
"name": "microsoft/dotnet-framework-samples",
5+
"readmePath": "samples/README.DockerHub.md",
6+
"images": [
7+
{
8+
"sharedTags": {
9+
"dotnetapp": {},
10+
"latest": {}
11+
},
12+
"platforms": [
13+
{
14+
"dockerfile": "samples/dotnetapp/Dockerfile",
15+
"os": "windows",
16+
"osVersion": "ltsc2016",
17+
"tags": {
18+
"dotnetapp-windowsservercore-ltsc2016": {}
19+
}
20+
},
21+
{
22+
"dockerfile": "samples/dotnetapp/Dockerfile",
23+
"os": "windows",
24+
"osVersion": "1709",
25+
"tags": {
26+
"dotnetapp-windowsservercore-1709": {}
27+
}
28+
}
29+
]
30+
},
31+
{
32+
"sharedTags": {
33+
"aspnetapp": {}
34+
},
35+
"platforms": [
36+
{
37+
"dockerfile": "samples/aspnetapp/Dockerfile",
38+
"os": "windows",
39+
"osVersion": "ltsc2016",
40+
"tags": {
41+
"aspnetapp-windowsservercore-ltsc2016": {}
42+
}
43+
},
44+
{
45+
"dockerfile": "samples/aspnetapp/Dockerfile",
46+
"os": "windows",
47+
"osVersion": "1709",
48+
"tags": {
49+
"aspnetapp-windowsservercore-1709": {}
50+
}
51+
}
52+
]
53+
}
54+
]
55+
}
56+
]
57+
}

samples/README.DockerHub.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Latest Version of Common Tags
2+
3+
The following tags are the latest stable versions of the most commonly used images. The complete set of tags is listed further down.
4+
5+
- [`dotnetapp`](https://github.com/Microsoft/dotnet-framework-docker/blob/master/samples/dotnetapp/Dockerfile)
6+
- [`aspnetapp`](https://github.com/Microsoft/dotnet-framework-docker/blob/master/samples/aspnetapp/Dockerfile)
7+
8+
The [.NET Framework Docker samples](https://github.com/Microsoft/dotnet-framework-docker/blob/master/samples/README.md) show various ways to use .NET Framework and Docker together. See [Building Docker Images for .NET Framework Applications](https://docs.microsoft.com/dotnet/framework/docker/) to learn more.
9+
10+
Watch [dotnet/announcements](https://github.com/dotnet/announcements/labels/Docker) for Docker-related .NET announcements.
11+
12+
### Container sample: Run a simple application
13+
14+
Type the following command to run a sample console application with Docker:
15+
16+
```console
17+
docker run --rm microsoft/dotnet-framework-samples
18+
```
19+
20+
### Container sample: Run a web application
21+
22+
Type the following command to run a sample web application with Docker:
23+
24+
```console
25+
docker run -it --rm -p 8000:80 --name aspnet_sample microsoft/dotnet-framework-samples:aspnetapp
26+
```
27+
28+
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 earlier Windows versions, which is demonstrated in [View the ASP.NET app in a running container on Windows](https://github.com/microsoft/dotnet-framework-docker/blob/master/samples/aspnetapp/README.md#view-the-aspnet-app-in-a-running-container-on-windows).
29+
30+
## Complete set of Tags
31+
32+
# Windows Server, version 1709 amd64 tags
33+
34+
- [`dotnetapp-windowsservercore-1709`, `dotnetapp`, `latest` (*samples/dotnetapp/Dockerfile*)](https://github.com/Microsoft/dotnet-framework-docker/blob/master/samples/dotnetapp/Dockerfile)
35+
- [`aspnetapp-windowsservercore-1709`, `aspnetapp` (*samples/aspnetapp/Dockerfile*)](https://github.com/Microsoft/dotnet-framework-docker/blob/master/samples/aspnetapp/Dockerfile)
36+
37+
# Windows Server 2016 amd64 tags
38+
39+
- [`dotnetapp-windowsservercore-ltsc2016`, `dotnetapp`, `latest` (*samples/dotnetapp/Dockerfile*)](https://github.com/Microsoft/dotnet-framework-docker/blob/master/samples/dotnetapp/Dockerfile)
40+
- [`aspnetapp-windowsservercore-ltsc2016`, `aspnetapp` (*samples/aspnetapp/Dockerfile*)](https://github.com/Microsoft/dotnet-framework-docker/blob/master/samples/aspnetapp/Dockerfile)
41+
42+
# What is the .NET Framework?
43+
44+
The [.NET Framework](https://www.microsoft.com/net/framework) is a general purpose development platform maintained by Microsoft. It is the most popular way to build client and server applications for Windows and Windows Server. It is included with Windows, Windows Server and Windows Server Core. It includes server technologies such as ASP.NET Web Forms, ASP.NET MVC and Windows Communication Framework (WCF) applications, which you can run in Docker containers.
45+
46+
.NET has several capabilities that make development easier, including automatic memory management, (runtime) generic types, reflection, asynchrony, concurrency, and native interop. Millions of developers take advantage of these capabilities to efficiently build high-quality web and client applications.
47+
48+
You can use C#, F# and VB to write .NET Framework apps. C# is simple, powerful, type-safe, and object-oriented while retaining the expressiveness and elegance of C-style languages. F# is a multi-paradigm programming language, enabling both functional and object-oriented patterns and practices. VB is a rapid development programming language with the deepest integration between the language and Visual Studio, providing the fastest path to a working app.
49+
50+
The .NET Framework was first released by Microsoft in 2001. The latest version is [.NET Framework 4.7.1](https://www.microsoft.com/net/framework).
51+
52+
> https://docs.microsoft.com/dotnet/framework/
53+
54+
![dotnet-icon](https://cloud.githubusercontent.com/assets/2608468/19951790/a0458278-a11d-11e6-86e4-660aaa22aa3c.png)
55+
56+
## Issues
57+
58+
If you have any problems with or questions about this image, please contact us through a [GitHub issue](https://github.com/microsoft/dotnet-framework-docker/issues).
59+
60+
## Licenses
61+
62+
* [Windows Server Core license](https://hub.docker.com/r/microsoft/windowsservercore/)
63+
64+
## Related Repos
65+
66+
See the following related repos for other application types:
67+
68+
* [microsoft/dotnet](https://hub.docker.com/r/microsoft/dotnet/) for .NET Core images.
69+
* [microsoft/aspnet](https://hub.docker.com/r/microsoft/aspnet/) for ASP.NET Web Forms and MVC images.
70+
* [microsoft/dotnet-framework](https://hub.docker.com/r/microsoft/dotnet-framework/) for .NET Framework images (for web applications, see microsoft/aspnet).

samples/README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# .NET Framework Docker Samples
2+
3+
The samples show various ways to use .NET Framework and Docker together. You can use the samples as the basis of your own Docker images or just to play.
4+
5+
The samples exercise various levels of functionality. The [.NET Framework Docker sample](dotnetapp/README.md) includes the most functionality, including build, unit testing, and pushing images to a container registry. The [ASP.NET Docker sample](aspnetapp/README.md) includes instructions for testing images with [Azure Container Instances](https://azure.microsoft.com/services/container-instances/). The samples include detailed instructions for use with and without Docker.
6+
7+
## Try a pre-built .NET Framework Docker Image
8+
9+
You can quickly run a container with a pre-built [.NET Framework Docker image](https://hub.docker.com/r/microsoft/dotnet-framework-samples/), based on the [.NET Framework console sample](dotnetapp/README.md).
10+
11+
Type the following [Docker](https://www.docker.com/products/docker) command:
12+
13+
```console
14+
docker run --rm microsoft/dotnet-framework-samples
15+
```
16+
17+
## Building .NET Framework Apps with Docker
18+
19+
* [.NET Framework Console Docker Sample](dotnetapp/README.md) - This [sample](dotnetapp/Dockerfile) builds, tests, and runs the sample. It includes and builds multiple projects.
20+
* [ASP.NET Web Forms Docker Sample](aspnetapp/README.md) - This [sample](aspnetapp/Dockerfile) demonstrates using Docker with an ASP.NET Web Forms app.
21+
* [ASP.NET MVC Docker Sample](aspnetmvcapp/README.md) - This [sample](aspnetmvcapp/Dockerfile) demonstrates using Docker with an ASP.NET MVC app.
22+
23+
## Push Images to a Container Registry
24+
25+
* [Push Docker Images to Azure Container Registry](dotnetapp/push-image-to-acr.md)
26+
* [Push Docker Images to DockerHub](dotnetapp/push-image-to-dockerhub.md)
27+
* [Deploy ASP.NET Applications to Azure Container Instances](aspnetapp/deploy-container-to-aci.md)
28+
29+
## .NET Resources
30+
31+
More Samples
32+
33+
* [.NET Core Docker Samples](https://github.com/dotnet/dotnet-docker/blob/master/samples/README.md)
34+
35+
Docs and More Information:
36+
37+
* [.NET Docs](https://docs.microsoft.com/dotnet/)
38+
* [ASP.NET Docs](https://docs.microsoft.com/aspnet/)
39+
* [dotnet/core](https://github.com/dotnet/core) for starting with .NET Core on GitHub.
40+
* [dotnet/announcements](https://github.com/dotnet/announcements/issues) for .NET announcements.
41+
42+
## Related Repositories
43+
44+
.NET Core Docker Hub repos:
45+
46+
* [microsoft/aspnetcore](https://hub.docker.com/r/microsoft/aspnetcore/) for ASP.NET Core images.
47+
* [microsoft/dotnet](https://hub.docker.com/r/microsoft/dotnet/) for .NET Core images.
48+
* [microsoft/dotnet-nightly](https://hub.docker.com/r/microsoft/dotnet-nightly/) for .NET Core preview images.
49+
* [microsoft/dotnet-samples](https://hub.docker.com/r/microsoft/dotnet-samples/) for .NET Core sample images.
50+
51+
.NET Framework Docker Hub repos:
52+
53+
* [microsoft/aspnet](https://hub.docker.com/r/microsoft/aspnet/) for ASP.NET Web Forms and MVC images.
54+
* [microsoft/dotnet-framework](https://hub.docker.com/r/microsoft/dotnet-framework/) for .NET Framework images.
55+
* [microsoft/dotnet-framework-samples](https://hub.docker.com/r/microsoft/dotnet-framework-samples/) for .NET Framework and ASP.NET sample images.

samples/aspnetapp/.dockerignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# directories
2+
**/packages/
3+
**/bin/
4+
**/obj/
5+
**/out/
6+
7+
# files
8+
Dockerfile*
9+
**/*.trx
10+
**/*.md

samples/aspnetapp/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM microsoft/dotnet-framework:4.7.2-sdk AS build
2+
WORKDIR /app
3+
4+
# copy csproj and restore as distinct layers
5+
COPY *.sln .
6+
COPY aspnetapp/*.csproj ./aspnetapp/
7+
COPY aspnetapp/*.config ./aspnetapp/
8+
RUN nuget restore
9+
10+
# copy everything else and build app
11+
COPY aspnetapp/. ./aspnetapp/
12+
WORKDIR /app/aspnetapp
13+
RUN msbuild /p:Configuration=Release
14+
15+
16+
FROM microsoft/aspnet:4.7.2 AS runtime
17+
WORKDIR /inetpub/wwwroot
18+
COPY --from=build /app/aspnetapp/. ./
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM microsoft/dotnet-framework:4.7.2-sdk AS build
2+
WORKDIR /app
3+
4+
# copy csproj and restore as distinct layers
5+
COPY *.sln .
6+
COPY aspnetapp/*.csproj ./aspnetapp/
7+
COPY aspnetapp/*.config ./aspnetapp/
8+
RUN nuget restore
9+
10+
# copy everything else and build app
11+
COPY aspnetapp/. ./aspnetapp/
12+
WORKDIR /app/aspnetapp
13+
RUN msbuild /p:Configuration=Release
14+
15+
16+
FROM microsoft/aspnet:4.7.2-windowsservercore-ltsc2016 AS runtime
17+
WORKDIR /inetpub/wwwroot
18+
COPY --from=build /app/aspnetapp/. ./

0 commit comments

Comments
 (0)