chore: enhance configuration for gateway URL handling
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 3m43s
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 3m43s
- Added GW_URL and GwUrl environment variables in frontoffice-deployment.yaml and Dockerfile for consistent gateway URL configuration. - Updated AddGrpcServices method to resolve gateway URL from both environment variables, ensuring proper error handling for missing values. - Modified TokenNotificationService to prioritize GW_URL over GwUrl for improved configuration flexibility.
This commit is contained in:
@@ -28,6 +28,10 @@ spec:
|
|||||||
env:
|
env:
|
||||||
- name: ASPNETCORE_ENVIRONMENT
|
- name: ASPNETCORE_ENVIRONMENT
|
||||||
value: "Staging"
|
value: "Staging"
|
||||||
|
- name: GW_URL
|
||||||
|
value: "https://cms.se.kbs1.ir"
|
||||||
|
- name: GwUrl
|
||||||
|
value: "https://cms.se.kbs1.ir"
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
memory: "256Mi"
|
memory: "256Mi"
|
||||||
|
|||||||
@@ -100,7 +100,8 @@ public static class ConfigureServices
|
|||||||
|
|
||||||
public static IServiceCollection AddGrpcServices(this IServiceCollection services, IConfiguration configuration)
|
public static IServiceCollection AddGrpcServices(this IServiceCollection services, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
var baseUrl = configuration["GwUrl"];
|
var baseUrl = ResolveGatewayUrl(configuration)
|
||||||
|
?? throw new InvalidOperationException("Gateway URL is missing. Set GW_URL or GwUrl.");
|
||||||
|
|
||||||
// Register optimized HttpClient for gRPC
|
// Register optimized HttpClient for gRPC
|
||||||
services.AddScoped(sp =>
|
services.AddScoped(sp =>
|
||||||
@@ -152,6 +153,15 @@ public static class ConfigureServices
|
|||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string? ResolveGatewayUrl(IConfiguration configuration)
|
||||||
|
{
|
||||||
|
var envUrl = configuration["GW_URL"];
|
||||||
|
if (!string.IsNullOrWhiteSpace(envUrl))
|
||||||
|
return envUrl.TrimEnd('/');
|
||||||
|
|
||||||
|
return configuration["GwUrl"]?.TrimEnd('/');
|
||||||
|
}
|
||||||
|
|
||||||
private static TClient CreateAuthenticatedClient<TClient>(IServiceProvider sp)
|
private static TClient CreateAuthenticatedClient<TClient>(IServiceProvider sp)
|
||||||
where TClient : class
|
where TClient : class
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ WORKDIR /app
|
|||||||
COPY --from=build /app/publish .
|
COPY --from=build /app/publish .
|
||||||
|
|
||||||
ENV ASPNETCORE_URLS=http://+:80
|
ENV ASPNETCORE_URLS=http://+:80
|
||||||
|
ENV GW_URL=https://cms.se.kbs1.ir
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
ENTRYPOINT ["dotnet", "FrontOffice.Main.dll"]
|
ENTRYPOINT ["dotnet", "FrontOffice.Main.dll"]
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public class TokenNotificationService : IAsyncDisposable
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var gwUrl = _configuration["GwUrl"]?.TrimEnd('/') ?? "https://localhost:5002";
|
var gwUrl = (_configuration["GW_URL"] ?? _configuration["GwUrl"])?.TrimEnd('/') ?? "https://localhost:5002";
|
||||||
var hubPath = _configuration["SignalR:HubPath"] ?? "/hubs/token-relay";
|
var hubPath = _configuration["SignalR:HubPath"] ?? "/hubs/token-relay";
|
||||||
var hubUrl = $"{gwUrl}{hubPath}";
|
var hubUrl = $"{gwUrl}{hubPath}";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user