將購物車與其他系統都改成docker執行,修改docker-compose.yml:
version: "3.4"
networks:
frontend:
backend:
services:
webmvc:
build:
context: .\src\Presentation\WebMvc
dockerfile: Dockerfile
environment:
- CatalogUrl=http://catalog
- IdentityUrl=https://${RPGSHOP_EXTERNAL_DNS_NAME_OR_IP}:7101
- CallBackUrl=http://${RPGSHOP_EXTERNAL_DNS_NAME_OR_IP}:7500/
- CartUrl=http://cart
container_name: rpgwebmvc
ports:
- "7500:80"
networks:
- frontend
depends_on:
- catalog
- auth
catalog:
build:
context: .\src\Services\CatalogApi
dockerfile: Dockerfile
image: rpgshop/catalog
environment:
- DatabaseServer=mssqlserver
- DatabaseName=CatalogDb
- DatabaseUser=sa
- DatabasePassword=JustTest!
- ExternalCatalogBaseUrl=http://${RPGSHOP_EXTERNAL_DNS_NAME_OR_IP}:7000
container_name: rpgcatalogapi
ports:
- "7000:80"
networks:
- backend
- frontend
depends_on:
- mssqlserver
auth:
build:
context: .\src\Services\AuthApi
dockerfile: Dockerfile
image: rpgshop/auth
environment:
- MvcClient=http://${RPGSHOP_EXTERNAL_DNS_NAME_OR_IP}:7500
- BasketApiClient=http://cart,
- DatabaseServer=mssqlserver
- DatabaseName=AuthDb
- DatabaseUser=sa
- DatabasePassword=JustTest!
- ExternalCatalogBaseUrl=http://${RPGSHOP_EXTERNAL_DNS_NAME_OR_IP}:7000
- ASPNETCORE_URLS=http://+:80;https://+:443
- ASPNETCORE_Kestrel__Certificates__Default__Password=crypticpassword
- ASPNETCORE_Kestrel__Certificates__Default__Path=./AuthApi.pfx
container_name: rpgauthapi
ports:
- "7100:80"
- "7101:443"
networks:
- backend
- frontend
depends_on:
- mssqlserver
cart:
build:
context: .\src\Services\CartApi
dockerfile: Dockerfile
image: rpgshop/cart
environment:
- ConnectionString=cart.data
- IdentityUrl=https://${RPGSHOP_EXTERNAL_DNS_NAME_OR_IP}:7101
container_name: rpgcartapi
ports:
- "7400:80"
networks:
- backend
- frontend
depends_on:
- cart.data
mssqlserver:
image: "microsoft/mssql-server-linux:latest"
ports:
- "1445:1433"
container_name: rpgmssqlcontainer
environment:
- ACCEPT_EULA=Y
- SA_PASSWORD=JustTest!
networks:
- backend
cart.data:
image: redis
ports:
- "6377:6379"
networks:
- backend
再執行docker-compose up
後,網頁輸入http://docker.for.win.localhost:7500/ 並測試購物車的功能,如圖1,只是還有Bug...
圖1
-------------------------------------------------------------
感謝鐵人賽讓我重拾寫文章的動力,只是真的寫得不是很好,中間很多功能沒實作完整、又有Bug,時間太趕就寫得零零落落QQ 之後會在個人Blog重新整理完整的流程,並把原先目標的功能都寫完~
謝謝訂閱支持我的網友,小弟的文章獻醜了~