🔧 Build Process Improvements: - Update default 'build' target to use development mode - Add new 'build-prod' target for production builds with validation - Fix 'deploy-prod-quick' to use production build command - Update 'build-test' to use development build (safer for CI) 📚 Documentation: - Add comprehensive Production Build Guide (docs/deployment/PRODUCTION_BUILD.md) - Include security requirements, configuration methods, and troubleshooting - Update main documentation index with production build guide - Update README with both build command options ✨ Features: - Development builds work without security configuration - Production builds require proper JWT/SESSION secrets - Clear separation between dev and prod build processes - Comprehensive production deployment documentation 🔒 Security: - Enforced JWT_SECRET validation for production builds - Clear documentation of required security configurations - Examples for CI/CD integration with proper secret management - Best practices for production deployment 🧪 Verification: - ✅ Development build: make build (works with warnings) - ✅ Production build validation: make build-prod (fails without secrets) - ✅ Production build with secrets: works correctly - ✅ All existing functionality preserved
217 lines
8.1 KiB
Makefile
217 lines
8.1 KiB
Makefile
# Makefile for Medication Reminder App
|
|
# Consolidated version with grouped targets and reduced redundancy
|
|
|
|
.PHONY: help install clean dev build test lint docker k8s
|
|
|
|
# Default target
|
|
.DEFAULT_GOAL := help
|
|
|
|
# Colors for output
|
|
BLUE := \033[34m
|
|
GREEN := \033[32m
|
|
YELLOW := \033[33m
|
|
RED := \033[31m
|
|
RESET := \033[0m
|
|
|
|
##@ General
|
|
|
|
help: ## Display this help message
|
|
@printf "$(BLUE)Medication Reminder App - Available Commands$(RESET)\n"
|
|
@printf "\n"
|
|
@awk 'BEGIN {FS = ":.*##"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " $(GREEN)%-20s$(RESET) %s\n", $$1, $$2 } /^##@/ { printf "\n$(YELLOW)%s$(RESET)\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
|
|
|
|
install: ## Install dependencies
|
|
@printf "$(BLUE)Installing dependencies...$(RESET)\n"
|
|
@bun install
|
|
|
|
clean: ## Clean build artifacts and dependencies
|
|
@printf "$(BLUE)Cleaning up...$(RESET)\n"
|
|
@rm -rf node_modules dist build .cache
|
|
|
|
reset: clean install ## Reset project (clean and reinstall)
|
|
@printf "$(GREEN)Project reset completed!$(RESET)\n"
|
|
|
|
##@ Development
|
|
|
|
dev: ## Start development server
|
|
@printf "$(BLUE)Starting development server...$(RESET)\n"
|
|
@bun run dev
|
|
|
|
build: ## Build the application for development
|
|
@printf "$(BLUE)Building application for development...$(RESET)\n"
|
|
@NODE_ENV=development bun run build
|
|
|
|
build-prod: ## Build the application for production
|
|
@printf "$(BLUE)Building application for production...$(RESET)\n"
|
|
@bun run build
|
|
|
|
preview: ## Preview the built application
|
|
@printf "$(BLUE)Starting preview server...$(RESET)\n"
|
|
@bun run preview
|
|
|
|
setup: ## Setup the project
|
|
@printf "$(BLUE)Setting up project...$(RESET)\n"
|
|
@bun run setup
|
|
|
|
##@ Testing & Quality
|
|
|
|
test: ## Run unit tests
|
|
@printf "$(BLUE)Running unit tests...$(RESET)\n"
|
|
@bun run test
|
|
|
|
test-watch: ## Run unit tests in watch mode
|
|
@printf "$(BLUE)Running tests in watch mode...$(RESET)\n"
|
|
@bun run test:watch
|
|
|
|
test-coverage: ## Run tests with coverage
|
|
@printf "$(BLUE)Running tests with coverage...$(RESET)\n"
|
|
@bun run test:coverage
|
|
|
|
test-integration: ## Run integration tests
|
|
@printf "$(BLUE)Running integration tests...$(RESET)\n"
|
|
@bun run test:integration
|
|
|
|
test-e2e: ## Run end-to-end tests
|
|
@printf "$(BLUE)Running e2e tests...$(RESET)\n"
|
|
@bun run test:e2e
|
|
|
|
test-e2e-ui: ## Run e2e tests with interactive UI
|
|
@printf "$(BLUE)Running e2e tests with UI...$(RESET)\n"
|
|
@bun run test:e2e:ui
|
|
|
|
test-auth-debug: ## Run authentication debug tests
|
|
@printf "$(BLUE)Running authentication debug tests...$(RESET)\n"
|
|
@bunx playwright test --config=tests/e2e/playwright.auth.config.ts
|
|
|
|
test-auth-debug-ui: ## Run authentication debug tests with UI
|
|
@printf "$(BLUE)Running authentication debug tests with UI...$(RESET)\n"
|
|
@bunx playwright test --config=tests/e2e/playwright.auth.config.ts --ui
|
|
|
|
test-all: ## Run all tests (unit + integration + e2e)
|
|
@printf "$(BLUE)Running all tests...$(RESET)\n"
|
|
@bun run test:all
|
|
|
|
lint: ## Run linting and fix issues
|
|
@printf "$(BLUE)Running linting checks...$(RESET)\n"
|
|
@bun run lint
|
|
@bun run lint:fix 2>/dev/null || true
|
|
|
|
pre-commit: ## Run pre-commit checks
|
|
@printf "$(BLUE)Running pre-commit checks...$(RESET)\n"
|
|
@bun run pre-commit
|
|
|
|
check: lint test-all ## Run complete quality check (lint + all tests)
|
|
@printf "$(GREEN)Quality check completed!$(RESET)\n"
|
|
|
|
##@ Docker
|
|
|
|
docker-build: ## Build Docker images (local and multi-platform)
|
|
@printf "$(BLUE)Building Docker images...$(RESET)\n"
|
|
@bun run docker:build-local
|
|
@bun run docker:build 2>/dev/null || true
|
|
|
|
docker-down: ## Stop and remove Docker containers
|
|
@printf "$(BLUE)Stopping Docker containers...$(RESET)\n"
|
|
@if docker-compose -f docker/docker-compose.yaml ps --services 2>/dev/null | grep -q .; then \
|
|
docker-compose -f docker/docker-compose.yaml down; \
|
|
printf "$(GREEN)Docker containers stopped$(RESET)\n"; \
|
|
else \
|
|
printf "$(YELLOW)No containers running$(RESET)\n"; \
|
|
fi
|
|
|
|
docker-clean: docker-down ## Stop containers and clean up volumes/images
|
|
@printf "$(BLUE)Cleaning Docker resources...$(RESET)\n"
|
|
@docker-compose -f docker/docker-compose.yaml down --volumes --remove-orphans 2>/dev/null || true
|
|
@docker image prune -f --filter "until=24h" 2>/dev/null || true
|
|
@docker volume prune -f 2>/dev/null || true
|
|
|
|
##@ Kubernetes Deployment
|
|
|
|
deploy-dev: ## Deploy to development environment
|
|
@printf "$(BLUE)Deploying to development...$(RESET)\n"
|
|
@kubectl apply -k k8s-kustomize/overlays/dev
|
|
|
|
deploy-prod: ## Deploy to production environment
|
|
@printf "$(BLUE)Deploying to production...$(RESET)\n"
|
|
@kubectl apply -k k8s-kustomize/overlays/prod
|
|
|
|
undeploy-dev: ## Remove development deployment
|
|
@printf "$(BLUE)Removing development deployment...$(RESET)\n"
|
|
@kubectl delete -k k8s-kustomize/overlays/dev --ignore-not-found=true
|
|
|
|
undeploy-prod: ## Remove production deployment
|
|
@printf "$(BLUE)Removing production deployment...$(RESET)\n"
|
|
@kubectl delete -k k8s-kustomize/overlays/prod --ignore-not-found=true
|
|
|
|
status-dev: ## Show development deployment status
|
|
@printf "$(BLUE)Development status...$(RESET)\n"
|
|
@kubectl get all -n rxminder-dev -l app=rxminder 2>/dev/null || printf "$(YELLOW)No development deployment found$(RESET)\n"
|
|
|
|
status-prod: ## Show production deployment status
|
|
@printf "$(BLUE)Production status...$(RESET)\n"
|
|
@kubectl get all -n rxminder-prod -l app=rxminder 2>/dev/null || printf "$(YELLOW)No production deployment found$(RESET)\n"
|
|
|
|
diff-dev: ## Show changes for development deployment
|
|
@printf "$(BLUE)Development diff...$(RESET)\n"
|
|
@kubectl diff -k k8s-kustomize/overlays/dev 2>/dev/null || true
|
|
|
|
diff-prod: ## Show changes for production deployment
|
|
@printf "$(BLUE)Production diff...$(RESET)\n"
|
|
@kubectl diff -k k8s-kustomize/overlays/prod 2>/dev/null || true
|
|
|
|
validate-k8s: ## Validate Kubernetes configurations
|
|
@printf "$(BLUE)Validating Kubernetes configs...$(RESET)\n"
|
|
@kubectl kustomize k8s-kustomize/overlays/dev | kubectl apply --dry-run=client --validate=true -f - >/dev/null
|
|
@kubectl kustomize k8s-kustomize/overlays/prod | kubectl apply --dry-run=client --validate=true -f - >/dev/null
|
|
@printf "$(GREEN)Kubernetes validation passed!$(RESET)\n"
|
|
|
|
##@ Configuration
|
|
|
|
generate-config: ## Generate configuration for all environments using unified config
|
|
@printf "$(BLUE)Generating unified configurations...$(RESET)\n"
|
|
@bun scripts/generate-unified-config.ts --all
|
|
@printf "$(GREEN)Unified configurations generated!$(RESET)\n"
|
|
|
|
generate-config-dev: ## Generate configuration for development environment
|
|
@printf "$(BLUE)Generating development configuration...$(RESET)\n"
|
|
@bun scripts/generate-unified-config.ts development
|
|
@printf "$(GREEN)Development configuration generated!$(RESET)\n"
|
|
|
|
generate-config-staging: ## Generate configuration for staging environment
|
|
@printf "$(BLUE)Generating staging configuration...$(RESET)\n"
|
|
@bun scripts/generate-unified-config.ts staging
|
|
@printf "$(GREEN)Staging configuration generated!$(RESET)\n"
|
|
|
|
generate-config-prod: ## Generate configuration for production environment
|
|
@printf "$(BLUE)Generating production configuration...$(RESET)\n"
|
|
@bun scripts/generate-unified-config.ts production
|
|
@printf "$(GREEN)Production configuration generated!$(RESET)\n"
|
|
|
|
validate-config: ## Validate unified configuration
|
|
@printf "$(BLUE)Validating unified configuration...$(RESET)\n"
|
|
@bun scripts/generate-unified-config.ts --dry-run
|
|
@printf "$(GREEN)Configuration validation completed!$(RESET)\n"
|
|
|
|
config-debug: ## Show current unified configuration (debug mode)
|
|
@printf "$(BLUE)Current unified configuration:$(RESET)\n"
|
|
@bun -e "import { logConfig } from './config/unified.config.ts'; logConfig();"
|
|
|
|
##@ Workflows
|
|
|
|
start: dev ## Alias for dev (start development server)
|
|
|
|
build-test: build test ## Build and run unit tests
|
|
@printf "$(GREEN)Build and test completed!$(RESET)\n"
|
|
|
|
deploy-dev-quick: build deploy-dev ## Build and deploy to development
|
|
@printf "$(GREEN)Quick development deployment completed!$(RESET)\n"
|
|
|
|
deploy-prod-quick: build-prod deploy-prod ## Build and deploy to production
|
|
@printf "$(GREEN)Quick production deployment completed!$(RESET)\n"
|
|
|
|
undeploy-all: undeploy-dev undeploy-prod docker-clean ## Remove all deployments and clean Docker
|
|
@printf "$(GREEN)Complete cleanup completed!$(RESET)\n"
|
|
|
|
ci-check: check validate-k8s ## Complete CI/CD validation pipeline
|
|
@printf "$(GREEN)CI/CD checks passed!$(RESET)\n"
|