Skip to content

Commit 98f4d39

Browse files
committed
Rename net to blog
1 parent cc522c8 commit 98f4d39

20 files changed

+49
-8
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

course/Controllers/HomeController.cs renamed to blog/Controllers/HomeController.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class HomeController : Controller
1414
[HttpGet]
1515
public string Get()
1616
{
17-
return "Blog APIs";
17+
return "<h1>Blog REST API by ASP.net MVC Core</h1>";
1818
}
1919
}
2020
}
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
FROM microsoft/aspnetcore-build:2.0 AS build-env
1+
FROM microsoft/aspnetcore-build:latest AS build-env
22
WORKDIR /app
33

4-
# Copy csproj and restore as distinct layers
4+
# copy csproj and restore as distinct layers
55
COPY *.csproj ./
66
RUN dotnet restore
77

@@ -10,8 +10,11 @@ COPY . ./
1010
RUN dotnet publish -c Release -o out
1111

1212
# Build runtime image
13-
FROM microsoft/aspnetcore:2.0
13+
FROM microsoft/aspnetcore:latest
1414
WORKDIR /app
1515
COPY --from=build-env /app/out .
1616

17+
EXPOSE 8002/tcp
18+
ENV ASPNETCORE_URLS http://*:8002
19+
1720
ENTRYPOINT ["dotnet", "blog.dll"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

docker-compose.yml

+35-2
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
version: '3'
22
services:
3+
#----- API Gatway ---------
34
nginx:
45
image: 'nginx:alpine'
56
container_name: 'api_gateway'
67
depends_on:
78
- api_customer
89
- api_book
10+
- api_blog
911
volumes:
1012
- ./gateway/default.conf:/etc/nginx/conf.d/default.conf
1113
- ./gateway/index.html:/usr/share/nginx/html/index.html
1214
ports:
1315
- '80:80'
1416
networks:
1517
- proxy
18+
#----- REST API Customer powered by Node.js
1619
api_customer:
1720
container_name: 'api_customer'
1821
build:
@@ -22,6 +25,7 @@ services:
2225
- '8000:8000'
2326
networks:
2427
- proxy
28+
#----- REST API Book powered by Golang
2529
api_book: # Golang REST service
2630
container_name: 'api_book'
2731
build:
@@ -33,7 +37,8 @@ services:
3337
- '8001:8001'
3438
networks:
3539
- proxy
36-
- db
40+
- db
41+
#----- Postgresql DB is used by REST API Book
3742
go_db:
3843
image: 'postgres:alpine'
3944
container_name: 'go_db'
@@ -43,7 +48,35 @@ services:
4348
- POSTGRES_USER=docker
4449
- POSTGRES_PASSWORD=docker
4550
networks:
46-
- db
51+
- db
52+
#----- REST API Blog powered by ASP.net MVC Core
53+
api_blog:
54+
container_name: 'api_blog'
55+
build:
56+
context: ./blog/
57+
image: api_blog:latest
58+
depends_on:
59+
- mssqlserver
60+
ports:
61+
- '8002:8002'
62+
networks:
63+
- proxy
64+
- db
65+
#----- SQLServer DB is used by REST API api_blog
66+
mssqlserver:
67+
container_name: sqlserver
68+
image: microsoft/mssql-server-linux:2017-latest
69+
environment:
70+
- ACCEPT_EULA=Y
71+
- SA_PASSWORD=SA123456!
72+
ports:
73+
- "1433:1433"
74+
logging:
75+
options:
76+
max-size: 1m
77+
networks:
78+
- db
79+
#----- Define networks
4780
networks:
4881
proxy:
4982
db:

gateway/default.conf

+4
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,8 @@ server {
1414
location /book/ {
1515
proxy_pass http://api_book:8001/;
1616
}
17+
18+
location /blog/ {
19+
proxy_pass http://api_blog:8002/;
20+
}
1721
}

gateway/index.html

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ <h1>Nginx làm API Gate (reverse proxy) cho các REST API phía sau</h1>
99

1010
<ul>
1111
<li><a href="http://localhost">Trang chủ</a></li>
12-
<li><a href="http://localhost/customer/list">localhost/customer/list</a> trỏ đến <a href="http://localhost:8000/list">localhost:8000/list</a></li>
13-
<li><a href="http://localhost/book/books">localhoost/book/books</a> trở đến <a href="http://localhost:8001/books">localhost:8001/books</a></li>
12+
<li><a href="http://localhost/customer/list">localhost/customer/list</a> ==> <a href="http://localhost:8000/list">localhost:8000/list</a></li>
13+
<li><a href="http://localhost/book/books">localhost/book/books</a> ==> <a href="http://localhost:8001/books">localhost:8001/books</a></li>
14+
<li><a href="http://localhost/blog/posts">localhost/blog/posts</a> ==> <a href="http://localhost:8002/posts">localhost:8002/posts</a></li>
1415
</ul>
1516
</body>
1617
</html>

0 commit comments

Comments
 (0)