Skip to content

Commit 32154f5

Browse files
committed
A bit more foreward. good luck!
1 parent 9dcd318 commit 32154f5

18 files changed

+114
-96
lines changed

src/Billing/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ ARG TARGETARCH
44
WORKDIR /src
55

66
COPY . .
7-
RUN dotnet publish src/Billing -c $BUILD_CONFIGURATION -o /app/publish --arch $TARGETARCH /p:UseAppHost=false
7+
RUN dotnet publish Billing -c $BUILD_CONFIGURATION -o /app/publish --arch $TARGETARCH /p:UseAppHost=false
88

99

10-
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
10+
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
1111
USER $APP_UID
1212
WORKDIR /app
13-
13+
EXPOSE 80
1414
COPY --from=build /app/publish .
1515
ENTRYPOINT ["dotnet", "Billing.dll"]

src/Billing/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ public static IHostBuilder CreateHostBuilder(string[] args)
3131
services.AddSignalR(options => { options.EnableDetailedErrors = true; });
3232
services.AddSingleton<SimulationEffects>();
3333
});
34-
webBuilder.UseUrls("http://*:5002");
34+
webBuilder.UseUrls($"http://*:{Environment.GetEnvironmentVariable("LISTENING_PORT") ?? "5002"}");
3535
webBuilder.Configure(app =>
3636
{
37-
app.UseCors(options => options.AllowAnyHeader().AllowAnyMethod().WithOrigins("http://localhost:61335").AllowCredentials());
37+
app.UseCors(options => options.AllowAnyHeader().AllowAnyMethod().WithOrigins(Environment.GetEnvironmentVariable("ORIGIN_URL") ?? "http://localhost:61335").AllowCredentials());
3838
app.UseRouting();
3939
app.UseEndpoints(endpoints =>
4040
{

src/ClientUI/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ ARG TARGETARCH
44
WORKDIR /src
55

66
COPY . .
7-
RUN dotnet publish src/ClientUI -c $BUILD_CONFIGURATION -o /app/publish --arch $TARGETARCH /p:UseAppHost=false
7+
RUN dotnet publish ClientUI -c $BUILD_CONFIGURATION -o /app/publish --arch $TARGETARCH /p:UseAppHost=false
88

99

10-
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
10+
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
1111
USER $APP_UID
1212
WORKDIR /app
13-
13+
EXPOSE 80
1414
COPY --from=build /app/publish .
1515
ENTRYPOINT ["dotnet", "ClientUI.dll"]

src/ClientUI/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ public static IHostBuilder CreateHostBuilder(string[] args)
3131
services.AddSignalR(options => { options.EnableDetailedErrors = true; });
3232
services.AddSingleton<SimulatedCustomers>();
3333
});
34-
webBuilder.UseUrls("http://*:5000");
34+
webBuilder.UseUrls($"http://*:{Environment.GetEnvironmentVariable("LISTENING_PORT") ?? "5000"}");
3535
webBuilder.Configure(app =>
3636
{
37-
app.UseCors(options => options.AllowAnyHeader().AllowAnyMethod().WithOrigins("http://localhost:61335").AllowCredentials());
37+
app.UseCors(options => options.AllowAnyHeader().AllowAnyMethod().WithOrigins(Environment.GetEnvironmentVariable("ORIGIN_URL") ?? "http://localhost:61335").AllowCredentials());
3838
app.UseRouting();
3939
app.UseEndpoints(endpoints =>
4040
{

src/Helper/BusRegistrationConfiguratorExt.cs

Lines changed: 32 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,50 @@
11
using dotenv.net;
2-
using Helper;
32
using MassTransit;
43

54
public static class BusRegistrationConfiguratorExt
65
{
76
public static void SetupTransport(this IBusRegistrationConfigurator x, string[] args)
87
{
9-
string selectedTransport;
8+
string selectedTransport = Environment.GetEnvironmentVariable("TRANSPORT_TYPE") ?? "RabbitMQ";
109

11-
if (args.Contains("--amazonsqs"))
10+
switch (selectedTransport)
1211
{
13-
x.UsingAmazonSqs((ctx, cfg) =>
14-
{
15-
var envs = DotEnv.Read(new DotEnvOptions(envFilePaths: [Path.GetFullPath("../../../sqs.env")]));
16-
cfg.Host(envs["AWS_REGION"], h =>
12+
case "AmazonSQS":
13+
x.UsingAmazonSqs((ctx, cfg) =>
1714
{
18-
h.AccessKey(envs["AWS_ACCESS_KEY_ID"]);
19-
h.SecretKey(envs["AWS_SECRET_ACCESS_KEY"]);
20-
});
21-
22-
cfg.ConfigureEndpoints(ctx);
23-
});
24-
selectedTransport = "AmazonSQS";
25-
}
26-
else if (args.Contains("--azureservicebus"))
27-
{
28-
var envs = DotEnv.Read(new DotEnvOptions(envFilePaths: [Path.GetFullPath("../../../asb.env")], ignoreExceptions: false));
29-
x.UsingAzureServiceBus((context, cfg) =>
30-
{
31-
cfg.Host(envs["CONNECTIONSTRING"]);
15+
var envs = DotEnv.Read(new DotEnvOptions(envFilePaths: [Path.GetFullPath("../../../sqs.env")]));
16+
cfg.Host(envs["AWS_REGION"], h =>
17+
{
18+
h.AccessKey(envs["AWS_ACCESS_KEY_ID"]);
19+
h.SecretKey(envs["AWS_SECRET_ACCESS_KEY"]);
20+
});
3221

33-
cfg.ConfigureEndpoints(context);
34-
});
22+
cfg.ConfigureEndpoints(ctx);
23+
});
24+
break;
25+
case "AzureServiceBus":
26+
var envs = DotEnv.Read(new DotEnvOptions(envFilePaths: [Path.GetFullPath("../../../asb.env")], ignoreExceptions: false));
27+
x.UsingAzureServiceBus((context, cfg) =>
28+
{
29+
cfg.Host(envs["CONNECTION_STRING"]);
3530

36-
selectedTransport = "Azure Service Bus";
37-
}
38-
else if (args.Contains("--rabbitmq"))
39-
{
40-
x.UsingRabbitMq((context, cfg) =>
41-
{
42-
cfg.Host("localhost", 33721, "/", h =>
31+
cfg.ConfigureEndpoints(context);
32+
});
33+
break;
34+
case "RabbitMQ":
35+
x.UsingRabbitMq((context, cfg) =>
4336
{
44-
h.Username("guest");
45-
h.Password("guest");
37+
cfg.Host("rabbitmq", 5672, "/", h =>
38+
{
39+
h.Username("guest");
40+
h.Password("guest");
41+
});
42+
cfg.ConfigureEndpoints(context);
4643
});
47-
cfg.ConfigureEndpoints(context);
48-
});
49-
selectedTransport = "RabbitMQ";
44+
break;
45+
default:
46+
throw new ArgumentException("No transport is chosen");
5047
}
51-
else
52-
{
53-
throw new ArgumentException("No transport is chosen");
54-
}
55-
56-
var name = Path.GetFileNameWithoutExtension(Environment.GetCommandLineArgs()[0]);
57-
Console.Title = name + " - " + selectedTransport;
5848

5949
x.AddConfigureEndpointsCallback((name, cfg) =>
6050
{

src/Sales/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ ARG TARGETARCH
44
WORKDIR /src
55

66
COPY . .
7-
RUN dotnet publish src/Sales -c $BUILD_CONFIGURATION -o /app/publish --arch $TARGETARCH /p:UseAppHost=false
7+
RUN dotnet publish Sales -c $BUILD_CONFIGURATION -o /app/publish --arch $TARGETARCH /p:UseAppHost=false
88

99

10-
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
10+
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
1111
USER $APP_UID
1212
WORKDIR /app
13-
13+
EXPOSE 80
1414
COPY --from=build /app/publish .
1515
ENTRYPOINT ["dotnet", "Sales.dll"]

src/Sales/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ public static IHostBuilder CreateHostBuilder(string[] args)
3131
services.AddSignalR(options => { options.EnableDetailedErrors = true; });
3232
services.AddSingleton<SimulationEffects>();
3333
});
34-
webBuilder.UseUrls("http://*:5001");
34+
webBuilder.UseUrls($"http://*:{Environment.GetEnvironmentVariable("LISTENING_PORT") ?? "5001"}");
3535
webBuilder.Configure(app =>
3636
{
37-
app.UseCors(options => options.AllowAnyHeader().AllowAnyMethod().WithOrigins("http://localhost:61335").AllowCredentials());
37+
app.UseCors(options => options.AllowAnyHeader().AllowAnyMethod().WithOrigins(Environment.GetEnvironmentVariable("ORIGIN_URL") ?? "http://localhost:61335").AllowCredentials());
3838
app.UseRouting();
3939
app.UseEndpoints(endpoints =>
4040
{

src/Shipping/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ ARG TARGETARCH
44
WORKDIR /src
55

66
COPY . .
7-
RUN dotnet publish src/Sales -c $BUILD_CONFIGURATION -o /app/publish --arch $TARGETARCH /p:UseAppHost=false
7+
RUN dotnet publish Sales -c $BUILD_CONFIGURATION -o /app/publish --arch $TARGETARCH /p:UseAppHost=false
88

99

10-
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
10+
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
1111
USER $APP_UID
1212
WORKDIR /app
13-
13+
EXPOSE 80
1414
COPY --from=build /app/publish .
1515
ENTRYPOINT ["dotnet", "Shipping.dll"]

src/Shipping/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ public static IHostBuilder CreateHostBuilder(string[] args)
3131
services.AddSignalR(options => { options.EnableDetailedErrors = true; });
3232
services.AddSingleton<SimulationEffects>();
3333
});
34-
webBuilder.UseUrls("http://*:5003");
34+
webBuilder.UseUrls($"http://*:{Environment.GetEnvironmentVariable("LISTENING_PORT") ?? "5003"}");
3535
webBuilder.Configure(app =>
3636
{
37-
app.UseCors(options => options.AllowAnyHeader().AllowAnyMethod().WithOrigins("http://localhost:61335").AllowCredentials());
37+
app.UseCors(options => options.AllowAnyHeader().AllowAnyMethod().WithOrigins(Environment.GetEnvironmentVariable("ORIGIN_URL") ?? "http://localhost:61335").AllowCredentials());
3838
app.UseRouting();
3939
app.UseEndpoints(endpoints =>
4040
{

src/docker-compose-base.yml

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ services:
2424
service-control:
2525
condition: service_healthy
2626
container_name: masstransit-connector
27-
image: particular/servicecontrol-connector-masstransit:0.1.0-alpha.4
27+
image: particular/servicecontrol-masstransit-connector:0.1.0-alpha.6
2828
volumes:
2929
- ./queues.txt:/app/queues.txt:ro
3030
environment:
@@ -39,56 +39,76 @@ services:
3939
ports:
4040
- 9090:9090
4141
environment:
42-
SERVICECONTROL_URL: http://localhost:33333/api/
42+
SERVICECONTROL_URL: http://servicecontrol:33333/api/
4343
ENABLE_REVERSE_PROXY: false
4444
SHOW_PENDING_RETRY: false
45-
vue-app:
46-
container_name: ui-app
45+
frontend:
46+
container_name: frontend
4747
build:
4848
context: ./frontend # Path to the folder containing Dockerfile
4949
dockerfile: Dockerfile
5050
ports:
51-
- "8080:80" # Map port 80 in the container to port 8080 on the host
51+
- "8080:80"
5252
depends_on:
5353
- billing
54+
- shipping
55+
- sales
56+
- clientui
5457
volumes:
5558
- ./frontend:/app # Optional for hot reloading
56-
restart: always
59+
environment:
60+
- BILLING_SIGNALR=billing:5002
61+
- CLIENT_SIGNALR=clientui:5000
62+
- SALES_SIGNALR=sales:5001
63+
- SHIPPING_SIGNALR=shipping:5003
5764
billing:
5865
build:
5966
context: ./
60-
dockerfile: ./src/Billing/Dockerfile
61-
container_name: billing
67+
dockerfile: ./Billing/Dockerfile
68+
container_name: billing
6269
ports:
63-
- "5002:5002"
70+
- "5002:80"
6471
environment:
65-
- ASPNETCORE_URLS=http://+:5002
72+
- LISTENING_PORT=80
73+
- ORIGIN_URL=http://frontend:8080
74+
- TRANSPORT_TYPE
75+
- CONNECTION_STRING
6676
shipping:
6777
build:
6878
context: ./
69-
dockerfile: ./src/Shipping/Dockerfile
70-
container_name: shipping
79+
dockerfile: ./Shipping/Dockerfile
80+
container_name: shipping
7181
ports:
72-
- "5003:5003"
82+
- "5003:80"
7383
environment:
74-
- ASPNETCORE_URLS=http://+:5003
84+
- LISTENING_PORT=80
85+
- ORIGIN_URL=http://frontend:8080
86+
- TRANSPORT_TYPE
87+
- CONNECTION_STRING
7588
sales:
7689
build:
7790
context: ./
78-
dockerfile: ./src/Sales/Dockerfile
79-
container_name: sales
91+
dockerfile: ./Sales/Dockerfile
92+
container_name: sales
8093
ports:
81-
- "5001:5001"
94+
- "5001:80"
8295
environment:
83-
- ASPNETCORE_URLS=http://+:5001
96+
- LISTENING_PORT=80
97+
- ORIGIN_URL=http://frontend:8080
98+
- TRANSPORT_TYPE
99+
- CONNECTION_STRING
84100
clientui:
85101
build:
86102
context: ./
87-
dockerfile: ./src/ClientUI/Dockerfile
88-
container_name: clientui
103+
dockerfile: ./ClientUI/Dockerfile
104+
container_name: clientui
89105
ports:
90-
- "5000:5000"
106+
- "5000:80"
91107
environment:
92-
- ASPNETCORE_URLS=http://+:5000
108+
- LISTENING_PORT=80
109+
- ORIGIN_URL=http://frontend:8080
110+
- TRANSPORT_TYPE
111+
- CONNECTION_STRING
112+
93113
volumes:
94114
sc-data:

0 commit comments

Comments
 (0)