Skip to content

Commit b8b00b9

Browse files
committed
added api service to service
1 parent 11582e2 commit b8b00b9

File tree

13 files changed

+184
-139
lines changed

13 files changed

+184
-139
lines changed

README.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ docker-compose -f ./containers/infrastructure-bare.yml -f ./containers/infrastru
4848

4949
***Kubernetes cluster***
5050

51-
A second option is to setup the application inside a Kubernetes cluster.
51+
Second option is to setup the application inside a Kubernetes cluster.
5252

5353
To setup a Kubernetes cluster that can be used for production I suggest to looking at the repo:
5454
- [enterprise-containers](https://github.com/Genocs/enterprise-containers)
@@ -429,9 +429,6 @@ dotnet nuget push *.nupkg -k $NUGET_API_KEY -s $NUGET_SOURCE
429429
docker build -t genocs/demo-webapi:2.0.0 -t genocs/demo-webapi:latest -f ./demo-webapi.dockerfile .
430430
docker build -t genocs/apigateway:7.0.0 -f ./src/apps/containers/apigateway.dockerfile ../../.
431431

432-
433-
apigateway.dockerfile
434-
435432
# Push on Dockerhub
436433
docker push genocs/demo-webapi:2.0.0
437434
docker push genocs/demo-webapi:latest
@@ -444,7 +441,26 @@ docker push genocs/demo-worker:2.0.0
444441
docker push genocs/demo-worker:latest
445442
```
446443

447-
A second option is to run docker-compose
444+
445+
446+
# Enterprise Solution
447+
---
448+
---
449+
450+
inside **./src/apps** folder you can find the an application comosed by:
451+
- ApiGateway
452+
- Identity Service
453+
- Order service
454+
- Product Service
455+
- SignalR Service
456+
457+
In that way you can test the entire flow.
458+
459+
460+
461+
## How to build the solution
462+
463+
Run docker-compose
448464

449465
``` bash
450466
# Build with docker compose

src/apps/api-gateway/Genocs.APIGateway/appsettings.Docker.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,21 @@
5959
"demo-cluster": {
6060
"destinations": {
6161
"destination1": {
62-
"address": "http://localhost:5070"
62+
"address": "http://demo"
6363
}
6464
}
6565
},
6666
"order-cluster": {
6767
"destinations": {
6868
"destination1": {
69-
"address": "http://localhost:5002"
69+
"address": "http://order"
7070
}
7171
}
7272
},
7373
"product-cluster": {
7474
"destinations": {
7575
"destination1": {
76-
"address": "http://localhost:5003"
76+
"address": "http://product"
7777
}
7878
}
7979
}

src/apps/api-workbench.rest

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@
44
###############################################################################
55

66
#@url = https://localhost:5001
7-
@apigateway = http://localhost:5000
8-
@identity = https://localhost:5271
7+
#@apigateway = http://localhost:5000
8+
#@identity = https://localhost:5271
9+
10+
# Container version
11+
@apigateway = http://localhost:5500
12+
@identity = http://localhost:5510
13+
914

1015

1116
### Sign up as Admin
@@ -46,7 +51,7 @@ POST {{identity}}/refresh-tokens/revoke
4651
GET {{apigateway}}/products-service/products/ec5983de-c667-4ad3-8e0e-d42e653572b9
4752

4853

49-
### Create new prodcut using the API Gateway
54+
### Create new product using the API Gateway
5055
POST {{apigateway}}/products-service/products
5156

5257
{
@@ -61,5 +66,5 @@ Content-Type: application/json
6166

6267
{
6368
"CustomerId": "ec5983de-c667-4ad3-8e0e-d42e653572b9",
64-
"productId" : "ec5983de-c667-4ad3-8e0e-d42e653572b9"
69+
"productId" : "3be72f8e-0219-4ffc-b10d-2b29e8bd54b6"
6570
}

src/apps/application-docker-compose.yml

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,48 @@ services:
5050

5151
# External ports not enabled because of the apigateway
5252
#ports:
53-
5453
networks:
5554
- genocs
5655
# network_mode: bridge
5756
volumes:
5857
- product:/var/lib/data
5958

59+
order.webapi:
60+
image: genocs/order-webapi:1.0.0
61+
hostname: order_node_1
62+
container_name: order
63+
build:
64+
context: .
65+
dockerfile: order-webapi.dockerfile
66+
environment:
67+
- ASPNETCORE_ENVIRONMENT=Docker
68+
69+
# External ports not enabled because of the apigateway
70+
#ports:
71+
networks:
72+
- genocs
73+
# network_mode: bridge
74+
volumes:
75+
- order:/var/lib/data
76+
77+
signalr.webapi:
78+
image: genocs/signalr-webapi:1.0.0
79+
hostname: signalr_node_1
80+
container_name: signalr
81+
build:
82+
context: .
83+
dockerfile: signalr-webapi.dockerfile
84+
environment:
85+
- ASPNETCORE_ENVIRONMENT=Docker
86+
87+
# External ports not enabled because of the apigateway
88+
#ports:
89+
networks:
90+
- genocs
91+
# network_mode: bridge
92+
volumes:
93+
- signalr:/var/lib/data
94+
6095
networks:
6196
genocs:
6297
name: genocs-network
@@ -70,3 +105,7 @@ volumes:
70105
driver: local
71106
product:
72107
driver: local
108+
order:
109+
driver: local
110+
signalr:
111+
driver: local

src/apps/order-webapi.dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
2+
3+
4+
#FROM mcr.microsoft.com/dotnet/core/aspnet:3.0
5+
#FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim
6+
#FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim
7+
#FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine
8+
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
9+
WORKDIR /app
10+
EXPOSE 80
11+
EXPOSE 443
12+
13+
#FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build-env
14+
#FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build-env
15+
# FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build-env
16+
#FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build-env
17+
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build-env
18+
WORKDIR /src
19+
COPY ["orders/Genocs.Orders.WebApi", "Genocs.Orders.WebApi/"]
20+
21+
WORKDIR "/src/Genocs.Orders.WebApi"
22+
23+
RUN dotnet restore "Genocs.Orders.WebApi.csproj"
24+
25+
RUN dotnet build "Genocs.Orders.WebApi.csproj" -c Release -o /app/build
26+
27+
FROM build-env AS publish
28+
RUN dotnet publish "Genocs.Orders.WebApi.csproj" -c Release -o /app/publish
29+
30+
FROM base AS final
31+
WORKDIR /app
32+
COPY --from=publish /app/publish .
33+
ENTRYPOINT ["dotnet", "Genocs.Orders.WebApi.dll"]

src/apps/orders/Genocs.Orders.WebApi/Genocs.Orders.WebApi.csproj

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net7.0</TargetFrameworks>
4+
<TargetFramework>net7.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
7-
<PackageId>Genocs.Services.WebApi</PackageId>
8-
<LangVersion>10.0</LangVersion>
9-
<Authors>Nocco Giovanni Emanuele</Authors>
10-
<Company>Genocs</Company>
11-
<Title>----.</Title>
12-
<Description>----.</Description>
13-
<Copyright>Genocs 2023</Copyright>
14-
<EnableNETAnalyzers>True</EnableNETAnalyzers>
15-
<AnalysisLevel>latest</AnalysisLevel>
7+
<UserSecretsId>__genocs</UserSecretsId>
8+
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
9+
<DockerfileContext>..\..</DockerfileContext>
1610
</PropertyGroup>
1711

1812
<ItemGroup Condition="'$(Configuration)' == 'Debug'">
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"MongoDb": {
3+
"ConnectionString": "mongodb://mongodb"
4+
},
5+
"Monitoring": {
6+
"Jaeger": "jaeger"
7+
},
8+
"jaeger": {
9+
"udpHost": "jaeger"
10+
},
11+
"metrics": {
12+
"influxUrl": "http://influxdb:8086"
13+
},
14+
"mongo": {
15+
"connectionString": "mongodb://mongodb:27017"
16+
},
17+
"redis": {
18+
"connectionString": "redis"
19+
},
20+
"httpClient": {
21+
"services": {
22+
"products": "product"
23+
}
24+
}
25+
}

src/apps/orders/Genocs.Orders.WebApi/appsettings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
"virtualHost": "/",
9191
"port": 5672,
9292
"hostnames": [
93-
"localhost"
93+
"localhost", "rabbitmq"
9494
],
9595
"requestedConnectionTimeout": "00:00:30",
9696
"requestedHeartbeat": "00:01:00",
@@ -141,7 +141,7 @@
141141
"certificate": {
142142
"enabled": true,
143143
"header": "Certificate",
144-
"allowedHosts": ["localhost"]
144+
"allowedHosts": ["localhost", "order"]
145145
}
146146
},
147147
"vault": {

src/apps/products/Genocs.Products.WebApi/appsettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
"certificate": {
141141
"enabled": true,
142142
"header": "Certificate",
143-
"allowedHosts": [ "localhost" ]
143+
"allowedHosts": [ "localhost" ,"product"]
144144
}
145145
},
146146
"vault": {

src/apps/signalr-webapi.dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
2+
3+
4+
#FROM mcr.microsoft.com/dotnet/core/aspnet:3.0
5+
#FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim
6+
#FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim
7+
#FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine
8+
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
9+
WORKDIR /app
10+
EXPOSE 80
11+
EXPOSE 443
12+
13+
#FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build-env
14+
#FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build-env
15+
# FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build-env
16+
#FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build-env
17+
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build-env
18+
WORKDIR /src
19+
COPY ["signalr/Genocs.SignalR.WebApi", "Genocs.SignalR.WebApi/"]
20+
21+
WORKDIR "/src/Genocs.SignalR.WebApi"
22+
23+
RUN dotnet restore "Genocs.SignalR.WebApi.csproj"
24+
25+
RUN dotnet build "Genocs.SignalR.WebApi.csproj" -c Release -o /app/build
26+
27+
FROM build-env AS publish
28+
RUN dotnet publish "Genocs.SignalR.WebApi.csproj" -c Release -o /app/publish
29+
30+
FROM base AS final
31+
WORKDIR /app
32+
COPY --from=publish /app/publish .
33+
ENTRYPOINT ["dotnet", "Genocs.SignalR.WebApi.dll"]

0 commit comments

Comments
 (0)