Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions .github/workflows/deploy-to-azure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Deploy to Azure Container Apps

on:
push:
branches: [ main ]
paths:
- 'codemotion-mcp-server/**'
- 'infra/**'
- '.github/workflows/deploy-to-azure.yml'
workflow_dispatch:

permissions:
contents: read
id-token: write

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.0.0

- name: Azure Login
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

- name: Terraform Init
run: |
cd infra
terraform init

- name: Terraform Plan
run: |
cd infra
terraform plan -out=tfplan \
-var="github_token=${{ secrets.GITHUB_TOKEN }}"

- name: Terraform Apply
run: |
cd infra
terraform apply -auto-approve tfplan

- name: Get ACR details
id: acr
run: |
cd infra
echo "ACR_LOGIN_SERVER=$(terraform output -raw acr_login_server)" >> $GITHUB_ENV
echo "ACR_USERNAME=$(terraform output -raw acr_admin_username)" >> $GITHUB_ENV
echo "ACR_PASSWORD=$(terraform output -raw acr_admin_password)" >> $GITHUB_ENV

- name: Build and push image to ACR
uses: azure/docker-login@v1
with:
login-server: ${{ env.ACR_LOGIN_SERVER }}
username: ${{ env.ACR_USERNAME }}
password: ${{ env.ACR_PASSWORD }}

- name: Build and push Docker image
run: |
cd codemotion-mcp-server
docker build -t ${{ env.ACR_LOGIN_SERVER }}/codemotion-mcp-server:${{ github.sha }} .
docker push ${{ env.ACR_LOGIN_SERVER }}/codemotion-mcp-server:${{ github.sha }}
docker tag ${{ env.ACR_LOGIN_SERVER }}/codemotion-mcp-server:${{ github.sha }} ${{ env.ACR_LOGIN_SERVER }}/codemotion-mcp-server:latest
docker push ${{ env.ACR_LOGIN_SERVER }}/codemotion-mcp-server:latest

- name: Update Container App with new image
run: |
RESOURCE_GROUP=$(cd infra && terraform output -raw resource_group_name)
APP_NAME=$(cd infra && terraform output -raw container_app_name)

az containerapp update \
--name $APP_NAME \
--resource-group $RESOURCE_GROUP \
--container-name mcp-server \
--image ${{ env.ACR_LOGIN_SERVER }}/codemotion-mcp-server:${{ github.sha }}
9 changes: 9 additions & 0 deletions codemotion-mcp-server/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# GitHub Models API credentials
GITHUB_TOKEN=your_github_token
GITHUB_MODELS_URL=https://api.github.com/models
GITHUB_MODELS_MODEL_FOR_EMBEDDINGS=text-embedding-3-large

# Qdrant Configuration
QDRANT_HOST=qdrant.internal
QDRANT_PORT=6333
QDRANT_COLLECTION_NAME=codemotion
21 changes: 21 additions & 0 deletions codemotion-mcp-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM node:18-alpine

WORKDIR /app

# Copy package.json and package-lock.json
COPY package*.json ./

# Install dependencies
RUN npm install

# Copy source code
COPY . .

# Build TypeScript
RUN npx tsc

# Expose port
EXPOSE 3000

# Command to run the application
CMD ["node", "dist/src/index.js"]
12 changes: 6 additions & 6 deletions codemotion-mcp-server/src/tools/sessionTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ export const registerSessionTool = (server: any): void => {
console.log(chalk.blue('Codemotion MCP Server: Vector:', vector));
console.log(chalk.blue('Codemotion MCP Server: Searching for sessions in Qdrant...'));

// Create a Qdrant client
const qdrantClient = new QdrantClient({
host: 'qdrant',
port: 6333,
https: false,
checkCompatibility: false
// Create a Qdrant client
const qdrantClient = new QdrantClient({
host: process.env.QDRANT_HOST || 'qdrant',
port: Number(process.env.QDRANT_PORT) || 6333,
https: false,
checkCompatibility: false
});

// Search for the sessions in Qdrant
Expand Down
98 changes: 98 additions & 0 deletions infra/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Codemotion 2025 Azure Deployment

This directory contains Terraform code to deploy the Codemotion 2025 MCP Server on Azure Container Apps.

## Prerequisites

- [Terraform](https://www.terraform.io/downloads.html) (version >= 1.0)
- [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli)
- Docker installed locally for building the container image
- An Azure subscription

## Setup Steps

### 1. Login to Azure

```bash
az login
```

### 2. Build and Push the Docker Image

```bash
# Navigate to the MCP Server directory
cd ../codemotion-mcp-server

# Build the Docker image
docker build -t codemotion-mcp-server:latest .

# Log in to Azure Container Registry (after terraform apply)
az acr login --name <acr_name>

# Tag the image
docker tag codemotion-mcp-server:latest <acr_name>.azurecr.io/codemotion-mcp-server:latest

# Push the image
docker push <acr_name>.azurecr.io/codemotion-mcp-server:latest
```

### 3. Initialize Terraform

```bash
# Navigate back to the infra directory
cd ../infra

# Initialize Terraform
terraform init
```

### 4. Create a terraform.tfvars File

Create a `terraform.tfvars` file with your custom values:

```hcl
resource_group_name = "rg-codemotion-2025"
location = "westeurope"
acr_name = "acrcodemotion2025"
github_token = "your-github-token"
# Add other variables as needed
```

### 5. Apply Terraform Configuration

```bash
terraform apply
```

Review the plan and type `yes` to proceed.

## Accessing the Deployed Application

After the deployment is complete, you can access your MCP Server at the URL provided in the outputs:

```bash
terraform output mcp_server_url
```

## Clean Up Resources

To remove all resources created by this Terraform configuration:

```bash
terraform destroy
```

Review the plan and type `yes` to proceed with deletion.

## Architecture

This deployment creates:

1. Azure Resource Group
2. Azure Container Registry (ACR)
3. Log Analytics Workspace
4. Container App Environment
5. Qdrant Container App (for vector search)
6. MCP Server Container App

The MCP Server connects to Qdrant using the internal DNS name within the Container App Environment.
27 changes: 27 additions & 0 deletions infra/acr.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Create Azure Container Registry
resource "azurerm_container_registry" "acr" {
name = var.acr_name
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
sku = "Basic"
admin_enabled = true

tags = {
Environment = "Demo"
Project = "Codemotion2025"
}
}

# Output for later use in GitHub Actions or other CI/CD
output "acr_login_server" {
value = azurerm_container_registry.acr.login_server
}

output "acr_admin_username" {
value = azurerm_container_registry.acr.admin_username
}

output "acr_admin_password" {
value = azurerm_container_registry.acr.admin_password
sensitive = true
}
Loading