Skip to content

Commit df7676b

Browse files
sparaMano Marks
authored and
Mano Marks
committed
asp.net and dot.net docker examples (docker#58)
* added aspnet-web example * added hello-dotnetbot example
1 parent f8710ad commit df7676b

File tree

11 files changed

+209
-0
lines changed

11 files changed

+209
-0
lines changed

windows/aspnet-web/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# ASP.NET Web application
2+
3+
A simple example using asp.net to serve a web page using kestrel. You can use either docker-compose or docker run to start the image.

windows/aspnet-web/docker-compose.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: "2"
2+
3+
services:
4+
5+
webserver:
6+
build:
7+
context: ./webserver
8+
image: aspnet-web
9+
ports:
10+
- "5000:5000"
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM microsoft/dotnet:latest
2+
3+
WORKDIR /root/
4+
ADD ./app/ ./app/
5+
WORKDIR /root/app
6+
7+
RUN dotnet restore
8+
RUN dotnet build
9+
10+
EXPOSE 5000/tcp
11+
12+
ENTRYPOINT ["dotnet", "run", "--server.urls", "http://0.0.0.0:5000"]
13+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
using Microsoft.AspNetCore.Hosting;
3+
4+
namespace aspnetcoreapp
5+
{
6+
public class Program
7+
{
8+
public static void Main(string[] args)
9+
{
10+
var host = new WebHostBuilder()
11+
.UseKestrel()
12+
.UseStartup<Startup>()
13+
.UseUrls("http://*:5000")
14+
.Build();
15+
16+
host.Run();
17+
}
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using Microsoft.AspNetCore.Builder;
3+
using Microsoft.AspNetCore.Hosting;
4+
using Microsoft.AspNetCore.Http;
5+
6+
namespace aspnetcoreapp
7+
{
8+
public class Startup
9+
{
10+
public void Configure(IApplicationBuilder app)
11+
{
12+
app.Run(context =>
13+
{
14+
return context.Response.WriteAsync("Hello from ASP.NET Core!");
15+
});
16+
}
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"version": "1.0.0-*",
3+
"buildOptions": {
4+
"debugType": "portable",
5+
"emitEntryPoint": true
6+
},
7+
"dependencies": {},
8+
"frameworks": {
9+
"netcoreapp1.0": {
10+
"dependencies": {
11+
"Microsoft.NETCore.App": {
12+
"type": "platform",
13+
"version": "1.0.1"
14+
},
15+
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0"
16+
},
17+
"imports": "dnxcore50"
18+
}
19+
}
20+
}
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dotnet run

windows/hello-dotnetbot/Dockerfile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM microsoft/dotnet:latest
2+
3+
WORKDIR /root/
4+
ADD ./app/ ./app/
5+
WORKDIR /root/app/
6+
7+
RUN dotnet restore
8+
RUN dotnet build
9+
10+
CMD ["dotnet", "run", "Hello World"]

windows/hello-dotnetbot/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Hello World Dotnet
2+
3+
A hello world example using Docker with Microsoft dotnet. To run the application:
4+
5+
`docker run -it dotnetbot`
6+
7+
The application is a console application that is compiled when the Docker image is created.
+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
using System;
2+
3+
namespace DotnetBot
4+
{
5+
public static class Program
6+
{
7+
public static void Main(string[] args)
8+
{
9+
string message = "";
10+
if (args.Length < 1)
11+
{
12+
message = "Welcome to .NET Core!";
13+
} else
14+
{
15+
foreach (string item in args)
16+
{
17+
message += item;
18+
}
19+
}
20+
Console.WriteLine(GetBot(message));
21+
}
22+
23+
public static string GetBot(string message)
24+
{
25+
string bot = "\n" + " " + message;
26+
bot += @"
27+
__________________
28+
\
29+
\
30+
....
31+
....'
32+
....
33+
..........
34+
.............'..'..
35+
................'..'.....
36+
.......'..........'..'..'....
37+
........'..........'..'..'.....
38+
.'....'..'..........'..'.......'.
39+
.'..................'... ......
40+
. ......'......... .....
41+
. ......
42+
.. . .. ......
43+
.... . .......
44+
...... ....... ............
45+
................ ......................
46+
........................'................
47+
......................'..'...... .......
48+
.........................'..'..... .......
49+
........ ..'.............'..'.... ..........
50+
..'..'... ...............'....... ..........
51+
...'...... ...... .......... ...... .......
52+
........... ....... ........ ......
53+
....... '...'.'. '.'.'.' ....
54+
....... .....'.. ..'.....
55+
.. .......... ..'........
56+
............ ..............
57+
............. '..............
58+
...........'.. .'.'............
59+
............... .'.'.............
60+
.............'.. ..'..'...........
61+
............... .'..............
62+
......... ..............
63+
.....
64+
65+
";
66+
return bot;
67+
}
68+
69+
70+
}
71+
}
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
3+
"version": "1.0.0-*",
4+
5+
"buildOptions": {
6+
7+
"debugType": "portable",
8+
9+
"emitEntryPoint": true
10+
11+
},
12+
13+
"dependencies": {},
14+
15+
"frameworks": {
16+
17+
"netcoreapp1.0": {
18+
19+
"dependencies": {
20+
21+
"Microsoft.NETCore.App": {
22+
23+
"type": "platform",
24+
25+
"version": "1.0.0"
26+
27+
}
28+
29+
},
30+
31+
"imports": "dnxcore50"
32+
33+
}
34+
35+
}
36+
37+
}

0 commit comments

Comments
 (0)