118
CHAPTER 5 | Designing and Developing Multi-Container and Microservice-Based .NET Applications
basket-api:
image:
eshop/basket-api
environment:
-
ConnectionString=sqldata
ports:
-
"5103:80"
depends_on:
-
sqldata
sqldata:
environment:
-
SA_PASSWORD=
[
PLACEHOLDER
]
-
ACCEPT_EULA=Y
ports:
-
"5434:1433"
basketdata:
image:
redis
The root key in this file is services.
Under that key, you define the services you want to deploy and run
when you execute the
docker-compose up
command or when you deploy
from Visual Studio by using
this docker-compose.yml file. In this case, the docker-compose.yml file has multiple services defined,
as described in the following table.
Service
name
Description
webmvc
Container including the ASP.NET Core MVC application consuming the microservices
from server-side C#
catalog-api
Container including the Catalog ASP.NET Core Web API microservice
ordering-api Container including the Ordering ASP.NET Core Web API microservice
sqldata
Container running SQL
Server for Linux, holding the microservices databases
basket-api
Container with the Basket ASP.NET Core Web API microservice
basketdata
Container running the REDIS
cache service, with the basket database as a REDIS cache
A simple Web Service API container
Focusing on a single container, the catalog-api container-microservice has a
straightforward
definition:
catalog-api:
image:
eshop/catalog-api
environment:
-
ConnectionString=Server=sqldata;Initial Catalog=CatalogData;User
Id=sa;Password=
[
PLACEHOLDER
]
expose:
-
"80"
ports:
-
"5101:80"
#extra hosts can be used for standalone SQL Server or services at the dev PC
extra_hosts:
-
"CESARDLSURFBOOK:10.0.75.1"
119
CHAPTER 5 | Designing and Developing Multi-Container and Microservice-Based .NET Applications
depends_on:
-
sqldata
This containerized service has the following basic configuration:
•
It is based on the custom
Dostları ilə paylaş: