Compare commits

..

1 Commits

Author SHA1 Message Date
masoodafar-web 99c0da4ecc feat: add production configuration for JWT and gRPC settings
Build and Deploy to Production / build-and-deploy (push) Successful in 2m31s
2025-12-27 07:42:45 +03:30
26 changed files with 120 additions and 123 deletions
+52 -50
View File
@@ -6,84 +6,86 @@ on:
- kub-stage
env:
REGISTRY: 194.5.195.53:30080
REGISTRY: gitea-svc:3000
IMAGE_NAME: admin/frontoffice-bff
K8S_SERVER: 194.5.195.53
jobs:
build-and-deploy:
runs-on: ubuntu-latest
container:
image: 194.5.195.53:32082/docker-sshpass:latest
image: docker:latest
options: --privileged
env:
HTTP_PROXY: http://proxyuser:87zH26nbqT2@46.249.98.211:3128
HTTPS_PROXY: http://proxyuser:87zH26nbqT2@46.249.98.211:3128
NO_PROXY: localhost,127.0.0.1,gitea-svc,194.5.195.53,10.0.0.0/8
steps:
- name: Start Docker daemon
- name: Install dependencies
run: |
apk add --no-cache git curl
# Install kubectl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
mv kubectl /usr/local/bin/
- name: Start Docker daemon with insecure registry
run: |
mkdir -p /etc/docker
cat > /etc/docker/daemon.json << 'DAEMON'
{
"insecure-registries": ["194.5.195.53:30080", "194.5.195.53:32500", "194.5.195.53:32082"]
"insecure-registries": ["git.foursat.afrino.co", "gitea-svc:3000"]
}
DAEMON
echo "🚀 Starting Docker daemon..."
mkdir -p ~/.docker
cat > ~/.docker/config.json << 'CONF'
{
"proxies": {
"default": {
"httpProxy": "http://proxyuser:87zH26nbqT2@46.249.98.211:3128",
"httpsProxy": "http://proxyuser:87zH26nbqT2@46.249.98.211:3128",
"noProxy": "localhost,127.0.0.1,gitea-svc,194.5.195.53,10.0.0.0/8"
}
}
}
CONF
dockerd &
# Wait up to 3 minutes for Docker to be ready
for i in $(seq 1 90); do
if docker info >/dev/null 2>&1; then
echo "✅ Docker daemon is ready (attempt $i)"
docker version
break
else
echo "⏳ Waiting for Docker daemon... (attempt $i/90)"
sleep 2
fi
for i in $(seq 1 30); do
docker info >/dev/null 2>&1 && break || sleep 2
done
# Final check
if ! docker info >/dev/null 2>&1; then
echo "❌ Docker daemon failed to start after 3 minutes"
exit 1
fi
docker info
- name: Checkout code
run: |
git clone --depth 1 --branch kub-stage http://gitea-svc:3000/admin/FrontOffice.BFF.git .
- name: Publish Protobuf packages
run: |
echo "📦 Publishing Protobuf packages..."
docker run --rm -v $(pwd):/src -w /src \
194.5.195.53:32082/dotnet/sdk:9.0 sh -c '
for proj in $(find . -name "*Protobuf*.csproj" -type f); do
echo "📦 $proj"
dotnet restore "$proj"
dotnet build "$proj" -c Release --no-restore
dotnet pack "$proj" -c Release --no-build -o "$(dirname $proj)/nupkg"
for nupkg in $(dirname $proj)/nupkg/*.nupkg; do
[ -f "$nupkg" ] && dotnet nuget push "$nupkg" \
--source "http://194.5.195.53:32081/repository/foursat-nuget-hosted/index.json" \
--api-key "admin:87zH26nbqT" \
--skip-duplicate --allow-insecure-connections || true
done
done
'
echo "✅ Protobuf packages done!"
git log -1 --format="%H %s"
- name: Build Docker Image
run: |
docker build -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest -f src/FrontOffice.BFF.WebApi/Dockerfile .
cd src
docker build -f FrontOffice.BFF.WebApi/Dockerfile \
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} \
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \
--build-arg HTTP_PROXY=http://proxyuser:87zH26nbqT2@46.249.98.211:3128 \
--build-arg HTTPS_PROXY=http://proxyuser:87zH26nbqT2@46.249.98.211:3128 \
.
- name: Push to Registry
run: |
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login ${{ env.REGISTRY }} -u admin --password-stdin
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
- name: Deploy to Kubernetes
run: |
export SSHPASS="${{ secrets.SERVER_PASSWORD }}"
sshpass -e ssh -o StrictHostKeyChecking=no root@${{ env.K8S_SERVER }} "
kubectl rollout restart deployment/frontoffice-bff
kubectl rollout status deployment/frontoffice-bff --timeout=180s
"
echo "Deployed!"
# Setup kubeconfig
mkdir -p ~/.kube
echo "${{ secrets.KUBECONFIG }}" | base64 -d > ~/.kube/config
# Restart deployment to pull new image
kubectl rollout restart deployment/frontoffice-bff || echo "Deployment doesn't exist yet"
# Wait for rollout to complete
kubectl rollout status deployment/frontoffice-bff --timeout=5m || echo "Deployment rollout pending"
+3 -5
View File
@@ -7,7 +7,7 @@ on:
env:
REGISTRY: gitea-svc:3000
EXTERNAL_REGISTRY: 194.5.195.53:30080
EXTERNAL_REGISTRY: git.foursat.afrino.co
IMAGE_NAME: admin/frontoffice-bff
jobs:
@@ -24,9 +24,7 @@ jobs:
- name: Install dependencies
run: |
apk add --no-cache git curl
# Install kubectl with fixed version
KUBECTL_VERSION="v1.31.0"
curl -LO "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl"
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
mv kubectl /usr/local/bin/
@@ -35,7 +33,7 @@ jobs:
mkdir -p /etc/docker
cat > /etc/docker/daemon.json << 'DAEMON'
{
"insecure-registries": ["194.5.195.53:30080", "194.5.195.53:32082", "gitea-svc:3000"]
"insecure-registries": ["git.foursat.afrino.co", "gitea-svc:3000"]
}
DAEMON
mkdir -p ~/.docker
@@ -35,23 +35,17 @@ public class GetMyWeeklyBalancesQueryHandler : IRequestHandler<GetMyWeeklyBalanc
var response = await _context.Commission.GetUserWeeklyBalancesAsync(cmsRequest, cancellationToken: cancellationToken);
// Map list of UserWeeklyBalanceModel to DTO
// Note: CMS proto uses LeftLegTotal/RightLegTotal (sum of NewMembers + Carryover)
var balances = response.Models.Select(b => new WeeklyBalanceItemDto
{
Id = b.Id,
WeekDefinitionId = b.WeekDefinitionId,
WeekLabel = b.WeekDisplayName,
LeftLegBalances = b.LeftLegTotal, // Changed from LeftLegBalances
RightLegBalances = b.RightLegTotal, // Changed from RightLegBalances
LeftLegBalances = b.LeftLegBalances,
RightLegBalances = b.RightLegBalances,
TotalBalances = b.TotalBalances,
WeeklyPoolContribution = b.WeeklyPoolContribution,
CalculatedAt = b.CalculatedAt?.ToDateTime(),
IsExpired = b.IsExpired,
// New fields for carryover info
LeftLegCarryover = b.LeftLegCarryover,
RightLegCarryover = b.RightLegCarryover,
LeftLegNewMembers = b.LeftLegNewMembers,
RightLegNewMembers = b.RightLegNewMembers
IsExpired = b.IsExpired
}).ToList();
// Calculate summary
@@ -89,24 +89,4 @@ public class WeeklyBalanceItemDto
/// تاریخ شمسی
/// </summary>
public string DatePersian { get; set; } = string.Empty;
/// <summary>
/// انتقالی پای چپ از هفته قبل
/// </summary>
public int LeftLegCarryover { get; set; }
/// <summary>
/// انتقالی پای راست از هفته قبل
/// </summary>
public int RightLegCarryover { get; set; }
/// <summary>
/// اعضای جدید پای چپ این هفته
/// </summary>
public int LeftLegNewMembers { get; set; }
/// <summary>
/// اعضای جدید پای راست این هفته
/// </summary>
public int RightLegNewMembers { get; set; }
}
@@ -7,7 +7,7 @@
<ItemGroup>
<PackageReference Include="Afrino.PYMSMicroservice.Protobuf" Version="0.0.11" />
<PackageReference Include="Foursat.CMSMicroservice.Protobuf" Version="0.0.162" />
<PackageReference Include="Foursat.CMSMicroservice.Protobuf" Version="0.0.159" />
<PackageReference Include="Google.Protobuf" Version="3.33.0" />
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.54.0" />
<PackageReference Include="Grpc.Tools" Version="2.76.0">
@@ -22,7 +22,7 @@ public class CommissionProfile : IRegister
{
PageNumber = src.PageNumber,
PageSize = src.PageSize,
WeekDefinitionId = src.WeekDefinitionId != null ? src.WeekDefinitionId.Value : null,
WeekDefinitionId = src.WeekDefinitionId,
OnlyActive = src.OnlyActive
});
@@ -55,10 +55,6 @@ public class CommissionProfile : IRegister
.Map(dest => dest.WeekDisplayName, src => src.WeekLabel)
.Map(dest => dest.LeftLegBalances, src => src.LeftLegBalances)
.Map(dest => dest.RightLegBalances, src => src.RightLegBalances)
.Map(dest => dest.LeftLegCarryover, src => src.LeftLegCarryover)
.Map(dest => dest.RightLegCarryover, src => src.RightLegCarryover)
.Map(dest => dest.LeftLegNewMembers, src => src.LeftLegNewMembers)
.Map(dest => dest.RightLegNewMembers, src => src.RightLegNewMembers)
.Map(dest => dest.TotalBalances, src => src.TotalBalances)
.Map(dest => dest.WeeklyPoolContribution, src => src.WeeklyPoolContribution)
.Map(dest => dest.IsExpired, src => src.IsExpired)
+3 -3
View File
@@ -1,10 +1,10 @@
FROM 194.5.195.53:32082/dotnet/aspnet:9.0 AS base
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
USER $APP_UID
WORKDATA /app
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
FROM 194.5.195.53:32082/dotnet/sdk:9.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["FrontOffice.BFF.WebApi/NuGet.config", "NuGet.config"]
+10 -6
View File
@@ -1,14 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<!-- Nexus (hosts FourSat packages + proxies nuget.org) -->
<add key="Nexus" value="http://194.5.195.53:32081/repository/nuget-all/index.json" allowInsecureConnections="true" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="FourSat" value="https://git.afrino.co/api/packages/FourSat/nuget/index.json" />
<add key="Afrino" value="https://git.afrino.co/api/packages/Afrino/nuget/index.json" />
</packageSources>
<packageSourceCredentials>
<Nexus>
<add key="Username" value="admin" />
<FourSat>
<add key="Username" value="masoud" />
<add key="ClearTextPassword" value="87zH26nbqT" />
</Nexus>
</FourSat>
<Afrino>
<add key="Username" value="systemuser" />
<add key="ClearTextPassword" value="sZSA7PTiv3pUSQZ" />
</Afrino>
</packageSourceCredentials>
</configuration>
@@ -0,0 +1,27 @@
{
"JwtSecurityKey": "TvlZVx5TJaHs8e9HgUdGzhGP2CIidoI444nAj+8+g7c=",
"JwtIssuer": "https://localhost",
"JwtAudience": "https://localhost",
"JwtExpiryInDays": 365,
"AllowedHosts": "*",
"Kestrel": {
"EndpointDefaults": {
"Protocols": "Http2"
}
},
"GrpcChannelOptions": {
"CMSMSAddress": "http://cms-svc",
"PYMSMSAddress": "https://ipg.afrino.co"
},
"CmsSignalR": {
"HubPath": "/hubs/token-notification"
},
"Authentication": {
"Authority": "https://ids.domain.com/",
"Audience": "domain_api"
},
"Seq": {
"ServerUrl": "http://seq-svc:5341",
"ApiKey": ""
}
}
+1 -1
View File
@@ -10,7 +10,7 @@
}
},
"GrpcChannelOptions": {
"CMSMSAddress": "https://cms.se.kbs1.ir",
"CMSMSAddress": "https://cms.foursat.afrino.co",
"PYMSMSAddress": "https://ipg.afrino.co"
},
"CmsSignalR": {
@@ -27,7 +27,7 @@
<PropertyGroup>
<NugetPackagePath>$(PackageOutputPath)$(PackageId).$(Version).nupkg</NugetPackagePath>
<PushCommand>
dotnet nuget push **/*.nupkg --source http://194.5.195.53:32081/repository/foursat-nuget-hosted/index.json --api-key admin:87zH26nbqT --skip-duplicate
dotnet nuget push **/*.nupkg --source https://git.afrino.co/api/packages/FourSat/nuget/index.json --api-key 061a5cb15517c6da39c16cfce8556c55ae104d0d --skip-duplicate
</PushCommand>
</PropertyGroup>
@@ -27,7 +27,7 @@
<PropertyGroup>
<NugetPackagePath>$(PackageOutputPath)$(PackageId).$(Version).nupkg</NugetPackagePath>
<PushCommand>
dotnet nuget push **/*.nupkg --source http://194.5.195.53:32081/repository/foursat-nuget-hosted/index.json --api-key admin:87zH26nbqT --skip-duplicate
dotnet nuget push **/*.nupkg --source https://git.afrino.co/api/packages/FourSat/nuget/index.json --api-key 061a5cb15517c6da39c16cfce8556c55ae104d0d --skip-duplicate
</PushCommand>
</PropertyGroup>
<Exec Command="$(PushCommand)" />
@@ -26,7 +26,7 @@
<PropertyGroup>
<NugetPackagePath>$(PackageOutputPath)$(PackageId).$(Version).nupkg</NugetPackagePath>
<PushCommand>
dotnet nuget push **/*.nupkg --source http://194.5.195.53:32081/repository/foursat-nuget-hosted/index.json --api-key admin:87zH26nbqT --skip-duplicate
dotnet nuget push **/*.nupkg --source https://git.afrino.co/api/packages/FourSat/nuget/index.json --api-key 061a5cb15517c6da39c16cfce8556c55ae104d0d --skip-duplicate
</PushCommand>
</PropertyGroup>
@@ -3,7 +3,7 @@
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.0.6</Version>
<Version>0.0.4</Version>
<PackageId>Foursat.FrontOffice.BFF.Commission.Protobuf</PackageId>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<DebugSymbols>False</DebugSymbols>
@@ -26,7 +26,7 @@
<PropertyGroup>
<NugetPackagePath>$(PackageOutputPath)$(PackageId).$(Version).nupkg</NugetPackagePath>
<PushCommand>
dotnet nuget push **/*.nupkg --source http://194.5.195.53:32081/repository/foursat-nuget-hosted/index.json --api-key admin:87zH26nbqT --skip-duplicate
dotnet nuget push **/*.nupkg --source https://git.afrino.co/api/packages/FourSat/nuget/index.json --api-key 061a5cb15517c6da39c16cfce8556c55ae104d0d --skip-duplicate
</PushCommand>
</PropertyGroup>
@@ -91,17 +91,13 @@ message WeeklyBalanceModel
int64 id = 1;
int64 week_definition_id = 2;
string week_display_name = 3;
int32 left_leg_balances = 4; // مجموع پای چپ (NewMembers + Carryover)
int32 right_leg_balances = 5; // مجموع پای راست (NewMembers + Carryover)
int32 total_balances = 6; // تعداد تعادل = MIN(چپ, راست)
int32 left_leg_balances = 4;
int32 right_leg_balances = 5;
int32 total_balances = 6;
int64 weekly_pool_contribution = 7;
bool is_expired = 8;
google.protobuf.Timestamp calculated_at = 9;
string date_persian = 10;
int32 left_leg_carryover = 11; // انتقالی پای چپ از هفته قبل
int32 right_leg_carryover = 12; // انتقالی پای راست از هفته قبل
int32 left_leg_new_members = 13; // اعضای جدید پای چپ این هفته
int32 right_leg_new_members = 14; // اعضای جدید پای راست این هفته
}
// ============ GetWeekDefinitions ============
@@ -30,7 +30,7 @@
<PropertyGroup>
<NugetPackagePath>$(PackageOutputPath)$(PackageId).$(Version).nupkg</NugetPackagePath>
<PushCommand>
dotnet nuget push **/*.nupkg --source http://194.5.195.53:32081/repository/foursat-nuget-hosted/index.json --api-key admin:87zH26nbqT --skip-duplicate
dotnet nuget push **/*.nupkg --source https://git.afrino.co/api/packages/FourSat/nuget/index.json --api-key 061a5cb15517c6da39c16cfce8556c55ae104d0d --skip-duplicate
</PushCommand>
</PropertyGroup>
@@ -26,7 +26,7 @@
<PropertyGroup>
<NugetPackagePath>$(PackageOutputPath)$(PackageId).$(Version).nupkg</NugetPackagePath>
<PushCommand>
dotnet nuget push **/*.nupkg --source http://194.5.195.53:32081/repository/foursat-nuget-hosted/index.json --api-key admin:87zH26nbqT --skip-duplicate
dotnet nuget push **/*.nupkg --source https://git.afrino.co/api/packages/FourSat/nuget/index.json --api-key 061a5cb15517c6da39c16cfce8556c55ae104d0d --skip-duplicate
</PushCommand>
</PropertyGroup>
@@ -26,7 +26,7 @@
<PropertyGroup>
<NugetPackagePath>$(PackageOutputPath)$(PackageId).$(Version).nupkg</NugetPackagePath>
<PushCommand>
dotnet nuget push **/*.nupkg --source http://194.5.195.53:32081/repository/foursat-nuget-hosted/index.json --api-key admin:87zH26nbqT --skip-duplicate
dotnet nuget push **/*.nupkg --source https://git.afrino.co/api/packages/FourSat/nuget/index.json --api-key 061a5cb15517c6da39c16cfce8556c55ae104d0d --skip-duplicate
</PushCommand>
</PropertyGroup>
@@ -30,7 +30,7 @@
<PropertyGroup>
<NugetPackagePath>$(PackageOutputPath)$(PackageId).$(Version).nupkg</NugetPackagePath>
<PushCommand>
dotnet nuget push **/*.nupkg --source http://194.5.195.53:32081/repository/foursat-nuget-hosted/index.json --api-key admin:87zH26nbqT --skip-duplicate
dotnet nuget push **/*.nupkg --source https://git.afrino.co/api/packages/FourSat/nuget/index.json --api-key 061a5cb15517c6da39c16cfce8556c55ae104d0d --skip-duplicate
</PushCommand>
</PropertyGroup>
@@ -27,7 +27,7 @@
<PropertyGroup>
<NugetPackagePath>$(PackageOutputPath)$(PackageId).$(Version).nupkg</NugetPackagePath>
<PushCommand>
dotnet nuget push **/*.nupkg --source http://194.5.195.53:32081/repository/foursat-nuget-hosted/index.json --api-key admin:87zH26nbqT --skip-duplicate
dotnet nuget push **/*.nupkg --source https://git.afrino.co/api/packages/FourSat/nuget/index.json --api-key 061a5cb15517c6da39c16cfce8556c55ae104d0d --skip-duplicate
</PushCommand>
</PropertyGroup>
@@ -27,7 +27,7 @@
<PropertyGroup>
<NugetPackagePath>$(PackageOutputPath)$(PackageId).$(Version).nupkg</NugetPackagePath>
<PushCommand>
dotnet nuget push **/*.nupkg --source http://194.5.195.53:32081/repository/foursat-nuget-hosted/index.json --api-key admin:87zH26nbqT --skip-duplicate
dotnet nuget push **/*.nupkg --source https://git.afrino.co/api/packages/FourSat/nuget/index.json --api-key 061a5cb15517c6da39c16cfce8556c55ae104d0d --skip-duplicate
</PushCommand>
</PropertyGroup>
@@ -30,7 +30,7 @@
<PropertyGroup>
<NugetPackagePath>$(PackageOutputPath)$(PackageId).$(Version).nupkg</NugetPackagePath>
<PushCommand>
dotnet nuget push **/*.nupkg --source http://194.5.195.53:32081/repository/foursat-nuget-hosted/index.json --api-key admin:87zH26nbqT --skip-duplicate
dotnet nuget push **/*.nupkg --source https://git.afrino.co/api/packages/FourSat/nuget/index.json --api-key 061a5cb15517c6da39c16cfce8556c55ae104d0d --skip-duplicate
</PushCommand>
</PropertyGroup>
@@ -30,7 +30,7 @@
<PropertyGroup>
<NugetPackagePath>$(PackageOutputPath)$(PackageId).$(Version).nupkg</NugetPackagePath>
<PushCommand>
dotnet nuget push **/*.nupkg --source http://194.5.195.53:32081/repository/foursat-nuget-hosted/index.json --api-key admin:87zH26nbqT --skip-duplicate
dotnet nuget push **/*.nupkg --source https://git.afrino.co/api/packages/FourSat/nuget/index.json --api-key 061a5cb15517c6da39c16cfce8556c55ae104d0d --skip-duplicate
</PushCommand>
</PropertyGroup>
@@ -30,7 +30,7 @@
<PropertyGroup>
<NugetPackagePath>$(PackageOutputPath)$(PackageId).$(Version).nupkg</NugetPackagePath>
<PushCommand>
dotnet nuget push **/*.nupkg --source http://194.5.195.53:32081/repository/foursat-nuget-hosted/index.json --api-key admin:87zH26nbqT --skip-duplicate
dotnet nuget push **/*.nupkg --source https://git.afrino.co/api/packages/FourSat/nuget/index.json --api-key 061a5cb15517c6da39c16cfce8556c55ae104d0d --skip-duplicate
</PushCommand>
</PropertyGroup>
@@ -30,7 +30,7 @@
<PropertyGroup>
<NugetPackagePath>$(PackageOutputPath)$(PackageId).$(Version).nupkg</NugetPackagePath>
<PushCommand>
dotnet nuget push **/*.nupkg --source http://194.5.195.53:32081/repository/foursat-nuget-hosted/index.json --api-key admin:87zH26nbqT --skip-duplicate
dotnet nuget push **/*.nupkg --source https://git.afrino.co/api/packages/FourSat/nuget/index.json --api-key 061a5cb15517c6da39c16cfce8556c55ae104d0d --skip-duplicate
</PushCommand>
</PropertyGroup>
@@ -27,7 +27,7 @@
<PropertyGroup>
<NugetPackagePath>$(PackageOutputPath)$(PackageId).$(Version).nupkg</NugetPackagePath>
<PushCommand>
dotnet nuget push **/*.nupkg --source http://194.5.195.53:32081/repository/foursat-nuget-hosted/index.json --api-key admin:87zH26nbqT --skip-duplicate
dotnet nuget push **/*.nupkg --source https://git.afrino.co/api/packages/FourSat/nuget/index.json --api-key 061a5cb15517c6da39c16cfce8556c55ae104d0d --skip-duplicate
</PushCommand>
</PropertyGroup>