This commit is contained in:
2026-01-03 14:16:16 -08:00
commit 1f0e678d47
71 changed files with 16127 additions and 0 deletions

170
Makefile Normal file
View File

@@ -0,0 +1,170 @@
.PHONY: dev dev-up dev-down test migrate migrate-up migrate-down build clean
# Development
dev: dev-up
@echo "Development environment is running"
@echo "Backend: http://localhost:8080"
@echo "Frontend: http://localhost:3000"
@echo ""
@echo "To view logs:"
@echo " make dev-logs"
@echo ""
@echo "To stop:"
@echo " make dev-down"
dev-up:
@echo "Creating podman network..."
-podman network create paragliding-net 2>/dev/null || true
@echo "Starting PostgreSQL..."
-podman rm -f paragliding-postgres 2>/dev/null || true
podman run -d \
--name paragliding-postgres \
--network paragliding-net \
-e POSTGRES_DB=paragliding \
-e POSTGRES_USER=dev \
-e POSTGRES_PASSWORD=devpass \
-p 5432:5432 \
postgres:16-alpine
@echo "Waiting for PostgreSQL to be ready..."
@sleep 5
@echo "Building backend..."
podman build -t paragliding-backend:dev -f backend/Dockerfile.dev backend/
@echo "Starting backend..."
-podman rm -f paragliding-backend 2>/dev/null || true
podman run -d \
--name paragliding-backend \
--network paragliding-net \
-e DATABASE_URL="postgres://dev:devpass@paragliding-postgres:5432/paragliding?sslmode=disable" \
-e PORT=8080 \
-e LOCATION_LAT=32.8893 \
-e LOCATION_LON=-117.2519 \
-e LOCATION_NAME="Torrey Pines Gliderport" \
-e TIMEZONE="America/Los_Angeles" \
-e FETCH_INTERVAL=15m \
-e CACHE_TTL=10m \
-p 8080:8080 \
-v $(PWD)/backend:/app:z \
paragliding-backend:dev
@echo "Building frontend..."
podman build -t paragliding-frontend:dev --target dev -f frontend/Dockerfile frontend/
@echo "Starting frontend..."
-podman rm -f paragliding-frontend 2>/dev/null || true
podman run -d \
--name paragliding-frontend \
--network paragliding-net \
-e NEXT_PUBLIC_API_URL=http://localhost:8080/api/v1 \
-p 3000:3000 \
-v $(PWD)/frontend:/app:z \
-v /app/node_modules \
-v /app/.next \
paragliding-frontend:dev
dev-down:
@echo "Stopping containers..."
-podman rm -f paragliding-frontend paragliding-backend paragliding-postgres 2>/dev/null || true
@echo "Containers stopped"
dev-logs:
@echo "=== Backend Logs ==="
podman logs -f paragliding-backend
dev-logs-frontend:
@echo "=== Frontend Logs ==="
podman logs -f paragliding-frontend
dev-logs-postgres:
@echo "=== PostgreSQL Logs ==="
podman logs -f paragliding-postgres
# Database migrations
migrate-up:
cd backend && go run -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest \
-path ./migrations \
-database "$(DATABASE_URL)" \
up
migrate-down:
cd backend && go run -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest \
-path ./migrations \
-database "$(DATABASE_URL)" \
down 1
migrate-create:
cd backend && go run -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest \
create -ext sql -dir ./migrations -seq $(name)
# Testing
test:
docker compose -f docker-compose.test.yml up --build --abort-on-container-exit
docker compose -f docker-compose.test.yml down -v
test-backend:
cd backend && go test -v ./...
test-frontend:
cd frontend && npm test
# Build
build-backend:
cd backend && go build -o bin/api ./cmd/api
build-frontend:
cd frontend && npm run build
build: build-backend build-frontend
# Clean
clean:
rm -rf backend/bin
rm -rf frontend/.next
rm -rf frontend/node_modules
# Local development without Docker
# Start postgres only (for local dev)
dev-db:
@echo "Starting PostgreSQL..."
podman-compose -f docker-compose.dev.yml up -d
@echo "PostgreSQL is running on localhost:5432"
@echo "Database: paragliding"
@echo "User: dev"
@echo "Password: devpass"
dev-db-down:
@echo "Stopping PostgreSQL..."
podman-compose -f docker-compose.dev.yml down
@echo "PostgreSQL stopped"
# Run backend locally (requires postgres)
run-backend:
@if [ ! -f backend/.env ]; then \
echo "Creating backend/.env from .env.example..."; \
cp backend/.env.example backend/.env; \
fi
cd backend && go run ./cmd/api
# Run frontend locally
run-frontend:
cd frontend && npm run dev
# Complete local development setup (using idempotent script)
dev-local:
@./dev.sh
# Alternative: step-by-step setup
dev-local-manual:
@echo "🚀 Setting up local development environment..."
@echo ""
@echo "1. Starting PostgreSQL..."
@make dev-db
@echo ""
@echo "2. Waiting for PostgreSQL to be ready..."
@sleep 3
@echo ""
@echo "3. Running migrations..."
@make migrate-up DATABASE_URL="postgres://dev:devpass@localhost:5432/paragliding?sslmode=disable"
@echo ""
@echo "✅ Setup complete!"
@echo ""
@echo "Now run these commands in separate terminals:"
@echo " Terminal 1: make run-backend"
@echo " Terminal 2: make run-frontend"