iT邦幫忙

第 12 屆 iThome 鐵人賽

DAY 30
2
Modern Web

一袋.NET要扛幾樓?打造容器化的ASP.NET Core網站!系列 第 30

[Day30] 建立購物車系統 - 13 & 完賽心得

  • 分享至 

  • xImage
  •  

1. 修改docker-compose.yml

將購物車與其他系統都改成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...

https://ithelp.ithome.com.tw/upload/images/20201015/20128651z9IJMwkLb2.png

圖1

-------------------------------------------------------------

感謝鐵人賽讓我重拾寫文章的動力,只是真的寫得不是很好,中間很多功能沒實作完整、又有Bug,時間太趕就寫得零零落落QQ 之後會在個人Blog重新整理完整的流程,並把原先目標的功能都寫完~

謝謝訂閱支持我的網友,小弟的文章獻醜了~


上一篇
[Day29] 建立購物車系統 - 12
系列文
一袋.NET要扛幾樓?打造容器化的ASP.NET Core網站!30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言