Skip to content

Commit 12abfb9

Browse files
axdiamondwing328
authored andcommitted
[aspnetcore] Update Dockerfile (#7873)
* Update Dockerfile * Readd telemetry optout * Update Petstore samples
1 parent 2e69e6c commit 12abfb9

File tree

7 files changed

+37
-23
lines changed

7 files changed

+37
-23
lines changed
Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1-
FROM microsoft/dotnet:1.0.3-sdk-projectjson
1+
FROM microsoft/aspnetcore-build:2.0 AS build-env
2+
WORKDIR /app
23

34
ENV DOTNET_CLI_TELEMETRY_OPTOUT 1
45

5-
WORKDIR /app/{{packageName}}
6-
COPY . /app/{{packageName}}
6+
# copy csproj and restore as distinct layers
7+
COPY *.csproj ./
8+
RUN dotnet restore
79

8-
EXPOSE 5000/tcp
10+
# copy everything else and build
11+
COPY . ./
12+
RUN dotnet publish -c Release -o out
913

10-
RUN ["dotnet", "restore"]
11-
ENTRYPOINT ["dotnet", "run", "-p", "project.json", "web"]
14+
# build runtime image
15+
FROM microsoft/aspnetcore:2.0
16+
WORKDIR /app
17+
COPY --from=build-env /app/out .
18+
ENTRYPOINT ["dotnet", "{{packageName}}.dll"]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.4.0-SNAPSHOT
1+
unset

samples/server/petstore/aspnetcore/src/IO.Swagger/Controllers/PetApi.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public virtual IActionResult FindPetsByStatus([FromQuery][Required()]List<string
9292

9393
string exampleJson = null;
9494
exampleJson = "<Pet>\n <id>123456789</id>\n <name>doggie</name>\n <photoUrls>\n <photoUrls>aeiou</photoUrls>\n </photoUrls>\n <tags>\n </tags>\n <status>aeiou</status>\n</Pet>";
95-
exampleJson = "[ {\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}, {\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n} ]";
95+
exampleJson = "[ {\r\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\r\n \"name\" : \"doggie\",\r\n \"id\" : 0,\r\n \"category\" : {\r\n \"name\" : \"name\",\r\n \"id\" : 6\r\n },\r\n \"tags\" : [ {\r\n \"name\" : \"name\",\r\n \"id\" : 1\r\n }, {\r\n \"name\" : \"name\",\r\n \"id\" : 1\r\n } ],\r\n \"status\" : \"available\"\r\n}, {\r\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\r\n \"name\" : \"doggie\",\r\n \"id\" : 0,\r\n \"category\" : {\r\n \"name\" : \"name\",\r\n \"id\" : 6\r\n },\r\n \"tags\" : [ {\r\n \"name\" : \"name\",\r\n \"id\" : 1\r\n }, {\r\n \"name\" : \"name\",\r\n \"id\" : 1\r\n } ],\r\n \"status\" : \"available\"\r\n} ]";
9696

9797
var example = exampleJson != null
9898
? JsonConvert.DeserializeObject<List<Pet>>(exampleJson)
@@ -123,7 +123,7 @@ public virtual IActionResult FindPetsByTags([FromQuery][Required()]List<string>
123123

124124
string exampleJson = null;
125125
exampleJson = "<Pet>\n <id>123456789</id>\n <name>doggie</name>\n <photoUrls>\n <photoUrls>aeiou</photoUrls>\n </photoUrls>\n <tags>\n </tags>\n <status>aeiou</status>\n</Pet>";
126-
exampleJson = "[ {\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}, {\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n} ]";
126+
exampleJson = "[ {\r\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\r\n \"name\" : \"doggie\",\r\n \"id\" : 0,\r\n \"category\" : {\r\n \"name\" : \"name\",\r\n \"id\" : 6\r\n },\r\n \"tags\" : [ {\r\n \"name\" : \"name\",\r\n \"id\" : 1\r\n }, {\r\n \"name\" : \"name\",\r\n \"id\" : 1\r\n } ],\r\n \"status\" : \"available\"\r\n}, {\r\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\r\n \"name\" : \"doggie\",\r\n \"id\" : 0,\r\n \"category\" : {\r\n \"name\" : \"name\",\r\n \"id\" : 6\r\n },\r\n \"tags\" : [ {\r\n \"name\" : \"name\",\r\n \"id\" : 1\r\n }, {\r\n \"name\" : \"name\",\r\n \"id\" : 1\r\n } ],\r\n \"status\" : \"available\"\r\n} ]";
127127

128128
var example = exampleJson != null
129129
? JsonConvert.DeserializeObject<List<Pet>>(exampleJson)
@@ -158,7 +158,7 @@ public virtual IActionResult GetPetById([FromRoute][Required]long? petId)
158158

159159
string exampleJson = null;
160160
exampleJson = "<Pet>\n <id>123456789</id>\n <name>doggie</name>\n <photoUrls>\n <photoUrls>aeiou</photoUrls>\n </photoUrls>\n <tags>\n </tags>\n <status>aeiou</status>\n</Pet>";
161-
exampleJson = "{\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\n \"name\" : \"doggie\",\n \"id\" : 0,\n \"category\" : {\n \"name\" : \"name\",\n \"id\" : 6\n },\n \"tags\" : [ {\n \"name\" : \"name\",\n \"id\" : 1\n }, {\n \"name\" : \"name\",\n \"id\" : 1\n } ],\n \"status\" : \"available\"\n}";
161+
exampleJson = "{\r\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\r\n \"name\" : \"doggie\",\r\n \"id\" : 0,\r\n \"category\" : {\r\n \"name\" : \"name\",\r\n \"id\" : 6\r\n },\r\n \"tags\" : [ {\r\n \"name\" : \"name\",\r\n \"id\" : 1\r\n }, {\r\n \"name\" : \"name\",\r\n \"id\" : 1\r\n } ],\r\n \"status\" : \"available\"\r\n}";
162162

163163
var example = exampleJson != null
164164
? JsonConvert.DeserializeObject<Pet>(exampleJson)
@@ -234,7 +234,7 @@ public virtual IActionResult UploadFile([FromRoute][Required]long? petId, [FromF
234234
// return StatusCode(200, default(ApiResponse));
235235

236236
string exampleJson = null;
237-
exampleJson = "{\n \"code\" : 0,\n \"type\" : \"type\",\n \"message\" : \"message\"\n}";
237+
exampleJson = "{\r\n \"code\" : 0,\r\n \"type\" : \"type\",\r\n \"message\" : \"message\"\r\n}";
238238

239239
var example = exampleJson != null
240240
? JsonConvert.DeserializeObject<ApiResponse>(exampleJson)

samples/server/petstore/aspnetcore/src/IO.Swagger/Controllers/StoreApi.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public virtual IActionResult GetInventory()
7070
// return StatusCode(200, default(Dictionary<string, int?>));
7171

7272
string exampleJson = null;
73-
exampleJson = "{\n \"key\" : 0\n}";
73+
exampleJson = "{\r\n \"key\" : 0\r\n}";
7474

7575
var example = exampleJson != null
7676
? JsonConvert.DeserializeObject<Dictionary<string, int?>>(exampleJson)
@@ -105,7 +105,7 @@ public virtual IActionResult GetOrderById([FromRoute][Required][Range(1, 5)]long
105105

106106
string exampleJson = null;
107107
exampleJson = "<Order>\n <id>123456789</id>\n <petId>123456789</petId>\n <quantity>123</quantity>\n <shipDate>2000-01-23T04:56:07.000Z</shipDate>\n <status>aeiou</status>\n <complete>true</complete>\n</Order>";
108-
exampleJson = "{\n \"petId\" : 6,\n \"quantity\" : 1,\n \"id\" : 0,\n \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\",\n \"complete\" : false,\n \"status\" : \"placed\"\n}";
108+
exampleJson = "{\r\n \"petId\" : 6,\r\n \"quantity\" : 1,\r\n \"id\" : 0,\r\n \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"complete\" : false,\r\n \"status\" : \"placed\"\r\n}";
109109

110110
var example = exampleJson != null
111111
? JsonConvert.DeserializeObject<Order>(exampleJson)
@@ -136,7 +136,7 @@ public virtual IActionResult PlaceOrder([FromBody]Order body)
136136

137137
string exampleJson = null;
138138
exampleJson = "<Order>\n <id>123456789</id>\n <petId>123456789</petId>\n <quantity>123</quantity>\n <shipDate>2000-01-23T04:56:07.000Z</shipDate>\n <status>aeiou</status>\n <complete>true</complete>\n</Order>";
139-
exampleJson = "{\n \"petId\" : 6,\n \"quantity\" : 1,\n \"id\" : 0,\n \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\",\n \"complete\" : false,\n \"status\" : \"placed\"\n}";
139+
exampleJson = "{\r\n \"petId\" : 6,\r\n \"quantity\" : 1,\r\n \"id\" : 0,\r\n \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\",\r\n \"complete\" : false,\r\n \"status\" : \"placed\"\r\n}";
140140

141141
var example = exampleJson != null
142142
? JsonConvert.DeserializeObject<Order>(exampleJson)

samples/server/petstore/aspnetcore/src/IO.Swagger/Controllers/UserApi.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public virtual IActionResult DeleteUser([FromRoute][Required]string username)
115115
/// Get user by user name
116116
/// </summary>
117117

118-
/// <param name="username">The name that needs to be fetched. Use user1 for testing. </param>
118+
/// <param name="username">The name that needs to be fetched. Use user1 for testing.</param>
119119
/// <response code="200">successful operation</response>
120120
/// <response code="400">Invalid username supplied</response>
121121
/// <response code="404">User not found</response>
@@ -137,7 +137,7 @@ public virtual IActionResult GetUserByName([FromRoute][Required]string username)
137137

138138
string exampleJson = null;
139139
exampleJson = "<User>\n <id>123456789</id>\n <username>aeiou</username>\n <firstName>aeiou</firstName>\n <lastName>aeiou</lastName>\n <email>aeiou</email>\n <password>aeiou</password>\n <phone>aeiou</phone>\n <userStatus>123</userStatus>\n</User>";
140-
exampleJson = "{\n \"firstName\" : \"firstName\",\n \"lastName\" : \"lastName\",\n \"password\" : \"password\",\n \"userStatus\" : 6,\n \"phone\" : \"phone\",\n \"id\" : 0,\n \"email\" : \"email\",\n \"username\" : \"username\"\n}";
140+
exampleJson = "{\r\n \"firstName\" : \"firstName\",\r\n \"lastName\" : \"lastName\",\r\n \"password\" : \"password\",\r\n \"userStatus\" : 6,\r\n \"phone\" : \"phone\",\r\n \"id\" : 0,\r\n \"email\" : \"email\",\r\n \"username\" : \"username\"\r\n}";
141141

142142
var example = exampleJson != null
143143
? JsonConvert.DeserializeObject<User>(exampleJson)
Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1-
FROM microsoft/dotnet:1.0.3-sdk-projectjson
1+
FROM microsoft/aspnetcore-build:2.0 AS build-env
2+
WORKDIR /app
23

34
ENV DOTNET_CLI_TELEMETRY_OPTOUT 1
45

5-
WORKDIR /app/IO.Swagger
6-
COPY . /app/IO.Swagger
6+
# copy csproj and restore as distinct layers
7+
COPY *.csproj ./
8+
RUN dotnet restore
79

8-
EXPOSE 5000/tcp
10+
# copy everything else and build
11+
COPY . ./
12+
RUN dotnet publish -c Release -o out
913

10-
RUN ["dotnet", "restore"]
11-
ENTRYPOINT ["dotnet", "run", "-p", "project.json", "web"]
14+
# build runtime image
15+
FROM microsoft/aspnetcore:2.0
16+
WORKDIR /app
17+
COPY --from=build-env /app/out .
18+
ENTRYPOINT ["dotnet", "IO.Swagger.dll"]

samples/server/petstore/aspnetcore/src/IO.Swagger/wwwroot/swagger-original.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@
563563
"parameters" : [ {
564564
"name" : "username",
565565
"in" : "path",
566-
"description" : "The name that needs to be fetched. Use user1 for testing. ",
566+
"description" : "The name that needs to be fetched. Use user1 for testing.",
567567
"required" : true,
568568
"type" : "string"
569569
} ],

0 commit comments

Comments
 (0)