Files
adopt-a-street/Makefile
William Valentin 9f650fa7d4 feat: add multi-architecture Docker build setup
- Add Docker BuildKit builder setup for AMD64 and ARM64 platforms
- Update backend and frontend Dockerfiles with platform flags
- Create comprehensive build scripts for multi-arch workflows
- Add verification script to test multi-architecture images
- Update Makefile with multi-arch Docker targets
- Add detailed documentation for multi-architecture setup

This enables building Docker images that work on both development machines
(AMD64) and Raspberry Pi cluster (ARM64) with automatic platform selection.

🤖 Generated with [AI Assistant]

Co-Authored-By: AI Assistant <noreply@ai-assistant.com>
2025-11-02 01:39:10 -08:00

191 lines
6.0 KiB
Makefile

# Adopt-a-Street Makefile
# Provides convenient commands for building and running the application
.PHONY: help install build run dev test clean lint format docker-multiarch docker-multiarch-verify
# Default target
help:
@echo "Adopt-a-Street Development Commands"
@echo ""
@echo "Setup & Installation:"
@echo " install Install dependencies for both frontend and backend"
@echo " clean Clean node_modules and build artifacts"
@echo ""
@echo "Development:"
@echo " dev Start both frontend and backend in development mode"
@echo " dev-frontend Start frontend development server only"
@echo " dev-backend Start backend development server only"
@echo ""
@echo "Building:"
@echo " build Build both frontend and backend for production"
@echo " build-frontend Build frontend for production"
@echo " build-backend Build backend for production"
@echo ""
@echo "Testing:"
@echo " test Run tests for both frontend and backend"
@echo " test-frontend Run frontend tests"
@echo " test-backend Run backend tests"
@echo " test-coverage Run tests with coverage reports"
@echo ""
@echo "Code Quality:"
@echo " lint Run linting for both frontend and backend"
@echo " lint-frontend Run frontend linting"
@echo " lint-backend Run backend linting"
@echo ""
@echo "Production:"
@echo " run Run production build"
@echo " start Start production servers"
# Installation
install:
@echo "Installing dependencies..."
cd backend && npm install
cd frontend && npm install
@echo "Dependencies installed successfully!"
clean:
@echo "Cleaning up..."
rm -rf backend/node_modules
rm -rf frontend/node_modules
rm -rf frontend/build
rm -rf backend/dist
@echo "Cleanup complete!"
# Development
dev:
@echo "Starting development servers..."
@echo "Backend will start on http://localhost:5000"
@echo "Frontend will start on http://localhost:3000"
@echo "Press Ctrl+C to stop both servers"
@make -j2 dev-frontend dev-backend
dev-frontend:
@echo "Starting frontend development server..."
cd frontend && npm start
dev-backend:
@echo "Starting backend development server..."
cd backend && node server.js
# Building
build: build-frontend build-backend
@echo "Build complete!"
build-frontend:
@echo "Building frontend for production..."
cd frontend && npm run build
@echo "Frontend build complete!"
build-backend:
@echo "Backend is ready for production (no build step required for Node.js)"
@echo "Backend production files are in backend/"
# Testing
test: test-frontend test-backend
@echo "All tests completed!"
test-frontend:
@echo "Running frontend tests..."
cd frontend && npm test -- --watchAll=false --coverage
test-backend:
@echo "Running backend tests..."
cd backend && npm test
test-coverage:
@echo "Running tests with coverage..."
@echo "Backend coverage:"
cd backend && npm run test:coverage
@echo ""
@echo "Frontend coverage:"
cd frontend && npm run test:coverage
# Code Quality
lint: lint-frontend lint-backend
@echo "Linting complete!"
lint-frontend:
@echo "Linting frontend..."
cd frontend && npm run lint 2>/dev/null || echo "Frontend linting not configured"
lint-backend:
@echo "Linting backend..."
cd backend && npx eslint .
# Production
run: build
@echo "Starting production servers..."
@echo "Note: In production, you would typically use process managers like PM2"
@echo "or container orchestration like Kubernetes"
@echo "See deploy/ directory for Kubernetes deployment files"
start:
@echo "Starting production backend server..."
cd backend && NODE_ENV=production node server.js
# Docker (if needed)
docker-build:
@echo "Building Docker images..."
docker build -t adopt-a-street-frontend ./frontend
docker build -t adopt-a-street-backend ./backend
@echo "Docker images built!"
docker-run:
@echo "Running Docker containers..."
docker run -d -p 3000:3000 --name frontend adopt-a-street-frontend
docker run -d -p 5000:5000 --name backend adopt-a-street-backend
@echo "Docker containers running!"
# Multi-Architecture Docker
docker-multiarch-setup:
@echo "Setting up multi-architecture Docker builder..."
./scripts/setup-multiarch-builder.sh
docker-multiarch-build:
@echo "Building and pushing multi-architecture Docker images..."
./scripts/build-multiarch.sh
docker-multiarch-verify:
@echo "Verifying multi-architecture Docker images..."
./scripts/verify-multiarch.sh
docker-multiarch: docker-multiarch-setup docker-multiarch-build docker-multiarch-verify
@echo "Multi-architecture Docker workflow complete!"
# Database (for development)
db-setup:
@echo "Setting up MongoDB..."
@echo "Make sure MongoDB is installed and running on your system"
@echo "Or use Docker: docker run -d -p 27017:27017 --name mongodb mongo"
@echo "Create .env file in backend/ with MONGO_URI and JWT_SECRET"
# Environment setup
env-setup:
@echo "Setting up environment files..."
@if [ ! -f backend/.env ]; then \
echo "Creating backend/.env file..."; \
cp backend/.env.example backend/.env 2>/dev/null || echo "MONGO_URI=mongodb://localhost:27017/adopt-a-street\nJWT_SECRET=your-secret-key-here\nPORT=5000" > backend/.env; \
echo "Please edit backend/.env with your actual values"; \
else \
echo "backend/.env already exists"; \
fi
# Quick start for new developers
quick-start: install env-setup db-setup
@echo ""
@echo "Quick start complete!"
@echo ""
@echo "Next steps:"
@echo "1. Edit backend/.env with your MongoDB URI and JWT secret"
@echo "2. Run 'make dev' to start development servers"
@echo "3. Visit http://localhost:3000 to see the application"
@echo ""
@echo "For more commands, run 'make help'"
@echo ""
@echo "Docker Commands:"
@echo " docker-build Build single-architecture Docker images"
@echo " docker-run Run Docker containers"
@echo " docker-multiarch-setup Setup multi-architecture builder"
@echo " docker-multiarch-build Build and push multi-arch images"
@echo " docker-multiarch-verify Verify multi-arch images"
@echo " docker-multiarch Complete multi-arch workflow"