diff --git a/.dockerignore b/.dockerignore index 3466d315..843dec4f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,6 +1,2 @@ -* -!*.py -!requirements.txt -!images/* -!front-end/* -front-end/node_modules/* +Dockerfile +charts/ diff --git a/.github/workflows/Genstack.yaml b/.github/workflows/Genstack.yaml new file mode 100644 index 00000000..20efea26 --- /dev/null +++ b/.github/workflows/Genstack.yaml @@ -0,0 +1,66 @@ +name: Genstack +"on": + push: + branches: + - main + workflow_dispatch: {} +env: + ACR_RESOURCE_GROUP: kubeops_group + AZURE_CONTAINER_REGISTRY: acrworkflow1722973530004 + CLUSTER_NAME: kube + CLUSTER_RESOURCE_GROUP: kubeops_group + CONTAINER_NAME: image-workflow-1722973530004 + DEPLOYMENT_MANIFEST_PATH: | + ./front-end/package.json + ./front-end/package-lock.json + ./front-end/jsconfig.json +jobs: + buildImage: + permissions: + contents: read + id-token: write + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 + name: Azure login + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + - name: Build and push image to ACR + run: az acr build --image ${{ env.CONTAINER_NAME }}:${{ github.sha }} --registry ${{ env.AZURE_CONTAINER_REGISTRY }} -g ${{ env.ACR_RESOURCE_GROUP }} -f ./docker-compose.yml ./ + deploy: + permissions: + actions: read + contents: read + id-token: write + runs-on: ubuntu-latest + needs: + - buildImage + steps: + - uses: actions/checkout@v3 + - uses: azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 + name: Azure login + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + - uses: azure/use-kubelogin@v1 + name: Set up kubelogin for non-interactive login + with: + kubelogin-version: v0.0.25 + - uses: azure/aks-set-context@v3 + name: Get K8s context + with: + admin: "false" + cluster-name: ${{ env.CLUSTER_NAME }} + resource-group: ${{ env.CLUSTER_RESOURCE_GROUP }} + use-kubelogin: "true" + - uses: Azure/k8s-deploy@v4 + name: Deploys application + with: + action: deploy + images: ${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.sha }} + manifests: ${{ env.DEPLOYMENT_MANIFEST_PATH }} + namespace: namespace-workflow-1722973530004 diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 00000000..3f53646d --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,18 @@ +name: Docker Image CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Build the Docker image + run: docker build . --file Dockerfile --tag my-image-name:$(date +%s) diff --git a/.github/workflows/genai-AutoDeployTrigger-08802d17-3be0-4081-89af-8ab34c2110f5.yml b/.github/workflows/genai-AutoDeployTrigger-08802d17-3be0-4081-89af-8ab34c2110f5.yml new file mode 100644 index 00000000..c7077b07 --- /dev/null +++ b/.github/workflows/genai-AutoDeployTrigger-08802d17-3be0-4081-89af-8ab34c2110f5.yml @@ -0,0 +1,48 @@ +name: Trigger auto deployment for genai + +# When this action will be executed +on: + # Automatically trigger it when detected changes in repo + push: + branches: + [ main ] + paths: + - '**' + - '.github/workflows/genai-AutoDeployTrigger-08802d17-3be0-4081-89af-8ab34c2110f5.yml' + + # Allow manual trigger + workflow_dispatch: + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + permissions: + id-token: write #This is required for requesting the OIDC JWT Token + contents: read #Required when GH token is used to authenticate with private repo + + steps: + - name: Checkout to the branch + uses: actions/checkout@v2 + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.GENAI_AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.GENAI_AZURE_TENANT_ID }} + subscription-id: ${{ secrets.GENAI_AZURE_SUBSCRIPTION_ID }} + + - name: Build and push container image to registry + uses: azure/container-apps-deploy-action@v2 + with: + appSourcePath: ${{ github.workspace }} + _dockerfilePathKey_: _dockerfilePath_ + registryUrl: hub.docker.com + registryUsername: ${{ secrets.GENAI_REGISTRY_USERNAME }} + registryPassword: ${{ secrets.GENAI_REGISTRY_PASSWORD }} + containerAppName: genai + resourceGroup: kubeops_group + imageToBuild: hub.docker.com/genai:${{ github.sha }} + _buildArgumentsKey_: | + _buildArgumentsValues_ + + diff --git a/.github/workflows/genstack.yaml b/.github/workflows/genstack.yaml new file mode 100644 index 00000000..ce65a69a --- /dev/null +++ b/.github/workflows/genstack.yaml @@ -0,0 +1,65 @@ +name: genstack +"on": + push: + branches: + - main + workflow_dispatch: {} +env: + ACR_RESOURCE_GROUP: kubeops_group + AZURE_CONTAINER_REGISTRY: acrworkflow1723012492625 + CLUSTER_NAME: kube + CLUSTER_RESOURCE_GROUP: kubeops_group + CONTAINER_NAME: image-workflow-1723012492625 + DEPLOYMENT_MANIFEST_PATH: | + manifests/deployment.yaml + manifests/service.yaml +jobs: + buildImage: + permissions: + contents: read + id-token: write + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 + name: Azure login + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + - name: Build and push image to ACR + run: az acr build --image ${{ env.CONTAINER_NAME }}:${{ github.sha }} --registry ${{ env.AZURE_CONTAINER_REGISTRY }} -g ${{ env.ACR_RESOURCE_GROUP }} -f Dockerfile ./ + deploy: + permissions: + actions: read + contents: read + id-token: write + runs-on: ubuntu-latest + needs: + - buildImage + steps: + - uses: actions/checkout@v3 + - uses: azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 + name: Azure login + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + - uses: azure/use-kubelogin@v1 + name: Set up kubelogin for non-interactive login + with: + kubelogin-version: v0.0.25 + - uses: azure/aks-set-context@v3 + name: Get K8s context + with: + admin: "false" + cluster-name: ${{ env.CLUSTER_NAME }} + resource-group: ${{ env.CLUSTER_RESOURCE_GROUP }} + use-kubelogin: "true" + - uses: Azure/k8s-deploy@v4 + name: Deploys application + with: + action: deploy + images: ${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.sha }} + manifests: ${{ env.DEPLOYMENT_MANIFEST_PATH }} + namespace: aks-istio-system diff --git a/.npmrc b/.npmrc new file mode 100644 index 00000000..6d567622 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +registry=https://packages.us-west-2.codecatalyst.aws/npm/Sauditech/mygit/Repository/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..16322aae --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM python:3.11-slim +ENV PORT 8000 +EXPOSE 8000 +WORKDIR /usr/src/app + +COPY requirements.txt ./ +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . + +ENTRYPOINT ["python"] +CMD ["app.py"] \ No newline at end of file diff --git a/front-end/package.json b/front-end/package.json index 910db7cd..c28e1b5b 100644 --- a/front-end/package.json +++ b/front-end/package.json @@ -9,14 +9,14 @@ "preview": "vite preview" }, "devDependencies": { - "@sveltejs/vite-plugin-svelte": "^2.4.2", - "autoprefixer": "^10.4.16", - "postcss": "^8.4.31", + "@sveltejs/vite-plugin-svelte": "^2.5.3", + "autoprefixer": "^10.4.19", + "postcss": "^8.4.42", "svelte": "^4.0.5", - "tailwindcss": "^3.3.3", - "vite": "^4.4.12" + "tailwindcss": "^3.4.8", + "vite": "^4.5.3" }, "dependencies": { - "svelte-markdown": "^0.4.0" + "svelte-markdown": "^0.4.1" } } diff --git a/manifests/deployment.yaml b/manifests/deployment.yaml new file mode 100644 index 00000000..6a90b5fe --- /dev/null +++ b/manifests/deployment.yaml @@ -0,0 +1,24 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: genstack + labels: + app: genstack + kubernetes.azure.com/generator: devhub + namespace: aks-istio-system +spec: + replicas: 1 + selector: + matchLabels: + app: genstack + template: + metadata: + labels: + app: genstack + spec: + containers: + - name: genstack + image: acrworkflow1723012492625.azurecr.io/image-workflow-1723012492625:latest + imagePullPolicy: Always + ports: + - containerPort: 8000 diff --git a/manifests/graphrag b/manifests/graphrag new file mode 160000 index 00000000..073f650b --- /dev/null +++ b/manifests/graphrag @@ -0,0 +1 @@ +Subproject commit 073f650ba9f059bbc4d3c9558d880fa88836487f diff --git a/manifests/package-lock.json b/manifests/package-lock.json new file mode 100644 index 00000000..4c5228eb --- /dev/null +++ b/manifests/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "manifests", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} diff --git a/manifests/service.yaml b/manifests/service.yaml new file mode 100644 index 00000000..cdaf290a --- /dev/null +++ b/manifests/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: genstack + namespace: aks-istio-system + labels: + kubernetes.azure.com/generator: devhub +spec: + type: LoadBalancer + selector: + app: genstack + ports: + - protocol: TCP + port: 8000 + targetPort: 8000 \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..731ed4c5 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "genai-stack", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} diff --git a/requirements.txt b/requirements.txt index ad0f6f90..4c89d04e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,7 +8,7 @@ sentence_transformers==2.2.2 Pillow fastapi PyPDF2 -torch==2.0.1 +torch==2.2.0 pydantic uvicorn sse-starlette