Defintions service for BOnlineStore application
2.4K
BOnlineStore, .NET 8, Angular ve bulut-yerel teknolojilerle geliştirilmiş, kimlik yönetimi (IdentityServer), API Gateway (Ocelot), BFF ve alan servislerinden (Definitions, Production, Order) oluşan bir mikroservis projesidir. Altyapıda MongoDB, SQL Server, RabbitMQ ve log/observability için Seq kullanılır. Yerel geliştirici deneyimi için Docker Compose; üretim için Kubernetes manifestleri (Rancher uyumlu) sağlanır.
Not: Bu döküman, Windows/PowerShell akışını esas alır; komutlar PowerShell için verilmiştir.
flowchart LR
User((Kullanıcı)) -->
UI -->REST/HTTPS --> GW
UI --> OIDC .-> IDS[IdentityServer]
GW --> BFF[BFF Service]
GW --> DEF[Definitions API]
GW --> PRD[Production API]
GW --> ORD[Order API]
subgraph Data & Infra
MONGO[(MongoDB)]
SQL[(SQL Server / IdentityDB)]
MQ[(RabbitMQ)]
SEQ[(Seq)]
end
DEF --- MONGO
PRD --- MONGO
ORD --- MONGO
IDS --- SQL
BFF --- MONGO
DEF -. Pub/Sub .- MQ
PRD -. Pub/Sub .- MQ
ORD -. Pub/Sub .- MQ
IDS ==> SEQ
DEF ==> SEQ
PRD ==> SEQ
ORD ==> SEQ
BFF ==> SEQ
GW ==> SEQ
ClientApp)BOnlineStore.Gateway/: Ocelot tabanlı API Gateway (+ configuration.*.json)BOnlineStore.IdentityServer/: Kimlik yönetimi (IdentityServer), SQL Server’a bağlıBOnlineStore.Services/: Domain servisleri
BFF/, Definitions/, Production/, Order/BOnlineStore.UI/: UI host projesi, Angular kaynakları ClientApp/ altındaShared/: Ortak kütüphaneler, sertifikalar (Shared/Certificates/*)docker-compose.yml + docker-compose.override.yml: Yerel çoklu konteyner çalıştırmaKubernetes/: Servis başına deployment.yaml, config-map.yaml (bazılarında secret.yaml, PV/PVC)bitbucket-pipelines.yml: CI/CD tanımı (build/test/push)(İsteğe bağlı) hosts dosyası eşlemesi
Bazı konteyner içi ayarlar domain isimleri kullanır. Yerelde tarayıcıdan erişim için aşağıdaki host adlarını 127.0.0.1’e eşleyebilirsiniz:
identity.b-online-store.comgateway.b-online-store.comui.b-online-store.comdefinitions.b-online-store.comproduction.b-online-store.comorder.b-online-store.combff.b-online-store.comWindows yolu: C:\Windows\System32\drivers\etc\hosts
Örnek satırlar:
127.0.0.1 identity.b-online-store.com
127.0.0.1 gateway.b-online-store.com
127.0.0.1 ui.b-online-store.com
127.0.0.1 definitions.b-online-store.com
127.0.0.1 production.b-online-store.com
127.0.0.1 order.b-online-store.com
127.0.0.1 bff.b-online-store.com
(Güçlü parola ile) .env oluşturun
cp .env.example .env (Windows PowerShell için aşağıda komut var).env’i referans alacak şekilde özelleştirmek isterseniz compose dosyalarında değişken genişletme kullanabilirsiniz.Boşta portlar kontrolü
80 ve 443 portlarını açar; çakışma varsa bu portları docker-compose.override.yml içinde değiştirin.1444 (SQL), 27017 (Mongo), 15672 (RabbitMQ UI), 5672 (AMQP), 5341 (Seq UI).Konteynerleri başlatın
# Proje kökünde
Copy-Item .env.example .env -Force
# Docker Compose up (detached)
docker compose up -d
# Durum kontrolü
docker compose ps
Notlar:
bonlinestore.pfx kullanır (imaj içinde), UI tarafında tarayıcı uyarıları görebilirsiniz. Gerekirse http ile başlayın.# Yalnızca alt servisleri başlatmak isterseniz
# (docker-compose.override.yml servis bloklarını yorumlayarak özelleştirebilirsiniz)
docker compose up -d mongodb identitydbdocker rabbitmq seq
# Restore ve build
dotnet restore .\BOnlineStore.sln
dotnet build .\BOnlineStore.sln -c Debug
# IdentityServer (https://localhost:5001)
dotnet run --project .\BOnlineStore.IdentityServer\BOnlineStore.IdentityServer.csproj
# API Gateway (configuration.local.json okunur)
dotnet run --project .\BOnlineStore.Gateway\BOnlineStore.Gateway.csproj
# Domain servisleri (ihtiyaca göre ayrı terminallerde)
dotnet run --project .\BOnlineStore.Services\Definitions\BOnlineStore.Services.Definitions.Api\BOnlineStore.Services.Definitions.Api.csproj
dotnet run --project .\BOnlineStore.Services\Production\BOnlineStore.Services.Production.Api\BOnlineStore.Services.Production.Api.csproj
dotnet run --project .\BOnlineStore.Services\Order\BOnlineStore.Services.Order.Api\BOnlineStore.Services.Order.Api.csproj
# BFF
dotnet run --project .\BOnlineStore.Services\BFF\BOnlineStore.BFF\BOnlineStore.BFF.csproj
cd .\BOnlineStore.UI\ClientApp
npm ci
npm start
# varsayılan: http://localhost:4200
İpuçları:
appsettings.Development.json ve GatewayRunningMode=local (Gateway) varsayılanları uygundur; IdentityServerUrl genellikle https://localhost:5001.BOnlineStore.Gateway/appsettings.json
IdentityServerUrl: JWT doğrulama authorityGatewayRunningMode: local veya docker (Ocelot config dosya seçimi + Kestrel TLS yapılandırması)configuration.local.json, configuration.docker.json: Ocelot route tanımlarıBOnlineStore.IdentityServer/appsettings.json
ConnectionStrings:DefaultConnection: SQL Server bağlantısı (yerel: localhost,1444)IdentityConfigSettings:*: RedirectUri, CORS origin’ler, post-logout vb.BOnlineStore.UI/appsettings*.json ve Angular ortam dosyaları (ClientApp)appsettings değerleri override edilebilir.Güvenlik notu: Parolaları/secret’ları commit etmeyin. K8s Secret, CI değişkenleri veya .env ile dışarıda yönetin.
scakir1978/gateway.bonlinestore.comscakir1978/identityserver.bonlinestore.comscakir1978/bff.bonlinestore.comscakir1978/definitions.bonlinestore.comscakir1978/production.bonlinestore.comscakir1978/order.bonlinestore.comscakir1978/ui.bonlinestore.commongo, mcr.microsoft.com/mssql/server, rabbitmq:3.11-management, datalust/seqTag stratejisi:
latest + commit-id; develop için dev-<commit>, prod için prod-<commit> (Pipelines’ta tanımlı)Önkoşullar: kubectl, bir Kubernetes kümesi (Rancher uyumlu), storage class (Mongo için PV/PVC), Docker Hub pull yetkisi.
Önerilen sıra:
# Namespace kullanıyorsanız -n <ns> ekleyin
kubectl apply -f .\Kubernetes\mongodb\
kubectl apply -f .\Kubernetes\identitydb\ # varsa
kubectl apply -f .\Kubernetes\identity\
kubectl apply -f .\Kubernetes\definitions\
kubectl apply -f .\Kubernetes\production\
kubectl apply -f .\Kubernetes\bff\
kubectl apply -f .\Kubernetes\gateway\
kubectl apply -f .\Kubernetes\ui\
# Ingress/routing
kubectl apply -f .\Kubernetes\routing-ingress\
# Seq, RabbitMQ vb. (varsa ilgili klasörlerden)
kubectl apply -f .\Kubernetes\seq\
Notlar:
secret.yaml gereken klasörlerde Docker Hub pull secret’ı ve uygulama secret’larını doldurun.config-map.yaml ile servis URL’lerini ortamınıza göre ayarlayın.dotnet test) ilgili projeler için koşturulur (IdentityServer, Definitions)dev-*)DOCKERHUB_USERNAME, DOCKERHUB_PASSWORDPipeline kesitleri için: bitbucket-pipelines.yml
init-mongo.js örnek dosyaları repo kökünde/misc; Compose ve K8s’de persistent volume kullanılır (klasörlerde PV/PVC mevcut).SeedData.EnsureSeedData() ile başlangıç verisi/şeması yaratır (kendi gereksinimlerinize göre güncelleyin).appsettings.json üzerinden# Çekirdek testler
dotnet test .\BOnlineStore.UnitTests\BOnlineStore.IdentityServer.UnitTests\BOnlineStore.IdentityServer.UnitTests.csproj
dotnet test .\BOnlineStore.UnitTests\BOnlineStore.Services.Definitions.Api.UnitTests\BOnlineStore.Services.Definitions.Api.UnitTests.csproj
80/443/1444/27017/15672/5672/5341 kullanan süreçleri sonlandırın veya compose portlarını değiştirin.NODE_OPTIONS=--max_old_space_size=3072 kullanılıyor; yerelde de gerekebilir.IdentityServerUrl ve UI origin’lerinin eşleştiğini doğrulayın (IdentityConfigSettings).hosts eşlemesi yapın veya doğrudan localhost ile başlayın..env, K8s Secrets veya CI değişkenleriyle yönetin; koda gömmeyin.TrustServerCertificate=true yalnızca yerel/geliştirme içindir.main (prod), develop (geliştirme), feature branch’larlatest, commit SHA, dev-*, prod-*, staging-*LICENSEscakir1978# Compose başlatma
docker compose up -d
# Compose durdurma
docker compose down
# Logları izleme
docker compose logs -f --tail=200
# Tek servis yeniden başlatma (örnek: gateway)
docker compose up -d --build gateway.bonlinestore.com
Bu README, repo içeriği taranarak (Docker/K8s manifestleri, appsettings, Program.cs’ler, Pipelines) üretilmiştir. Ortamınıza göre host adları, portlar ve secret değerlerini güncellemeniz gerekebilir.
Content type
Image
Digest
sha256:17b2e05df…
Size
90.8 MB
Last updated
10 months ago
docker pull scakir1978/definitions.bonlinestore.com