From eef13d147102a3515fd620739d621d1455707638 Mon Sep 17 00:00:00 2001 From: masoodafar-web Date: Thu, 14 May 2026 01:35:18 +0330 Subject: [PATCH 1/2] fix: remove hardcoded GW_URL from Dockerfile and staging manifest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GW_URL/GwUrl env vars were baked into the Dockerfile (ENV) and the staging K8s manifest, overriding appsettings.*.json at runtime. This meant merging to production still used the staging CMS URL. Now only ASPNETCORE_ENVIRONMENT is set in the manifest; the correct GwUrl is read from appsettings.Staging.json or appsettings.Production.json depending on the environment — as intended. Co-authored-by: Cursor --- k8s/staging/frontoffice-deployment.yaml | 4 ---- src/FrontOffice.Main/Dockerfile | 1 - 2 files changed, 5 deletions(-) diff --git a/k8s/staging/frontoffice-deployment.yaml b/k8s/staging/frontoffice-deployment.yaml index 88b5cf3..989e9a2 100644 --- a/k8s/staging/frontoffice-deployment.yaml +++ b/k8s/staging/frontoffice-deployment.yaml @@ -28,10 +28,6 @@ spec: env: - name: ASPNETCORE_ENVIRONMENT value: "Staging" - - name: GW_URL - value: "https://cms.se.kbs1.ir" - - name: GwUrl - value: "https://cms.se.kbs1.ir" resources: requests: memory: "256Mi" diff --git a/src/FrontOffice.Main/Dockerfile b/src/FrontOffice.Main/Dockerfile index 7773778..b7a1691 100644 --- a/src/FrontOffice.Main/Dockerfile +++ b/src/FrontOffice.Main/Dockerfile @@ -25,7 +25,6 @@ COPY ["FrontOffice.Main/staging-ca.crt", "/usr/local/share/ca-certificates/stagi RUN update-ca-certificates ENV ASPNETCORE_URLS=http://+:80 -ENV GW_URL=https://cms.se.kbs1.ir EXPOSE 80 ENTRYPOINT ["dotnet", "FrontOffice.Main.dll"] From 0b1cc1c1c8ba87522912e28fb79e93fbdad1ec37 Mon Sep 17 00:00:00 2001 From: masoodafar-web Date: Thu, 14 May 2026 01:44:13 +0330 Subject: [PATCH 2/2] fix: add kubectl apply to CI workflows and add production K8s manifest Both kub-deploy and prod-deploy were only running kubectl rollout restart, meaning changes to the deployment manifest (env vars, resources, image tag) were never applied to the cluster. - Add scp + kubectl apply before rollout restart in kub-deploy.yml (staging) - Add scp + kubectl apply before rollout restart in prod-deploy.yml (production) - Add k8s/production/frontoffice-deployment.yaml with ASPNETCORE_ENVIRONMENT=Production and image tag :prod Co-authored-by: Cursor --- .gitea/workflows/kub-deploy.yml | 11 ++++- .gitea/workflows/prod-deploy.yml | 11 ++++- k8s/production/frontoffice-deployment.yaml | 56 ++++++++++++++++++++++ 3 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 k8s/production/frontoffice-deployment.yaml diff --git a/.gitea/workflows/kub-deploy.yml b/.gitea/workflows/kub-deploy.yml index 606a25a..4f58900 100644 --- a/.gitea/workflows/kub-deploy.yml +++ b/.gitea/workflows/kub-deploy.yml @@ -67,8 +67,15 @@ jobs: - name: Deploy to Kubernetes run: | export SSHPASS="${{ secrets.SERVER_PASSWORD }}" + + # Copy K8s manifests to server + sshpass -e scp -o StrictHostKeyChecking=no k8s/staging/frontoffice-deployment.yaml root@${{ env.K8S_SERVER }}:/tmp/frontoffice-deployment.yaml + + # Apply manifests and restart sshpass -e ssh -o StrictHostKeyChecking=no root@${{ env.K8S_SERVER }} " - kubectl rollout restart deployment/frontoffice - kubectl rollout status deployment/frontoffice --timeout=180s + kubectl apply -f /tmp/frontoffice-deployment.yaml && + kubectl rollout restart deployment/frontoffice && + kubectl rollout status deployment/frontoffice --timeout=180s && + rm -f /tmp/frontoffice-deployment.yaml " echo "✅ Deployed!" diff --git a/.gitea/workflows/prod-deploy.yml b/.gitea/workflows/prod-deploy.yml index 5e7ada2..cdfe89b 100644 --- a/.gitea/workflows/prod-deploy.yml +++ b/.gitea/workflows/prod-deploy.yml @@ -68,8 +68,15 @@ jobs: - name: Deploy to Production run: | export SSHPASS="${{ secrets.SERVER_PASSWORD }}" + + # Copy K8s manifests to server + sshpass -e scp -o StrictHostKeyChecking=no k8s/production/frontoffice-deployment.yaml root@${{ env.K8S_SERVER }}:/tmp/frontoffice-deployment.yaml + + # Apply manifests and restart sshpass -e ssh -o StrictHostKeyChecking=no root@${{ env.K8S_SERVER }} " - kubectl rollout restart deployment/frontoffice - kubectl rollout status deployment/frontoffice --timeout=300s + kubectl apply -f /tmp/frontoffice-deployment.yaml && + kubectl rollout restart deployment/frontoffice && + kubectl rollout status deployment/frontoffice --timeout=300s && + rm -f /tmp/frontoffice-deployment.yaml " echo "✅ Deployed to Production!" diff --git a/k8s/production/frontoffice-deployment.yaml b/k8s/production/frontoffice-deployment.yaml new file mode 100644 index 0000000..15111ac --- /dev/null +++ b/k8s/production/frontoffice-deployment.yaml @@ -0,0 +1,56 @@ +--- +# FrontOffice (Blazor Server) production. +apiVersion: apps/v1 +kind: Deployment +metadata: + name: frontoffice + namespace: default + labels: + app: frontoffice + environment: production +spec: + replicas: 1 + selector: + matchLabels: + app: frontoffice + template: + metadata: + labels: + app: frontoffice + spec: + containers: + - name: frontoffice + image: 194.5.195.53:30080/admin/frontoffice:prod + imagePullPolicy: Always + ports: + - containerPort: 80 + name: http + env: + - name: ASPNETCORE_ENVIRONMENT + value: "Production" + resources: + requests: + memory: "256Mi" + cpu: "250m" + limits: + memory: "512Mi" + cpu: "500m" + imagePullSecrets: + - name: gitea-registry-secret + +--- +apiVersion: v1 +kind: Service +metadata: + name: frontoffice-svc + namespace: default + labels: + app: frontoffice +spec: + selector: + app: frontoffice + ports: + - port: 80 + targetPort: 80 + name: http + type: ClusterIP