-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathMakefile
More file actions
106 lines (83 loc) · 3.53 KB
/
Makefile
File metadata and controls
106 lines (83 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
.PHONY: help start start-public stop setup setup-contrib import-profs import-course import-vacuum migrate test build-test docker-build-test logs clean
# Load environment variables
include .env
export
# Docker compose command with proper file configuration
DOCKER_COMPOSE := docker-compose -f docker-compose.yml -f docker-compose.dev.yml
DOCKER_COMPOSE_PUBLIC := docker-compose -f docker-compose.yml
help: ## Show this help message
@echo 'Usage: make [target]'
@echo ''
@echo 'Available targets:'
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " %-20s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
start: ## Start all backend services in development mode (without frontend)
@echo "Starting backend services in development mode..."
@$(DOCKER_COMPOSE) up -d api postgres hasura uw email
start-public: ## Start all services using public images
@echo "Pulling latest images..."
@$(DOCKER_COMPOSE_PUBLIC) pull
@echo "Starting services with public images..."
@$(DOCKER_COMPOSE_PUBLIC) up -d
stop: ## Stop all running services
@echo "Stopping all services..."
@docker-compose down
setup: ## Initialize database with backup data (maintainers)
@echo "Starting setup..."
@bash script/start.sh
@echo "Setup complete! Run 'make start' to start services."
setup-contrib: ## Initialize database from scratch using migrations and UW API (contributors)
@echo "Starting contributor setup..."
@bash script/setup-contrib.sh
import-profs: ## Import some dummy prof data
@echo "Importing professor data from production..."
@bash script/import-profs.sh
import-course: ## Run UW course importer job (rebuilds importer service)
@echo "Rebuilding and running course import job..."
@$(DOCKER_COMPOSE) up -d --build uw
@docker exec uw /app/uw hourly
@echo "Course import complete!"
import-vacuum: ## Run UW importer vacuum job (rebuilds importer service)
@echo "Rebuilding and running vacuum job..."
@$(DOCKER_COMPOSE) up -d --build uw
@docker exec uw /app/uw vacuum
@echo "Vacuum complete!"
migrate: ## Apply Hasura migrations
@echo "Applying Hasura migrations..."
@if ! command -v hasura >/dev/null 2>&1; then \
echo "Error: hasura CLI not found. Please install it first."; \
echo "Visit: https://hasura.io/docs/latest/hasura-cli/install-hasura-cli/"; \
exit 1; \
fi
@cd hasura && hasura migrate apply --admin-secret $(HASURA_GRAPHQL_ADMIN_SECRET)
@cd hasura && hasura metadata apply --admin-secret $(HASURA_GRAPHQL_ADMIN_SECRET)
migrate-status: ## Check Hasura migration status
@echo "Checking migration status..."
@cd hasura && hasura migrate status --admin-secret $(HASURA_GRAPHQL_ADMIN_SECRET)
test: ## Run Go tests
@echo "Running Go tests in container..."
@docker exec api go test ./...
@echo "Tests complete!"
build-test: ## Test Go build compilation
@echo "Testing Go build in container..."
@docker exec api go build ./...
@echo "Build test complete!"
docker-build-test: ## Dry run Docker Compose build
@echo "Testing Docker build (dry run)..."
$(DOCKER_COMPOSE) build --dry-run
@echo "Docker build test complete!"
logs: ## Tail logs from all services
@docker-compose logs -f
logs-api: ## Tail logs from API service
@docker logs -f api
logs-hasura: ## Tail logs from Hasura service
@docker logs -f hasura
logs-uw: ## Tail logs from UW importer service
@docker logs -f uw
logs-email: ## Tail logs from email service
@docker logs -f email
clean: ## Remove all containers, volumes, and reset environment
@echo "Cleaning up..."
@docker-compose down --remove-orphans --volumes
@echo "Clean complete!"
ps: ## Show status of all services
@docker-compose ps