Skip to content

mefetsi/hackathon-project-deployer

Repository files navigation

Agent Deploy Extension (Local Backend Demo)

This repo contains a local backend service plus an AI-powered Dockerfile generator (dockerizer-agent). The backend accepts a project zip, generates a Dockerfile using an agentic approach with Gemini (the AI iteratively explores your project using tools), builds a Docker image, pushes it to Artifact Registry, and deploys it to Google Cloud Run.

Prerequisites

  • Python 3.10+
  • Docker Desktop (or Docker Engine) running locally
  • Node.js 18+ (for the VS Code extension)
  • Google Cloud billing account (for deployment)
  • A GCP project with billing linked (Cloud Run + Artifact Registry can be auto-enabled during deploy)
  • Gemini API key for Dockerfile generation

Step-by-step (Windows cmd)

  1. Create and activate a virtual environment:
python -m venv .venv
.\.venv\Scripts\activate
  1. Install backend dependencies:
python -m pip install -r requirements.txt
python -m pip install -e dockerizer-agent
  1. Create a .env file in the repo root with:
GEMINI_API_KEY=your-gemini-api-key
GCP_OAUTH_CLIENT_ID=your-oauth-client-id
GCP_OAUTH_CLIENT_SECRET=your-oauth-client-secret

GCP_OAUTH_CLIENT_SECRET is optional for true Desktop OAuth clients. If you still get client_secret is missing, add the secret here and the extension will load it from the backend. The extension prefers backend .env OAuth values over built-in defaults unless VS Code settings are set.

  1. Start the backend server:
python -m uvicorn backend.app:app --reload
  1. In a new cmd window, set up the extension:
cd vscode-extension
npm install
npm run compile
code .
  1. In VS Code, press F5 to open the Extension Development Host window.

  2. In the Extension Development Host window:

    • Open Command Palette (Ctrl+Shift+P)
    • Run Agent Deploy: Open
    • Click Sign in with Google
    • Create a GCP project (if needed), link billing, and copy the Project ID
    • Fill in GCP Project ID, Cloud Run Service, and region
    • (Optional) Add runtime env vars to pass API keys to Cloud Run
    • Pick a project folder and click Deploy

Step-by-step (macOS/Linux)

  1. Create and activate a virtual environment:
python3 -m venv .venv
source .venv/bin/activate
  1. Install backend dependencies:
python -m pip install -r requirements.txt
python -m pip install -e dockerizer-agent
  1. Create a .env file in the repo root with:
GEMINI_API_KEY=your-gemini-api-key
GCP_OAUTH_CLIENT_ID=your-oauth-client-id
GCP_OAUTH_CLIENT_SECRET=your-oauth-client-secret
  1. Start the backend server:
python -m uvicorn backend.app:app --reload
  1. In a new terminal, set up the extension:
cd vscode-extension
npm install
npm run compile
code .
  1. In VS Code, press F5 to open the Extension Development Host window.

  2. In the Extension Development Host window:

    • Open Command Palette (Cmd+Shift+P)
    • Run Agent Deploy: Open
    • Click Sign in with Google
    • Create a GCP project (if needed), link billing, and copy the Project ID
    • Fill in GCP Project ID, Cloud Run Service, and region
    • (Optional) Add runtime env vars to pass API keys to Cloud Run
    • Pick a project folder and click Deploy

Extension settings (optional)

You can override defaults in VS Code settings:

  • agentDeploy.backendUrl (default http://127.0.0.1:8000)
  • agentDeploy.gcpClientId (optional override for Google OAuth client ID)
  • agentDeploy.gcpClientSecret (only needed if you created a Web OAuth client)
  • agentDeploy.gcpRegion (default asia-southeast1) If you prefer no VS Code settings, put GCP_OAUTH_CLIENT_ID and GCP_OAUTH_CLIENT_SECRET in the backend .env and the extension will fetch them automatically.

Manual API call (optional)

If you want to hit the backend directly:

  1. Get an access token:
gcloud auth login
gcloud auth print-access-token
  1. Call the backend:
curl -X POST http://127.0.0.1:8000/jobs \
  -F "project_zip=@/path/to/project.zip" \
  -F "access_token=YOUR_ACCESS_TOKEN" \
  -F "project_id=YOUR_PROJECT_ID" \
  -F "service_name=YOUR_SERVICE_NAME" \
  -F "region=asia-southeast1" \
  -F "env_vars=[{\"name\":\"API_KEY\",\"value\":\"secret\"}]"

Notes

  • Zips are kept for now under backend/data/uploads.
  • Work directories are stored under backend/data/work.
  • Cloud Run service names must be lowercase and start with a letter.
  • For solo devs with their own billing account, the flow is: create project + link billing, sign in, enter project ID, deploy.

Troubleshooting

If you see ImportError: cannot import name 'genai' from 'google', fix the environment:

Windows (cmd):

python -m pip uninstall -y google
python -m pip install -U google-genai
python -m pip install -r requirements.txt
python -m pip install -e dockerizer-agent
python -m uvicorn backend.app:app --reload

If you see client_secret is missing during Google sign-in:

  • Rebuild the extension: npm run compile
  • Preferred: add to .env:
GCP_OAUTH_CLIENT_ID=YOUR_CLIENT_ID
GCP_OAUTH_CLIENT_SECRET=YOUR_CLIENT_SECRET
  • Alternative: set in User Settings (JSON):
"agentDeploy.gcpClientId": "YOUR_CLIENT_ID",
"agentDeploy.gcpClientSecret": "YOUR_CLIENT_SECRET"
  • Reload the Extension Development Host and sign in again.

If deployment fails with SERVICE_DISABLED for Artifact Registry or Cloud Run:

  • The backend now auto-enables these APIs during deploy (if the user has permission).
  • Wait a minute for propagation and retry.

If deployment fails with a billing error:

  • Link a billing account to the target project, then retry.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors