From 3a583f80e5a372ec7b6b98f41e5e51f4c335a14d Mon Sep 17 00:00:00 2001 From: "Kalana B. Thilakarathna" Date: Thu, 17 Sep 2026 12:28:31 +0530 Subject: [PATCH] gitea work flow update --- .gitea/workflows/ci-cd.yml | 102 ++++++++++++++++++ .../ERPCore/Properties/launchSettings.json | 4 +- Backend/ERPCore/appsettings.json | 5 +- Frontend/erp-system/.dockerignore | 18 ++++ Frontend/erp-system/.env.local.example | 2 +- Frontend/erp-system/Dockerfile | 32 ++++++ Frontend/erp-system/next.config.ts | 2 +- 7 files changed, 159 insertions(+), 6 deletions(-) create mode 100644 .gitea/workflows/ci-cd.yml create mode 100644 Frontend/erp-system/.dockerignore create mode 100644 Frontend/erp-system/Dockerfile diff --git a/.gitea/workflows/ci-cd.yml b/.gitea/workflows/ci-cd.yml new file mode 100644 index 0000000..fa33c72 --- /dev/null +++ b/.gitea/workflows/ci-cd.yml @@ -0,0 +1,102 @@ +name: CI/CD - ERP Core Monorepo + +on: + pull_request: + branches: + - Production + types: + - closed + +jobs: + backend-build-and-deploy: + name: Build & Deploy ERP Core Backend + runs-on: linux + if: github.event.pull_request.merged == true + steps: + - name: Checkout code + run: | + git clone \ + --depth 1 \ + --branch Production \ + https://oauth2:${{ secrets.ERPCORE }}@gitea.hexdive.com/New_REP_SYSTEM/ERP-core.git \ + . + + - name: Restore backend + run: dotnet restore Backend/ERPCore.sln + + - name: Publish backend + run: | + rm -rf /tmp/erpcore-deploy + mkdir -p /tmp/erpcore-deploy + dotnet publish Backend/ERPCore/ERPCore.csproj \ + -c Release \ + -r linux-x64 \ + --self-contained true \ + -o /tmp/erpcore-deploy + + - name: Stop backend service + run: systemctl stop erpcore.service + + - name: Copy backend to deploy folder + run: | + mkdir -p /home/erp/core/publish + rm -rf /home/erp/core/publish/* + cp -r /tmp/erpcore-deploy/* /home/erp/core/publish/ + + - name: Fix backend ownership and permissions + run: | + chown -R erpcore:erpcore /home/erp/core/publish + find /home/erp/core/publish -type d -exec chmod 755 {} + + find /home/erp/core/publish -type f -exec chmod 644 {} + + chmod +x /home/erp/core/publish/ERPCore + + - name: Restart backend service + run: systemctl restart erpcore.service + + - name: Verify backend + run: | + systemctl is-active erpcore.service && echo "Backend service running" || echo "Backend service failed" + + frontend-build-and-deploy: + name: Build & Deploy ERP Core Frontend + runs-on: linux + needs: backend-build-and-deploy + if: github.event.pull_request.merged == true + steps: + - name: Checkout code + run: | + git clone \ + --depth 1 \ + --branch Production \ + https://oauth2:${{ secrets.ERPCORE }}@gitea.hexdive.com/New_REP_SYSTEM/ERP-core.git \ + . + + - name: Build frontend Docker image + run: docker build -t erpcore-frontend:latest Frontend/erp-system + + - name: Stop & remove existing frontend container + run: | + docker stop erpcore-frontend 2>/dev/null || true + docker rm erpcore-frontend 2>/dev/null || true + + - name: Start frontend container + run: | + docker run -d \ + --name erpcore-frontend \ + -p 6702:6702 \ + --add-host=host.docker.internal:host-gateway \ + -e BACKEND_ORIGIN=http://host.docker.internal:6701 \ + --restart unless-stopped \ + --memory="512m" \ + --cpus="1.0" \ + --cap-drop ALL \ + --security-opt no-new-privileges \ + erpcore-frontend:latest + + - name: Remove old frontend images + run: docker image prune -f + + - name: Verify frontend + run: | + docker ps --filter name=erpcore-frontend --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" \ + | grep erpcore-frontend && echo "Frontend container running" || echo "Frontend container failed" diff --git a/Backend/ERPCore/Properties/launchSettings.json b/Backend/ERPCore/Properties/launchSettings.json index 05cca77..4afc2a9 100644 --- a/Backend/ERPCore/Properties/launchSettings.json +++ b/Backend/ERPCore/Properties/launchSettings.json @@ -6,7 +6,7 @@ "dotnetRunMessages": true, "launchBrowser": true, "launchUrl": "swagger", - "applicationUrl": "http://localhost:5224", + "applicationUrl": "http://localhost:6701", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } @@ -16,7 +16,7 @@ "dotnetRunMessages": true, "launchBrowser": true, "launchUrl": "swagger", - "applicationUrl": "https://localhost:7112;http://localhost:5224", + "applicationUrl": "https://localhost:7112;http://localhost:6701", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/Backend/ERPCore/appsettings.json b/Backend/ERPCore/appsettings.json index ed05dc3..10ea3d1 100644 --- a/Backend/ERPCore/appsettings.json +++ b/Backend/ERPCore/appsettings.json @@ -6,8 +6,9 @@ } }, "ConnectionStrings": { - "DefaultConnection": "Host=localhost;Port=5432;Database=ERPCore;Username=root;Password=root" + "DefaultConnection": "Host=localhost;Port=5432;Database=ERPCoreTest;Username=postgres;Password=post@hexdive" }, + "Urls": "http://0.0.0.0:6701", "Auth": { "Issuer": "AuthHex", "Audience": "AuthHexClient", @@ -16,7 +17,7 @@ "RequiredRoleCode": "" }, "AuthHex": { - "BaseUrl": "http://localhost:5602" + "BaseUrl": "http://localhost:6703" }, "FileStorage": { "RootPath": "App_Data/hr-documents", diff --git a/Frontend/erp-system/.dockerignore b/Frontend/erp-system/.dockerignore new file mode 100644 index 0000000..de22555 --- /dev/null +++ b/Frontend/erp-system/.dockerignore @@ -0,0 +1,18 @@ +node_modules +.next +out +build +coverage +.vercel + +.env +.env.* +!.env.local.example + +npm-debug.log* +yarn-debug.log* +yarn-error.log* +.pnpm-debug.log* + +Dockerfile +.dockerignore diff --git a/Frontend/erp-system/.env.local.example b/Frontend/erp-system/.env.local.example index 7c31eb9..288d0ab 100644 --- a/Frontend/erp-system/.env.local.example +++ b/Frontend/erp-system/.env.local.example @@ -4,4 +4,4 @@ # # Use the backend's HTTP port: its HTTPS port serves a self-signed dev cert that the # proxy will refuse. -BACKEND_ORIGIN=http://localhost:5224 +BACKEND_ORIGIN=http://localhost:6701 diff --git a/Frontend/erp-system/Dockerfile b/Frontend/erp-system/Dockerfile new file mode 100644 index 0000000..af767eb --- /dev/null +++ b/Frontend/erp-system/Dockerfile @@ -0,0 +1,32 @@ +FROM node:22-alpine AS deps +WORKDIR /app + +COPY package.json package-lock.json ./ +RUN npm ci + +FROM node:22-alpine AS builder +WORKDIR /app + +ENV NEXT_TELEMETRY_DISABLED=1 + +COPY --from=deps /app/node_modules ./node_modules +COPY . . +RUN npm run build + +FROM node:22-alpine AS runner +WORKDIR /app + +ENV NODE_ENV=production +ENV NEXT_TELEMETRY_DISABLED=1 +ENV PORT=6702 + +COPY package.json package-lock.json ./ +RUN npm ci --omit=dev && npm cache clean --force + +COPY --from=builder /app/.next ./.next +COPY --from=builder /app/public ./public +COPY --from=builder /app/next.config.ts ./next.config.ts + +EXPOSE 6702 + +CMD ["npm", "run", "start"] diff --git a/Frontend/erp-system/next.config.ts b/Frontend/erp-system/next.config.ts index 3bdd152..5df0395 100644 --- a/Frontend/erp-system/next.config.ts +++ b/Frontend/erp-system/next.config.ts @@ -8,7 +8,7 @@ import path from "path" // // Defaults to the backend's HTTP port: the HTTPS port uses a self-signed dev cert that // this proxy would reject. -const BACKEND_ORIGIN = process.env.BACKEND_ORIGIN ?? "http://localhost:5224" +const BACKEND_ORIGIN = process.env.BACKEND_ORIGIN ?? "http://localhost:6701" const nextConfig: NextConfig = { turbopack: {