nexi-intra / nexi-meeting

0 stars 0 forks source link

title: Template for a Magic App description: This architecture ensures that frontend developers focus solely on building the user interface and client-side logic, without direct access to production data. Backend developers manage data processing and API creation, maintaining strict access controls through the MagicPot. The use of GitHub Actions for continuous integration and deployment automates the process of building and publishing Docker images, while the PowerShell script facilitates seamless deployment to Kubernetes.

Architecture Overview

The architecture of the KOKSMAT framework ensures a clear separation between frontend and backend developers, with specific roles and access levels.

Frontend (Next.js Application)

Backend (Go Application)

Getting Started with a New Project

To start a new project using the KOKSMAT framework, follow these steps:

  1. Decide on a Project Name: Choose a subject matter for the project, formatted as two words separated by a dash (e.g., intranet-tools).

  2. Create a New Repository:

    • Use the master template repository: nexi-meeting
    • Name the new repository according to the project subject (e.g., intranet-tools).
  3. Set Up the Repository:

    • Clone the new repository to your local machine or open it in GitHub Codespaces.
    • Rename the project folder to match the subject (e.g., tools).
  4. Update Configuration:

    • Open .koksmat/web/app/global.ts.
    • Update the APPNAME variable to match your project name (e.g., tools).
    • Change the clientId and authority values to match your Azure tenant configuration:
      export const APPNAME = "tools";
      export const CLARITY = "your-clarity-key";
      export const MSAL = {
      clientId: "your-client-id",
      authority: "https://login.microsoftonline.com/your-tenant-id",
      redirectUri: "/",
      postLogoutRedirectUri: "/",
      };
  5. Change name

Continuous Integration and Deployment with GitHub Actions

The KOKSMAT framework leverages GitHub Actions for continuous integration and deployment, specifically for publishing Docker images and deploying them to Kubernetes. This process is triggered whenever a new release is made.

GitHub Actions for Publishing Docker Images

  1. Configuration File:

    • The release tag and image name are controlled by the .koksmat/koksmat.json file:
      {
      "version": {
       "minor": 0,
       "build": 5,
       "patch": 5,
       "major": 0
      },
      "appname": "magic-people",
      "dnsprod": "people.intra.nexigroup.com",
      "dnstest": "people-test.intra.nexigroup.com",
      "imagename": "ghcr.io/magicbutton/magic-people",
      "port": 4444
      }
  2. GitHub Actions Workflow:

    • The workflow is triggered on creating a new release, building the Docker image, and pushing it to the GitHub Container Registry:

      name: Build and Publish Docker Image
      
      on:
      release:
       types: [published]
      
      jobs:
      build:
       runs-on: ubuntu-latest
      
       steps:
         - name: Checkout code
           uses: actions/checkout@v2
      
         - name: Set up Docker Buildx
           uses: docker/setup-buildx-action@v1
      
         - name: Login to GitHub Container Registry
           uses: docker/login-action@v1
           with:
             registry: ghcr.io
             username: ${{ github.actor }}
             password: ${{ secrets.GITHUB_TOKEN }}
      
         - name: Extract version
           id: extract_version
           run: |
             version=$(jq -r '.version.major+"."+ .version.minor+"."+ .version.patch+"."+ .version.build' .koksmat/koksmat.json)
             echo "::set-output name=version::$version"
      
         - name: Build and push Docker image
           run: |
             imagename=$(jq -r '.imagename' .koksmat/koksmat.json)
             version=${{ steps.extract_version.outputs.version }}
             docker build -t $imagename:$version .
             docker push $imagename:$version

Deploying to Kubernetes

The deployment manifest is generated and published to Kubernetes using a PowerShell script located at 60-provision/10-web.ps1.