Browse Source

Fix for rabbitMQ under windows containers.

Also some config tweaking on windows
pull/317/head
Eduard Tomàs 7 years ago
parent
commit
6fd4f46058
11 changed files with 152 additions and 16 deletions
  1. +2
    -0
      .env
  2. +17
    -1
      cli-windows/start-windows-containers.ps1
  3. +4
    -10
      docker-compose-windows.yml
  4. +53
    -0
      docker-compose.override.windows.yml
  5. +13
    -1
      docker-compose.override.yml
  6. +9
    -0
      src/Services/Basket/Basket.API/Startup.cs
  7. +12
    -1
      src/Services/Catalog/Catalog.API/Startup.cs
  8. +12
    -2
      src/Services/Location/Locations.API/Startup.cs
  9. +9
    -0
      src/Services/Marketing/Marketing.API/Startup.cs
  10. +11
    -0
      src/Services/Ordering/Ordering.API/Startup.cs
  11. +10
    -1
      src/Services/Payment/Payment.API/Startup.cs

+ 2
- 0
.env View File

@ -21,3 +21,5 @@ ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP=10.121.122.92
#ESHOP_AZURE_STORAGE_CATALOG_KEY=<YourAzureStorageCatalogKey> #ESHOP_AZURE_STORAGE_CATALOG_KEY=<YourAzureStorageCatalogKey>
#ESHOP_AZURE_STORAGE_MARKETING_NAME=<YourAzureStorageMarketingName> #ESHOP_AZURE_STORAGE_MARKETING_NAME=<YourAzureStorageMarketingName>
#ESHOP_AZURE_STORAGE_MARKETING_KEY=<YourAzureStorageMarketingKey> #ESHOP_AZURE_STORAGE_MARKETING_KEY=<YourAzureStorageMarketingKey>
#ESHOP_SERVICE_BUS_USERNAME=<ServiceBusUserName-OnlyUsedIfUsingRabbitMQUnderwindows>
#ESHOP_SERVICE_BUS_PASSWORD=<ServiceBusUserPassword-OnlyUsedIfUsingRabbitMQUnderwindows>

+ 17
- 1
cli-windows/start-windows-containers.ps1 View File

@ -1,5 +1,10 @@
# rootPath: Root path of the repo (where docker-compose*.yml are). If not passed ../cli-windows/ is assumed
# buildBits: If the projects must be built before. Default value: $true
# customEventBusLoginPassword: If a custom RabbitMQ image is used that do not use the default user login/pwd. Default: $false (means assume use default spring2/rabbitmq image)
Param( Param(
[parameter(Mandatory=$false)][string] $rootPath, [parameter(Mandatory=$false)][string] $rootPath,
[parameter(Mandatory=$false)][bool] $customEventBusLoginPassword=$false,
[parameter(Mandatory=$false)][bool]$buildBits=$true [parameter(Mandatory=$false)][bool]$buildBits=$true
) )
@ -13,4 +18,15 @@ Write-Host "Root path used is $rootPath" -ForegroundColor Yellow
if ($buildBits) { if ($buildBits) {
& $scriptPath\build-bits.ps1 -rootPath $rootPath & $scriptPath\build-bits.ps1 -rootPath $rootPath
} }
docker-compose -f "$rootPath\docker-compose-windows.yml" -f "$rootPath\docker-compose.override.yml" up
$env:ESHOP_EXTERNAL_DNS_NAME_OR_IP = "10.0.75.1"
$env:ESHOP_AZURE_STORAGE_CATALOG_URL ="http://10.0.75.1:5101/api/v1/catalog/items/[0]/pic/"
$env:ESHOP_AZURE_STORAGE_MARKETING_URL ="http://10.0.75.1:5110/api/v1/campaigns/[0]/pic/"
if (-Not $customEventBusLoginPassword) {
docker-compose -f "$rootPath\docker-compose-windows.yml" -f "$rootPath\docker-compose.override.yml" -f "$rootPath\docker-compose.override.windows.yml" up
}
else {
docker-compose -f "$rootPath\docker-compose-windows.yml" -f "$rootPath\docker-compose.override.yml" up
}

+ 4
- 10
docker-compose-windows.yml View File

@ -38,7 +38,7 @@ services:
- rabbitmq - rabbitmq
marketing.api: marketing.api:
image: eshop/marketing.api:${TAG:-latest}
image: eshop/marketing.api-win:${TAG:-latest}
build: build:
context: ./src/Services/Marketing/Marketing.API context: ./src/Services/Marketing/Marketing.API
dockerfile: Dockerfile dockerfile: Dockerfile
@ -73,13 +73,13 @@ services:
- marketing.api - marketing.api
webstatus: webstatus:
image: eshop/webstatus:${TAG:-latest}
image: eshop/webstatus-win:${TAG:-latest}
build: build:
context: ./src/Web/WebStatus context: ./src/Web/WebStatus
dockerfile: Dockerfile dockerfile: Dockerfile
payment.api: payment.api:
image: eshop/payment.api:${TAG:-latest}
image: eshop/payment.api-win:${TAG:-latest}
build: build:
context: ./src/Services/Payment/Payment.API context: ./src/Services/Payment/Payment.API
dockerfile: Dockerfile dockerfile: Dockerfile
@ -87,7 +87,7 @@ services:
- rabbitmq - rabbitmq
locations.api: locations.api:
image: eshop/locations.api:${TAG:-latest}
image: eshop/locations.api-win:${TAG:-latest}
build: build:
context: ./src/Services/Location/Locations.API context: ./src/Services/Location/Locations.API
dockerfile: Dockerfile dockerfile: Dockerfile
@ -103,17 +103,11 @@ services:
basket.data: basket.data:
image: redis:nanoserver image: redis:nanoserver
# build:
# context: ./_docker/redis
# dockerfile: Dockerfile
ports: ports:
- "6379:6379" - "6379:6379"
rabbitmq: rabbitmq:
image: spring2/rabbitmq image: spring2/rabbitmq
# build:
# context: ./_docker/rabbitmq
# dockerfile: Dockerfile
ports: ports:
- "15672:15672" - "15672:15672"
- "5672:5672" - "5672:5672"


+ 53
- 0
docker-compose.override.windows.yml View File

@ -0,0 +1,53 @@
version: '2.1'
# ONLY NEEDED WHEN RUNNING WINDOWS CONTAINERS
#
# This file sets the containers' environment variables:
#
# - EventBusUerName
# - EventBusPassword
#
# To the default username & password used in the spring2/rabbitmq image.
#
# If you are using any other rabbitmq image with any other username/pwd then you can:
#
# Set your shell environment variables:
# - ESHOP_SERVICE_BUS_USERNAME
# - ESHOP_SERVICE_BUS_PASSWORD
#
# With the appropiate values (note that you can use .env file also) AND DO NOT USE THIS FILE when launching windows container:
#
# docker-compose -f docker-compose-windows.yml -f docker-compose.override.yml up
# INSTEAD OF
# docker-compose -f docker-compose-windows.yml -f docker-compose.override.yml -f docker-compose.override.windows.yml up
services:
basket.api:
environment:
- EventBusUserName=admin
- EventBusPassword=password
catalog.api:
environment:
- EventBusUserName=admin
- EventBusPassword=password
ordering.api:
environment:
- EventBusUserName=admin
- EventBusPassword=password
marketing.api:
environment:
- EventBusUserName=admin
- EventBusPassword=password
payment.api:
environment:
- EventBusUserName=admin
- EventBusPassword=password
locations.api:
environment:
- EventBusUserName=admin
- EventBusPassword=password

+ 13
- 1
docker-compose.override.yml View File

@ -16,6 +16,8 @@ services:
- identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. - identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110.
- IdentityUrlExternal=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105 - IdentityUrlExternal=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105
- EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq} - EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq}
- EventBusUserName=${ESHOP_SERVICE_BUS_USERNAME}
- EventBusPassword=${ESHOP_SERVICE_BUS_PASSWORD}
- AzureServiceBusEnabled=False - AzureServiceBusEnabled=False
ports: ports:
- "5103:80" - "5103:80"
@ -27,6 +29,8 @@ services:
- ConnectionString=${ESHOP_AZURE_CATALOG_DB:-Server=sql.data;Database=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word} - ConnectionString=${ESHOP_AZURE_CATALOG_DB:-Server=sql.data;Database=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word}
- PicBaseUrl=${ESHOP_AZURE_STORAGE_CATALOG_URL:-http://localhost:5101/api/v1/catalog/items/[0]/pic/} #Local: You need to open your local dev-machine firewall at range 5100-5110. - PicBaseUrl=${ESHOP_AZURE_STORAGE_CATALOG_URL:-http://localhost:5101/api/v1/catalog/items/[0]/pic/} #Local: You need to open your local dev-machine firewall at range 5100-5110.
- EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq} - EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq}
- EventBusUserName=${ESHOP_SERVICE_BUS_USERNAME}
- EventBusPassword=${ESHOP_SERVICE_BUS_PASSWORD}
- AzureStorageAccountName=${ESHOP_AZURE_STORAGE_CATALOG_NAME} - AzureStorageAccountName=${ESHOP_AZURE_STORAGE_CATALOG_NAME}
- AzureStorageAccountKey=${ESHOP_AZURE_STORAGE_CATALOG_KEY} - AzureStorageAccountKey=${ESHOP_AZURE_STORAGE_CATALOG_KEY}
- UseCustomizationData=True - UseCustomizationData=True
@ -47,7 +51,7 @@ services:
- MarketingApiClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5110 - MarketingApiClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5110
- BasketApiClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5103 - BasketApiClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5103
- OrderingApiClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5102 - OrderingApiClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5102
- UseCustomizationData=True
- UseCustomizationData=True
ports: ports:
- "5105:80" - "5105:80"
@ -59,6 +63,8 @@ services:
- identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. - identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110.
- IdentityUrlExternal=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105 - IdentityUrlExternal=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105
- EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq} - EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq}
- EventBusUserName=${ESHOP_SERVICE_BUS_USERNAME}
- EventBusPassword=${ESHOP_SERVICE_BUS_PASSWORD}
- UseCustomizationData=True - UseCustomizationData=True
- AzureServiceBusEnabled=False - AzureServiceBusEnabled=False
- GracePeriodTime=1 - GracePeriodTime=1
@ -74,6 +80,8 @@ services:
- MongoConnectionString=${ESHOP_AZURE_COSMOSDB:-mongodb://nosql.data} - MongoConnectionString=${ESHOP_AZURE_COSMOSDB:-mongodb://nosql.data}
- MongoDatabase=MarketingDb - MongoDatabase=MarketingDb
- EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq} - EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq}
- EventBusUserName=${ESHOP_SERVICE_BUS_USERNAME}
- EventBusPassword=${ESHOP_SERVICE_BUS_PASSWORD}
- identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. - identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110.
- IdentityUrlExternal=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105 - IdentityUrlExternal=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105
- CampaignDetailFunctionUri=${ESHOP_AZUREFUNC_CAMPAIGN_DETAILS_URI} - CampaignDetailFunctionUri=${ESHOP_AZUREFUNC_CAMPAIGN_DETAILS_URI}
@ -137,6 +145,8 @@ services:
- ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://0.0.0.0:80 - ASPNETCORE_URLS=http://0.0.0.0:80
- EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq} - EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq}
- EventBusUserName=${ESHOP_SERVICE_BUS_USERNAME}
- EventBusPassword=${ESHOP_SERVICE_BUS_PASSWORD}
- AzureServiceBusEnabled=False - AzureServiceBusEnabled=False
ports: ports:
- "5108:80" - "5108:80"
@ -150,6 +160,8 @@ services:
- identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. - identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110.
- IdentityUrlExternal=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105 - IdentityUrlExternal=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105
- EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq} - EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq}
- EventBusUserName=${ESHOP_SERVICE_BUS_USERNAME}
- EventBusPassword=${ESHOP_SERVICE_BUS_PASSWORD}
- AzureServiceBusEnabled=False - AzureServiceBusEnabled=False
ports: ports:
- "5109:80" - "5109:80"


+ 9
- 0
src/Services/Basket/Basket.API/Startup.cs View File

@ -103,6 +103,15 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API
HostName = Configuration["EventBusConnection"] HostName = Configuration["EventBusConnection"]
}; };
if (!string.IsNullOrEmpty(Configuration["EventBusUserName"])) {
factory.UserName = Configuration["EventBusUserName"];
}
if (!string.IsNullOrEmpty(Configuration["EventBusPassword"]))
{
factory.Password = Configuration["EventBusPassword"];
}
return new DefaultRabbitMQPersistentConnection(factory, logger); return new DefaultRabbitMQPersistentConnection(factory, logger);
}); });
} }


+ 12
- 1
src/Services/Catalog/Catalog.API/Startup.cs View File

@ -132,11 +132,22 @@
{ {
var settings = sp.GetRequiredService<IOptions<CatalogSettings>>().Value; var settings = sp.GetRequiredService<IOptions<CatalogSettings>>().Value;
var logger = sp.GetRequiredService<ILogger<DefaultRabbitMQPersistentConnection>>(); var logger = sp.GetRequiredService<ILogger<DefaultRabbitMQPersistentConnection>>();
var factory = new ConnectionFactory() var factory = new ConnectionFactory()
{ {
HostName = settings.EventBusConnection
HostName = Configuration["EventBusConnection"]
}; };
if (!string.IsNullOrEmpty(Configuration["EventBusUserName"]))
{
factory.UserName = Configuration["EventBusUserName"];
}
if (!string.IsNullOrEmpty(Configuration["EventBusPassword"]))
{
factory.Password = Configuration["EventBusPassword"];
}
return new DefaultRabbitMQPersistentConnection(factory, logger); return new DefaultRabbitMQPersistentConnection(factory, logger);
}); });
} }


+ 12
- 2
src/Services/Location/Locations.API/Startup.cs View File

@ -62,12 +62,22 @@ namespace Microsoft.eShopOnContainers.Services.Locations.API
services.AddSingleton<IRabbitMQPersistentConnection>(sp => services.AddSingleton<IRabbitMQPersistentConnection>(sp =>
{ {
var logger = sp.GetRequiredService<ILogger<DefaultRabbitMQPersistentConnection>>(); var logger = sp.GetRequiredService<ILogger<DefaultRabbitMQPersistentConnection>>();
var factory = new ConnectionFactory
var factory = new ConnectionFactory()
{ {
HostName = Configuration["EventBusConnection"] HostName = Configuration["EventBusConnection"]
}; };
if (!string.IsNullOrEmpty(Configuration["EventBusUserName"]))
{
factory.UserName = Configuration["EventBusUserName"];
}
if (!string.IsNullOrEmpty(Configuration["EventBusPassword"]))
{
factory.Password = Configuration["EventBusPassword"];
}
return new DefaultRabbitMQPersistentConnection(factory, logger); return new DefaultRabbitMQPersistentConnection(factory, logger);
}); });
} }


+ 9
- 0
src/Services/Marketing/Marketing.API/Startup.cs View File

@ -106,6 +106,15 @@
HostName = Configuration["EventBusConnection"] HostName = Configuration["EventBusConnection"]
}; };
if (!string.IsNullOrEmpty(Configuration["EventBusUserName"]))
{
factory.UserName = Configuration["EventBusUserName"];
}
if (!string.IsNullOrEmpty(Configuration["EventBusPassword"]))
{
factory.Password = Configuration["EventBusPassword"];
}
return new DefaultRabbitMQPersistentConnection(factory, logger); return new DefaultRabbitMQPersistentConnection(factory, logger);
}); });
} }


+ 11
- 0
src/Services/Ordering/Ordering.API/Startup.cs View File

@ -148,11 +148,22 @@
{ {
var logger = sp.GetRequiredService<ILogger<DefaultRabbitMQPersistentConnection>>(); var logger = sp.GetRequiredService<ILogger<DefaultRabbitMQPersistentConnection>>();
var factory = new ConnectionFactory() var factory = new ConnectionFactory()
{ {
HostName = Configuration["EventBusConnection"] HostName = Configuration["EventBusConnection"]
}; };
if (!string.IsNullOrEmpty(Configuration["EventBusUserName"]))
{
factory.UserName = Configuration["EventBusUserName"];
}
if (!string.IsNullOrEmpty(Configuration["EventBusPassword"]))
{
factory.Password = Configuration["EventBusPassword"];
}
return new DefaultRabbitMQPersistentConnection(factory, logger); return new DefaultRabbitMQPersistentConnection(factory, logger);
}); });
} }


+ 10
- 1
src/Services/Payment/Payment.API/Startup.cs View File

@ -51,12 +51,21 @@ namespace Payment.API
services.AddSingleton<IRabbitMQPersistentConnection>(sp => services.AddSingleton<IRabbitMQPersistentConnection>(sp =>
{ {
var logger = sp.GetRequiredService<ILogger<DefaultRabbitMQPersistentConnection>>(); var logger = sp.GetRequiredService<ILogger<DefaultRabbitMQPersistentConnection>>();
var factory = new ConnectionFactory() var factory = new ConnectionFactory()
{ {
HostName = Configuration["EventBusConnection"] HostName = Configuration["EventBusConnection"]
}; };
if (!string.IsNullOrEmpty(Configuration["EventBusUserName"]))
{
factory.UserName = Configuration["EventBusUserName"];
}
if (!string.IsNullOrEmpty(Configuration["EventBusPassword"]))
{
factory.Password = Configuration["EventBusPassword"];
}
return new DefaultRabbitMQPersistentConnection(factory, logger); return new DefaultRabbitMQPersistentConnection(factory, logger);
}); });
} }


Loading…
Cancel
Save