Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Commit 6fd4f46

Browse files
committed
Fix for rabbitMQ under windows containers.
Also some config tweaking on windows
1 parent 4e87a5c commit 6fd4f46

File tree

11 files changed

+152
-16
lines changed

11 files changed

+152
-16
lines changed

.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP=10.121.122.92
2121
#ESHOP_AZURE_STORAGE_CATALOG_KEY=<YourAzureStorageCatalogKey>
2222
#ESHOP_AZURE_STORAGE_MARKETING_NAME=<YourAzureStorageMarketingName>
2323
#ESHOP_AZURE_STORAGE_MARKETING_KEY=<YourAzureStorageMarketingKey>
24+
#ESHOP_SERVICE_BUS_USERNAME=<ServiceBusUserName-OnlyUsedIfUsingRabbitMQUnderwindows>
25+
#ESHOP_SERVICE_BUS_PASSWORD=<ServiceBusUserPassword-OnlyUsedIfUsingRabbitMQUnderwindows>

cli-windows/start-windows-containers.ps1

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
# rootPath: Root path of the repo (where docker-compose*.yml are). If not passed ../cli-windows/ is assumed
2+
# buildBits: If the projects must be built before. Default value: $true
3+
# 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)
4+
15
Param(
26
[parameter(Mandatory=$false)][string] $rootPath,
7+
[parameter(Mandatory=$false)][bool] $customEventBusLoginPassword=$false,
38
[parameter(Mandatory=$false)][bool]$buildBits=$true
49
)
510

@@ -13,4 +18,15 @@ Write-Host "Root path used is $rootPath" -ForegroundColor Yellow
1318
if ($buildBits) {
1419
& $scriptPath\build-bits.ps1 -rootPath $rootPath
1520
}
16-
docker-compose -f "$rootPath\docker-compose-windows.yml" -f "$rootPath\docker-compose.override.yml" up
21+
22+
23+
$env:ESHOP_EXTERNAL_DNS_NAME_OR_IP = "10.0.75.1"
24+
$env:ESHOP_AZURE_STORAGE_CATALOG_URL ="http://10.0.75.1:5101/api/v1/catalog/items/[0]/pic/"
25+
$env:ESHOP_AZURE_STORAGE_MARKETING_URL ="http://10.0.75.1:5110/api/v1/campaigns/[0]/pic/"
26+
27+
if (-Not $customEventBusLoginPassword) {
28+
docker-compose -f "$rootPath\docker-compose-windows.yml" -f "$rootPath\docker-compose.override.yml" -f "$rootPath\docker-compose.override.windows.yml" up
29+
}
30+
else {
31+
docker-compose -f "$rootPath\docker-compose-windows.yml" -f "$rootPath\docker-compose.override.yml" up
32+
}

docker-compose-windows.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ services:
3838
- rabbitmq
3939

4040
marketing.api:
41-
image: eshop/marketing.api:${TAG:-latest}
41+
image: eshop/marketing.api-win:${TAG:-latest}
4242
build:
4343
context: ./src/Services/Marketing/Marketing.API
4444
dockerfile: Dockerfile
@@ -73,21 +73,21 @@ services:
7373
- marketing.api
7474

7575
webstatus:
76-
image: eshop/webstatus:${TAG:-latest}
76+
image: eshop/webstatus-win:${TAG:-latest}
7777
build:
7878
context: ./src/Web/WebStatus
7979
dockerfile: Dockerfile
8080

8181
payment.api:
82-
image: eshop/payment.api:${TAG:-latest}
82+
image: eshop/payment.api-win:${TAG:-latest}
8383
build:
8484
context: ./src/Services/Payment/Payment.API
8585
dockerfile: Dockerfile
8686
depends_on:
8787
- rabbitmq
8888

8989
locations.api:
90-
image: eshop/locations.api:${TAG:-latest}
90+
image: eshop/locations.api-win:${TAG:-latest}
9191
build:
9292
context: ./src/Services/Location/Locations.API
9393
dockerfile: Dockerfile
@@ -103,17 +103,11 @@ services:
103103

104104
basket.data:
105105
image: redis:nanoserver
106-
# build:
107-
# context: ./_docker/redis
108-
# dockerfile: Dockerfile
109106
ports:
110107
- "6379:6379"
111108

112109
rabbitmq:
113110
image: spring2/rabbitmq
114-
# build:
115-
# context: ./_docker/rabbitmq
116-
# dockerfile: Dockerfile
117111
ports:
118112
- "15672:15672"
119113
- "5672:5672"
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
version: '2.1'
2+
3+
# ONLY NEEDED WHEN RUNNING WINDOWS CONTAINERS
4+
#
5+
# This file sets the containers' environment variables:
6+
#
7+
# - EventBusUerName
8+
# - EventBusPassword
9+
#
10+
# To the default username & password used in the spring2/rabbitmq image.
11+
#
12+
# If you are using any other rabbitmq image with any other username/pwd then you can:
13+
#
14+
# Set your shell environment variables:
15+
# - ESHOP_SERVICE_BUS_USERNAME
16+
# - ESHOP_SERVICE_BUS_PASSWORD
17+
#
18+
# With the appropiate values (note that you can use .env file also) AND DO NOT USE THIS FILE when launching windows container:
19+
#
20+
# docker-compose -f docker-compose-windows.yml -f docker-compose.override.yml up
21+
# INSTEAD OF
22+
# docker-compose -f docker-compose-windows.yml -f docker-compose.override.yml -f docker-compose.override.windows.yml up
23+
24+
services:
25+
basket.api:
26+
environment:
27+
- EventBusUserName=admin
28+
- EventBusPassword=password
29+
30+
catalog.api:
31+
environment:
32+
- EventBusUserName=admin
33+
- EventBusPassword=password
34+
35+
ordering.api:
36+
environment:
37+
- EventBusUserName=admin
38+
- EventBusPassword=password
39+
40+
marketing.api:
41+
environment:
42+
- EventBusUserName=admin
43+
- EventBusPassword=password
44+
45+
payment.api:
46+
environment:
47+
- EventBusUserName=admin
48+
- EventBusPassword=password
49+
50+
locations.api:
51+
environment:
52+
- EventBusUserName=admin
53+
- EventBusPassword=password

docker-compose.override.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ services:
1616
- identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110.
1717
- IdentityUrlExternal=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105
1818
- EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq}
19+
- EventBusUserName=${ESHOP_SERVICE_BUS_USERNAME}
20+
- EventBusPassword=${ESHOP_SERVICE_BUS_PASSWORD}
1921
- AzureServiceBusEnabled=False
2022
ports:
2123
- "5103:80"
@@ -27,6 +29,8 @@ services:
2729
- ConnectionString=${ESHOP_AZURE_CATALOG_DB:-Server=sql.data;Database=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word}
2830
- 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.
2931
- EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq}
32+
- EventBusUserName=${ESHOP_SERVICE_BUS_USERNAME}
33+
- EventBusPassword=${ESHOP_SERVICE_BUS_PASSWORD}
3034
- AzureStorageAccountName=${ESHOP_AZURE_STORAGE_CATALOG_NAME}
3135
- AzureStorageAccountKey=${ESHOP_AZURE_STORAGE_CATALOG_KEY}
3236
- UseCustomizationData=True
@@ -47,7 +51,7 @@ services:
4751
- MarketingApiClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5110
4852
- BasketApiClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5103
4953
- OrderingApiClient=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5102
50-
- UseCustomizationData=True
54+
- UseCustomizationData=True
5155
ports:
5256
- "5105:80"
5357

@@ -59,6 +63,8 @@ services:
5963
- identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110.
6064
- IdentityUrlExternal=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105
6165
- EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq}
66+
- EventBusUserName=${ESHOP_SERVICE_BUS_USERNAME}
67+
- EventBusPassword=${ESHOP_SERVICE_BUS_PASSWORD}
6268
- UseCustomizationData=True
6369
- AzureServiceBusEnabled=False
6470
- GracePeriodTime=1
@@ -74,6 +80,8 @@ services:
7480
- MongoConnectionString=${ESHOP_AZURE_COSMOSDB:-mongodb://nosql.data}
7581
- MongoDatabase=MarketingDb
7682
- EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq}
83+
- EventBusUserName=${ESHOP_SERVICE_BUS_USERNAME}
84+
- EventBusPassword=${ESHOP_SERVICE_BUS_PASSWORD}
7785
- identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110.
7886
- IdentityUrlExternal=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105
7987
- CampaignDetailFunctionUri=${ESHOP_AZUREFUNC_CAMPAIGN_DETAILS_URI}
@@ -137,6 +145,8 @@ services:
137145
- ASPNETCORE_ENVIRONMENT=Development
138146
- ASPNETCORE_URLS=http://0.0.0.0:80
139147
- EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq}
148+
- EventBusUserName=${ESHOP_SERVICE_BUS_USERNAME}
149+
- EventBusPassword=${ESHOP_SERVICE_BUS_PASSWORD}
140150
- AzureServiceBusEnabled=False
141151
ports:
142152
- "5108:80"
@@ -150,6 +160,8 @@ services:
150160
- identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110.
151161
- IdentityUrlExternal=http://${ESHOP_EXTERNAL_DNS_NAME_OR_IP}:5105
152162
- EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq}
163+
- EventBusUserName=${ESHOP_SERVICE_BUS_USERNAME}
164+
- EventBusPassword=${ESHOP_SERVICE_BUS_PASSWORD}
153165
- AzureServiceBusEnabled=False
154166
ports:
155167
- "5109:80"

src/Services/Basket/Basket.API/Startup.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,15 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
103103
HostName = Configuration["EventBusConnection"]
104104
};
105105

106+
if (!string.IsNullOrEmpty(Configuration["EventBusUserName"])) {
107+
factory.UserName = Configuration["EventBusUserName"];
108+
}
109+
110+
if (!string.IsNullOrEmpty(Configuration["EventBusPassword"]))
111+
{
112+
factory.Password = Configuration["EventBusPassword"];
113+
}
114+
106115
return new DefaultRabbitMQPersistentConnection(factory, logger);
107116
});
108117
}

src/Services/Catalog/Catalog.API/Startup.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,22 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
132132
{
133133
var settings = sp.GetRequiredService<IOptions<CatalogSettings>>().Value;
134134
var logger = sp.GetRequiredService<ILogger<DefaultRabbitMQPersistentConnection>>();
135+
135136
var factory = new ConnectionFactory()
136137
{
137-
HostName = settings.EventBusConnection
138+
HostName = Configuration["EventBusConnection"]
138139
};
139140

141+
if (!string.IsNullOrEmpty(Configuration["EventBusUserName"]))
142+
{
143+
factory.UserName = Configuration["EventBusUserName"];
144+
}
145+
146+
if (!string.IsNullOrEmpty(Configuration["EventBusPassword"]))
147+
{
148+
factory.Password = Configuration["EventBusPassword"];
149+
}
150+
140151
return new DefaultRabbitMQPersistentConnection(factory, logger);
141152
});
142153
}

src/Services/Location/Locations.API/Startup.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,22 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
6262
services.AddSingleton<IRabbitMQPersistentConnection>(sp =>
6363
{
6464
var logger = sp.GetRequiredService<ILogger<DefaultRabbitMQPersistentConnection>>();
65-
66-
var factory = new ConnectionFactory
65+
66+
var factory = new ConnectionFactory()
6767
{
6868
HostName = Configuration["EventBusConnection"]
6969
};
7070

71+
if (!string.IsNullOrEmpty(Configuration["EventBusUserName"]))
72+
{
73+
factory.UserName = Configuration["EventBusUserName"];
74+
}
75+
76+
if (!string.IsNullOrEmpty(Configuration["EventBusPassword"]))
77+
{
78+
factory.Password = Configuration["EventBusPassword"];
79+
}
80+
7181
return new DefaultRabbitMQPersistentConnection(factory, logger);
7282
});
7383
}

src/Services/Marketing/Marketing.API/Startup.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,15 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
106106
HostName = Configuration["EventBusConnection"]
107107
};
108108

109+
if (!string.IsNullOrEmpty(Configuration["EventBusUserName"]))
110+
{
111+
factory.UserName = Configuration["EventBusUserName"];
112+
}
113+
114+
if (!string.IsNullOrEmpty(Configuration["EventBusPassword"]))
115+
{
116+
factory.Password = Configuration["EventBusPassword"];
117+
}
109118
return new DefaultRabbitMQPersistentConnection(factory, logger);
110119
});
111120
}

src/Services/Ordering/Ordering.API/Startup.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,22 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
148148
{
149149
var logger = sp.GetRequiredService<ILogger<DefaultRabbitMQPersistentConnection>>();
150150

151+
151152
var factory = new ConnectionFactory()
152153
{
153154
HostName = Configuration["EventBusConnection"]
154155
};
155156

157+
if (!string.IsNullOrEmpty(Configuration["EventBusUserName"]))
158+
{
159+
factory.UserName = Configuration["EventBusUserName"];
160+
}
161+
162+
if (!string.IsNullOrEmpty(Configuration["EventBusPassword"]))
163+
{
164+
factory.Password = Configuration["EventBusPassword"];
165+
}
166+
156167
return new DefaultRabbitMQPersistentConnection(factory, logger);
157168
});
158169
}

0 commit comments

Comments
 (0)