From a459e09d033112a11bcc81ca1e8686e175a73b0c Mon Sep 17 00:00:00 2001 From: Gourav Shah Date: Sun, 21 Sep 2025 15:27:04 +0530 Subject: [PATCH 1/3] Add Docker Compose setup and AI review workflow --- docker-compose.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 docker-compose.yaml diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..f4d2419 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,14 @@ +services: + tech-stack-advisor: + build: . + ports: + - "7860:7860" + environment: + - ENV=production + healthcheck: + test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:7860', timeout=5)"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + restart: unless-stopped From 445fbd8b6cf16164d005ebe3fcae6dccceec8d52 Mon Sep 17 00:00:00 2001 From: Gourav Shah Date: Sun, 21 Sep 2025 15:32:25 +0530 Subject: [PATCH 2/3] dont run docker image build on pr --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 78d36e0..3411529 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,8 +3,6 @@ name: CI Pipeline on: push: branches: [ "main", "develop" ] - pull_request: - branches: [ "main" ] env: REGISTRY: docker.io From c977336a8e3cd21ec069cdf86ee4e64f9d061792 Mon Sep 17 00:00:00 2001 From: Gourav Shah Date: Sun, 21 Sep 2025 15:39:15 +0530 Subject: [PATCH 3/3] ai based pr review with goose --- .github/workflows/goose-pr-review.yml | 40 +++++++++++---------- .goose/instructions.txt | 50 +++++++++++++++++++++++++++ docker-compose.yaml | 23 ++++++++++++ nginx.conf | 28 +++++++++++++++ 4 files changed, 122 insertions(+), 19 deletions(-) create mode 100644 .goose/instructions.txt create mode 100644 nginx.conf diff --git a/.github/workflows/goose-pr-review.yml b/.github/workflows/goose-pr-review.yml index d281338..57c362c 100644 --- a/.github/workflows/goose-pr-review.yml +++ b/.github/workflows/goose-pr-review.yml @@ -1,4 +1,4 @@ -name: Goose +name: AI Based PR Review with Goose on: pull_request: @@ -52,26 +52,19 @@ jobs: keyring: false EOF - - name: Create instructions for Goose + - name: Prepare review instructions run: | - cat > instructions.txt <<'EOF' - Create a summary of the changes provided. Don't provide any session or logging details. - The summary for each file should be brief and structured as: - - - dot points of changes - You don't need any extensions, don't mention extensions at all. - The changes to summarise are: - EOF - cat changes.txt >> instructions.txt - - - name: Test - run: cat instructions.txt + # Read custom instructions from repository + cat .goose/instructions.txt > review_instructions.txt + echo "" >> review_instructions.txt + echo "The changes to review are:" >> review_instructions.txt + cat changes.txt >> review_instructions.txt - - name: Run Goose and filter output + - name: Run Goose AI review env: GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }} run: | - goose run --instructions instructions.txt \ + goose run --instructions review_instructions.txt \ | sed -E 's/\x1B\[[0-9;]*[mK]//g' \ | grep -v "logging to /home/runner/.config/goose/sessions/" \ | grep -v "^starting session" \ @@ -79,7 +72,16 @@ jobs: | sed 's/[[:space:]]*$//' \ > pr_comment.txt - - name: Post comment to PR + - name: Post AI review to PR run: | - cat -A pr_comment.txt - gh pr comment "$PR_NUMBER" --body-file pr_comment.txt + { + echo "## 🤖 AI Code Review" + echo "*Automated review by Goose + Google Gemini*" + echo "" + cat pr_comment.txt + echo "" + echo "---" + echo "*This review was automatically generated. Use human judgment for final decisions.*" + } > final_comment.txt + + gh pr comment "$PR_NUMBER" --body-file final_comment.txt diff --git a/.goose/instructions.txt b/.goose/instructions.txt new file mode 100644 index 0000000..e8d4b8e --- /dev/null +++ b/.goose/instructions.txt @@ -0,0 +1,50 @@ +You are an expert DevOps engineer reviewing code changes for a machine learning application. + +Focus your review on these key areas: + +## 🐳 Docker & Containerization +- Dockerfile best practices and optimization +- Multi-stage builds and layer efficiency +- Security considerations (non-root users, minimal base images) +- Health checks and restart policies + +## 🏗️ Infrastructure & Orchestration +- Docker Compose service configuration +- Service dependencies and networking +- Volume mounts and data persistence +- Load balancing and proxy setup + +## 🔒 Security & Best Practices +- Exposed ports and network security +- Environment variable management +- Container security practices +- Access controls and permissions + +## 🚀 CI/CD & Automation +- Workflow efficiency and optimization +- Security scanning integration +- Caching strategies and performance +- Error handling and reliability + +## 📊 Code Quality +- Configuration file structure and clarity +- Documentation and maintainability +- Production readiness +- Scalability considerations + +## Review Format +Please structure your review as: + +**`filename`** +- Summary of changes +- Key observations +- Recommendations for improvement +- Security or performance notes + +**Overall Assessment:** +- Rate: Excellent/Good/Needs Improvement +- Main strengths +- Priority improvements +- Production readiness assessment + +Keep feedback constructive, specific, and actionable. diff --git a/docker-compose.yaml b/docker-compose.yaml index 27f08a7..7f345ec 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,3 +1,5 @@ +version: '3.8' + services: tech-stack-advisor: build: . @@ -12,4 +14,25 @@ services: retries: 3 start_period: 40s restart: unless-stopped + + redis: + image: redis:7-alpine + ports: + - "6379:6379" + volumes: + - redis_data:/data + command: redis-server --appendonly yes + restart: unless-stopped + + nginx: + image: nginx:alpine + ports: + - "80:80" + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf:ro + depends_on: + - tech-stack-advisor + restart: unless-stopped +volumes: + redis_data: diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..63b7f1d --- /dev/null +++ b/nginx.conf @@ -0,0 +1,28 @@ +events { + worker_connections 1024; +} + +http { + upstream tech_stack_advisor { + server tech-stack-advisor:7860; + } + + server { + listen 80; + server_name localhost; + + location / { + proxy_pass http://tech_stack_advisor; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + + location /health { + access_log off; + return 200 "healthy\n"; + add_header Content-Type text/plain; + } + } +}