Skip to content
Merged
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
166 changes: 41 additions & 125 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,138 +1,54 @@
.PHONY: help dev prod build test clean deploy
# CodeIntel Development Makefile
# Usage: make [target]

# Default target
help:
@echo "CodeIntel - Development Commands"
@echo ""
@echo "Local Development:"
@echo " make dev - Start local dev (uses .env.dev)"
@echo " make dev-prod - Test prod config locally (uses .env.prod)"
@echo " make stop - Stop all services"
@echo " make clean - Stop and remove all containers/volumes"
@echo " make logs - View all logs"
@echo " make health - Check service health"
@echo ""
@echo "Testing:"
@echo " make test - Run backend tests"
@echo " make test-ws - Run WebSocket auth tests only"
@echo " make coverage - Run tests with coverage report"
@echo ""
@echo "Deployment:"
@echo " make deploy-backend - Deploy backend to Railway"
@echo " make deploy-frontend - Deploy frontend to Vercel"
.PHONY: f b all logs restart down status clean help

# ============================================
# LOCAL DEVELOPMENT
# ============================================
# Default target - rebuild frontend
f frontend:
@echo "🔄 Rebuilding frontend..."
@docker compose build frontend
@docker compose up -d frontend
@echo "✅ Done"

# Development with .env.dev
dev:
@echo "🚀 Starting LOCAL DEV environment..."
@cp .env.dev .env
docker compose up -d --build
@echo ""
@echo "✅ Development environment started!"
@echo " Backend: http://localhost:8000"
@echo " API Docs: http://localhost:8000/docs"
@echo " Frontend: http://localhost:3000"
@echo " Redis: localhost:6379"
@echo ""
@echo "View logs: make logs"
b backend:
@echo "🔄 Rebuilding backend..."
@docker compose build backend
@docker compose up -d backend
@echo "✅ Done"

# Test production config locally (uses .env.prod)
dev-prod:
@echo "🚀 Starting LOCAL environment with PROD config..."
@cp .env.prod .env
docker compose up -d --build
@echo ""
@echo "✅ Prod-config environment started!"
@echo " Backend: http://localhost:8000"
@echo " Frontend: http://localhost:3000"
all:
@docker compose build
@docker compose up -d

# Stop services
stop:
docker compose down
@echo "✅ Services stopped"
up:
@docker compose up -d

# Clean everything (including volumes)
clean:
docker compose down -v --remove-orphans
@echo "✅ Cleaned all containers and volumes"
down:
@docker compose down

restart:
@docker compose restart

# View logs
logs:
docker compose logs -f
@docker compose logs -f frontend

# Logs for specific service
logs-backend:
docker compose logs -f backend

logs-frontend:
docker compose logs -f frontend

# ============================================
# TESTING
# ============================================

# Run all backend tests
test:
cd backend && python3 -m pytest tests/ -v --no-cov

# Run WebSocket auth tests only
test-ws:
cd backend && python3 -m pytest tests/test_websocket_auth.py -v --no-cov

# Run tests with coverage
coverage:
cd backend && python3 -m pytest tests/ --cov=. --cov-report=html --cov-report=term
@echo ""
@echo "Coverage report: backend/htmlcov/index.html"

# ============================================
# DEPLOYMENT
# ============================================
@docker compose logs -f backend

# Deploy backend to Railway
deploy-backend:
@echo "🚀 Deploying backend to Railway..."
railway up
@echo "✅ Backend deployed!"
status ps:
@docker compose ps

# Deploy frontend to Vercel
deploy-frontend:
@echo "🚀 Deploying frontend to Vercel..."
cd frontend && vercel --prod
@echo "✅ Frontend deployed!"

# Deploy everything
deploy-all: deploy-backend deploy-frontend
@echo "✅ All services deployed!"

# ============================================
# UTILITIES
# ============================================

# Check service health
health:
@echo "Checking services..."
@curl -s http://localhost:8000/health | python3 -m json.tool 2>/dev/null || echo "❌ Backend not responding"
@curl -s -o /dev/null -w "" http://localhost:3000 && echo "✅ Frontend is up" || echo "❌ Frontend not responding"
@docker compose exec -T redis redis-cli ping 2>/dev/null | grep -q PONG && echo "✅ Redis is up" || echo "❌ Redis not responding"

# Shell into backend container
shell-backend:
docker compose exec backend bash

# Shell into Redis
shell-redis:
docker compose exec redis redis-cli

# Quick rebuild backend only
rebuild-backend:
docker compose up -d --build backend
@echo "✅ Backend rebuilt and restarted"
clean:
@echo "⚠️ Full rebuild (slow)..."
@docker compose build --no-cache
@docker compose up -d

# Quick rebuild frontend only
rebuild-frontend:
docker compose up -d --build frontend
@echo "✅ Frontend rebuilt and restarted"
help:
@echo "make f - Rebuild frontend (~10s)"
@echo "make b - Rebuild backend"
@echo "make all - Rebuild everything"
@echo "make up - Start services"
@echo "make down - Stop services"
@echo "make logs - Frontend logs"
@echo "make status - Container status"
@echo "make clean - Full rebuild (slow)"
63 changes: 63 additions & 0 deletions dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash
# Quick rebuild script for CodeIntel development
# Usage: ./dev.sh [frontend|backend|all]

set -e

cd "$(dirname "$0")"

case "${1:-frontend}" in
frontend|f)
echo "🔄 Rebuilding frontend only..."
docker compose build frontend
docker compose up -d frontend
echo "✅ Frontend rebuilt in ~10s"
;;
backend|b)
echo "🔄 Rebuilding backend only..."
docker compose build backend
docker compose up -d backend
echo "✅ Backend rebuilt"
;;
all|a)
echo "🔄 Rebuilding all services..."
docker compose build
docker compose up -d
echo "✅ All services rebuilt"
;;
logs|l)
docker compose logs -f "${2:-frontend}"
;;
restart|r)
echo "🔄 Restarting ${2:-all} without rebuild..."
if [ -n "$2" ]; then
docker compose restart "$2"
else
docker compose restart
fi
;;
down|d)
docker compose down
;;
status|s)
docker compose ps
;;
clean)
echo "⚠️ Full rebuild with no cache..."
docker compose build --no-cache
docker compose up -d
;;
*)
echo "Usage: ./dev.sh [command]"
echo ""
echo "Commands:"
echo " frontend, f Rebuild frontend only (~10s)"
echo " backend, b Rebuild backend only (~2min first time, cached after)"
echo " all, a Rebuild all services"
echo " logs, l [svc] Follow logs (default: frontend)"
echo " restart, r Restart without rebuild"
echo " down, d Stop all services"
echo " status, s Show container status"
echo " clean Full rebuild, no cache (slow!)"
;;
esac
14 changes: 7 additions & 7 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Frontend Dockerfile - Multi-stage build
FROM node:20-alpine AS builder
# Frontend Dockerfile - Multi-stage build with Bun
FROM oven/bun:1 AS builder

WORKDIR /app

Expand All @@ -13,17 +13,17 @@ ENV VITE_API_URL=$VITE_API_URL
ENV VITE_SUPABASE_URL=$VITE_SUPABASE_URL
ENV VITE_SUPABASE_ANON_KEY=$VITE_SUPABASE_ANON_KEY

# Copy package files
COPY package*.json ./
# Copy package files (lockfile required for deterministic builds)
COPY package.json bun.lock ./

# Install dependencies
RUN npm ci
# Install dependencies (fail if lockfile missing or outdated)
RUN bun install --frozen-lockfile

# Copy source code
COPY . .

# Build for production
RUN npm run build
RUN bun run build

# Production image - nginx
FROM nginx:alpine
Expand Down
Loading