Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
72 changes: 72 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Deploy to Kubernetes

on:
push:
branches:
- main
workflow_dispatch:

env:
REGISTRY: crretoxmas2024.azurecr.io
NAMESPACE: reto-xmas-2025-goland-ia-backend

jobs:
build-and-deploy:
runs-on: ubuntu-latest
strategy:
matrix:
service:
- name: docs-manager
path: ./DocsManager
image: reto-xmas-2025-goland-ia-backend-docs-manager
deployment: docs-manager
- name: rag-manager
path: ./RAGManager
image: reto-xmas-2025-goland-ia-backend-rag-manager
deployment: rag-manager
Comment on lines +22 to +27
Copy link

Copilot AI Dec 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The image name contains "goland" which appears to be a typo for "golang". GoLand is a JetBrains IDE, while Golang (or Go) is the programming language. If this is meant to reference the Go language, it should be corrected to "golang".

Copilot uses AI. Check for mistakes.
Comment thread
Locatelli-Flor marked this conversation as resolved.

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to ACR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ${{ matrix.service.path }}
platforms: linux/amd64
push: true
tags: |
${{ env.REGISTRY }}/${{ matrix.service.image }}:latest
${{ env.REGISTRY }}/${{ matrix.service.image }}:${{ github.sha }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ matrix.service.image }}:buildcache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ matrix.service.image }}:buildcache,mode=max

- name: Set up kubectl
uses: azure/setup-kubectl@v3
with:
version: 'latest'

- name: Configure kubectl
run: |
mkdir -p $HOME/.kube
echo "${{ secrets.KUBECONFIG }}" | base64 -d > $HOME/.kube/config
chmod 600 $HOME/.kube/config
Comment thread
Locatelli-Flor marked this conversation as resolved.

- name: Restart deployment
run: |
kubectl rollout restart deployment/${{ matrix.service.deployment }} -n ${{ env.NAMESPACE }}
kubectl rollout status deployment/${{ matrix.service.deployment }} -n ${{ env.NAMESPACE }} --timeout=5m

- name: Verify deployment
run: |
kubectl get pods -n ${{ env.NAMESPACE }} -l app=${{ matrix.service.deployment }}
Comment thread
Locatelli-Flor marked this conversation as resolved.
Outdated
99 changes: 99 additions & 0 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: PR Validation

on:
pull_request:
branches:
- main

env:
REGISTRY: crretoxmas2024.azurecr.io
DOCS_MANAGER_IMAGE: reto-xmas-2025-goland-ia-backend-docs-manager
RAG_MANAGER_IMAGE: reto-xmas-2025-goland-ia-backend-rag-manager
Comment thread
Locatelli-Flor marked this conversation as resolved.
Comment thread
Locatelli-Flor marked this conversation as resolved.

jobs:
build-validation:
name: Build Validation
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
service:
- name: docs-manager
path: ./DocsManager
image: reto-xmas-2025-goland-ia-backend-docs-manager
- name: rag-manager
path: ./RAGManager
image: reto-xmas-2025-goland-ia-backend-rag-manager

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: ${{ matrix.service.path }}
platforms: linux/amd64
load: true
tags: ${{ matrix.service.image }}:pr-${{ github.event.pull_request.number }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ matrix.service.image }}:buildcache

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: ${{ matrix.service.image }}:pr-${{ github.event.pull_request.number }}
format: 'sarif'
output: 'trivy-results-${{ matrix.service.name }}.sarif'
severity: 'CRITICAL,HIGH'
exit-code: '0'

- name: Upload Trivy results to GitHub Security
uses: github/codeql-action/upload-sarif@v4
if: always()
with:
sarif_file: 'trivy-results-${{ matrix.service.name }}.sarif'
category: 'trivy-${{ matrix.service.name }}'

- name: Print Trivy results
if: always()
uses: aquasecurity/trivy-action@master
with:
image-ref: ${{ matrix.service.image }}:pr-${{ github.event.pull_request.number }}
format: 'table'
severity: 'CRITICAL,HIGH'
exit-code: '0'

pr-summary:
name: PR Summary
runs-on: ubuntu-latest
needs: [build-validation]
if: always()
steps:
- name: PR Comment
uses: actions/github-script@v7
Comment on lines +73 to +76
Copy link

Copilot AI Dec 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Trivy scan in the "Print Trivy results" step attempts to scan an image that was built with "push: false" on line 53, meaning the image only exists in the local buildx cache and is not available to the separate docker run command. This will cause the step to fail because the image cannot be found. Either enable pushing to a temporary registry or use the Trivy action's scan-type: 'fs' to scan the filesystem directly.

Copilot uses AI. Check for mistakes.
with:
script: |
const buildStatus = '${{ needs.build-validation.result }}';

const statusEmoji = (status) => {
if (status === 'success') return '✅';
if (status === 'failure') return '❌';
return '⚠️';
};

let message = '## 🔍 PR Validation Results\n\n';
message += `| Check | Status |\n`;
message += `|-------|--------|\n`;
message += `| Build | ${statusEmoji(buildStatus)} ${buildStatus} |\n`;
message += `| Trivy | Check Security tab |\n\n`;
message += `[View detailed results](${context.payload.repository.html_url}/actions/runs/${context.runId})`;

github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: message
});
Comment thread
Locatelli-Flor marked this conversation as resolved.
13 changes: 13 additions & 0 deletions DocsManager/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim
Comment thread
Locatelli-Flor marked this conversation as resolved.
Comment thread
Locatelli-Flor marked this conversation as resolved.

WORKDIR /app

COPY pyproject.toml uv.lock* ./

RUN uv sync --frozen --no-cache || uv sync --no-cache
Comment thread
Locatelli-Flor marked this conversation as resolved.

COPY . .

EXPOSE 8000

CMD ["uv", "run", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
1 change: 0 additions & 1 deletion DocsManager/Dockerfile.pgvector

This file was deleted.

23 changes: 0 additions & 23 deletions DocsManager/docker-compose.yml

This file was deleted.

2 changes: 1 addition & 1 deletion RAGManager/.python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.14
3.12
Comment thread
Locatelli-Flor marked this conversation as resolved.
13 changes: 13 additions & 0 deletions RAGManager/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
Comment thread
Locatelli-Flor marked this conversation as resolved.

WORKDIR /app

COPY pyproject.toml uv.lock* ./

RUN uv sync --frozen --no-cache || uv sync --no-cache
Comment thread
Locatelli-Flor marked this conversation as resolved.

COPY . .

EXPOSE 8000

CMD ["uv", "run", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
5 changes: 0 additions & 5 deletions RAGManager/Dockerfile.pgvector

This file was deleted.

23 changes: 0 additions & 23 deletions RAGManager/docker-compose.yml

This file was deleted.

85 changes: 85 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
services:
docs-manager:
build:
context: ./DocsManager
dockerfile: Dockerfile
container_name: docs-manager
ports:
- "8000:8000"
env_file:
- .env
- ./DocsManager/.env
Comment thread
Locatelli-Flor marked this conversation as resolved.
depends_on:
db:
condition: service_healthy
restart: unless-stopped
environment:
- PYTHONUNBUFFERED=1
- SERVICE_NAME=docs-manager
- SERVICE_ROLE=document-handler

rag-manager:
build:
context: ./RAGManager
dockerfile: Dockerfile
container_name: rag-manager
ports:
- "8001:8000"
env_file:
- .env
- ./RAGManager/.env
depends_on:
db:
condition: service_healthy
rabbitmq:
condition: service_healthy
restart: unless-stopped
environment:
- PYTHONUNBUFFERED=1
- SERVICE_NAME=rag-manager
- SERVICE_ROLE=document-processor

db:
image: pgvector/pgvector:pg16
Comment thread
Locatelli-Flor marked this conversation as resolved.
container_name: postgres-db
env_file:
- .env
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
ports:
- "5432:5432"
Comment thread
Locatelli-Flor marked this conversation as resolved.
volumes:
- postgres_data:/var/lib/postgresql/data
- ./db-init:/docker-entrypoint-initdb.d
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
interval: 5s
timeout: 5s
retries: 5

rabbitmq:
image: rabbitmq:3.13-management-alpine
Comment thread
Locatelli-Flor marked this conversation as resolved.
container_name: rabbitmq
ports:
- "5672:5672"
- "15672:15672"
env_file:
- .env
environment:
RABBITMQ_DEFAULT_USER: ${RABBITMQ_USER}
RABBITMQ_DEFAULT_PASS: ${RABBITMQ_PASSWORD}
volumes:
- rabbitmq_data:/var/lib/rabbitmq
restart: unless-stopped
healthcheck:
test: ["CMD", "rabbitmq-diagnostics", "ping"]
interval: 10s
timeout: 5s
retries: 5

volumes:
postgres_data:
rabbitmq_data:
Loading