@@ -108,13 +108,13 @@ A new project is added to the solution **docker-compose.dcproj** containing the
108
108
109
109
A **Dockerfile ** is also added to the **BackEnd ** project .
110
110
111
- ```docker
112
- FROM microsoft /dotnet : 2 . 1 - aspnetcore - runtime AS base
111
+ ```Dockerfile
112
+ FROM mcr . microsoft . com /dotnet / core / aspnet : 2 . 2 AS base
113
113
WORKDIR / app
114
114
EXPOSE 80
115
115
EXPOSE 443
116
116
117
- FROM microsoft / dotnet :2 . 1 - sdk AS build
117
+ FROM mcr . microsoft . com / dotnet / core / sdk :2 . 2 AS build
118
118
WORKDIR / src
119
119
COPY ConferencePlanner .sln ./
120
120
COPY BackEnd / BackEnd .csproj BackEnd /
@@ -135,13 +135,13 @@ ENTRYPOINT ["dotnet", "BackEnd.dll"]
135
135
136
136
Repeat the same step for the ** FrontEnd ** project . The Dockerfile is added to the project for it .
137
137
138
- ```docker
139
- FROM microsoft /dotnet : 2 . 1 - aspnetcore - runtime AS base
138
+ ```Dockerfile
139
+ FROM mcr . microsoft . com /dotnet / core / aspnet : 2 . 2 AS base
140
140
WORKDIR / app
141
141
EXPOSE 80
142
142
EXPOSE 443
143
143
144
- FROM microsoft / dotnet : 2 . 1 - sdk AS build
144
+ FROM mcr . microsoft . com / dotnet / core / sdk : 2 . 2 AS build
145
145
WORKDIR / src
146
146
COPY ConferencePlanner .sln ./
147
147
COPY FrontEnd / FrontEnd .csproj FrontEnd /
@@ -162,7 +162,7 @@ ENTRYPOINT ["dotnet", "FrontEnd.dll"]
162
162
163
163
The ** docker - compose .yml ** file is updated to reflect that there are two projects to build images .
164
164
165
- ```docker
165
+ ```yaml
166
166
version : '3'
167
167
168
168
services :
@@ -193,7 +193,7 @@ Using Docker, adding a container for SQL Server and linking the containers in th
193
193
194
194
Open the docker - compose .yml file and add the following entry . * Note the $ is doubled for escaping *
195
195
196
- ```docker
196
+ ```yaml
197
197
db :
198
198
image : " microsoft/mssql-server-linux"
199
199
environment :
@@ -203,7 +203,7 @@ Open the docker-compose.yml file and add the following entry. *Note the $ is dou
203
203
204
204
Since the ** BackEnd ** application must have connectivity and cannot start until the database container is ready . Add the **depends_on ** entry to the **backend ** definition in the compose file .
205
205
206
- ```docker
206
+ ```yaml
207
207
backend :
208
208
image : backend
209
209
build :
@@ -225,7 +225,7 @@ Finally, change the connection string for the database in the BackEnd\appsetting
225
225
226
226
In the ** docker - compose .yml ** file , add the ** links ** section to the ** frontend ** definition . This sets up the host name in the Docker networking allowing for the web application to call the API by name . `http :// backend`
227
227
228
- ```docker
228
+ ```yaml
229
229
frontend :
230
230
image : frontend
231
231
build :
@@ -246,7 +246,7 @@ Remove or comment out the `.UseUrls(http://localhost:56009)` in BackEnd\Program.
246
246
247
247
Finally open the ** docker - compose .override .yml ** file . Change the ports for the ** backend ** entry to `56009 : 80 ` and for the ** frontend ** , make it `5001 : 80 `
248
248
249
- ```docker
249
+ ```yaml
250
250
version : '3'
251
251
252
252
services :
@@ -273,20 +273,21 @@ Changes can be made to Razor pages and seen immediately without rebuilds, howeve
273
273
274
274
### Using VS Code or other editors
275
275
276
- Create and ddd the following Dockerfile for the BackEnd application .
276
+ Create and add the following Dockerfile for the BackEnd application .
277
277
278
- ```docker
279
- FROM microsoft / dotnet :2 . 1 - aspnetcore - runtime AS base
278
+ ```Dockerfile
279
+ FROM mcr . microsoft . com / dotnet / core / aspnet :2 . 2 AS base
280
280
WORKDIR / app
281
281
EXPOSE 80
282
282
EXPOSE 443
283
283
284
- FROM microsoft / dotnet : 2 . 1 - sdk AS build
284
+ FROM mcr . microsoft . com / dotnet / core / sdk : 2 . 2 AS build
285
285
WORKDIR / src
286
286
COPY ConferencePlanner .sln ./
287
287
COPY BackEnd / BackEnd .csproj BackEnd /
288
+ COPY FrontEnd / FrontEnd .csproj FrontEnd /
288
289
COPY ConferenceDTO / ConferenceDTO .csproj ConferenceDTO /
289
- RUN dotnet restore - nowarn : msb3202 , nu1503
290
+ RUN dotnet restore
290
291
COPY . .
291
292
WORKDIR / src / BackEnd
292
293
RUN dotnet build - c Release - o / app
@@ -301,20 +302,21 @@ ENTRYPOINT ["dotnet", "BackEnd.dll"]
301
302
302
303
```
303
304
304
- Create and ddd the following Dockerfile for the BackEnd application .
305
+ Create and add the following Dockerfile for the BackEnd application .
305
306
306
- ```docker
307
- FROM microsoft / dotnet : 2 . 1 - aspnetcore - runtime AS base
307
+ ```Dockerfile
308
+ FROM mcr . microsoft . com / dotnet / core / aspnet : 2 . 2 AS base
308
309
WORKDIR / app
309
310
EXPOSE 80
310
311
EXPOSE 443
311
312
312
- FROM microsoft / dotnet : 2 . 1 - sdk AS build
313
+ FROM mcr . microsoft . com / dotnet / core / sdk : 2 . 2 AS build
313
314
WORKDIR / src
314
315
COPY ConferencePlanner .sln ./
316
+ COPY BackEnd / BackEnd .csproj BackEnd /
315
317
COPY FrontEnd / FrontEnd .csproj FrontEnd /
316
318
COPY ConferenceDTO / ConferenceDTO .csproj ConferenceDTO /
317
- RUN dotnet restore - nowarn : msb3202 , nu1503
319
+ RUN dotnet restore
318
320
COPY . .
319
321
WORKDIR / src / FrontEnd
320
322
RUN dotnet build - c Release - o / app
@@ -331,7 +333,7 @@ ENTRYPOINT ["dotnet", "FrontEnd.dll"]
331
333
332
334
At the root of the ConferencePlanner solution , add the following ** docker - compose .yml ** file .
333
335
334
- ```docker
336
+ ```yaml
335
337
version : '3'
336
338
337
339
services :
@@ -342,7 +344,6 @@ services:
342
344
dockerfile : BackEnd / Dockerfile
343
345
ports :
344
346
- " 56009:80"
345
- - " 56001:443"
346
347
environment :
347
348
- ASPNETCORE_ENVIRONMENT = Development
348
349
depends_on :
@@ -354,8 +355,7 @@ services:
354
355
context : .
355
356
dockerfile : FrontEnd / Dockerfile
356
357
ports :
357
- - " 5001:80"
358
- - " 5003:443"
358
+ - " 5002:80"
359
359
environment :
360
360
- ASPNETCORE_ENVIRONMENT = Development
361
361
links :
@@ -394,6 +394,7 @@ Remove or comment out the `.UseUrls(http://localhost:56009)` in BackEnd\Program.
394
394
- Build the Docker images `docker - compose build `
395
395
- Run `docker - compose up - d ` to start the application
396
396
- Run `docker - compose down ` to stop the application
397
+ - Open the application at < http : // localhost:5002>
397
398
398
399
## Bonus
399
400
0 commit comments