-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
123 lines (95 loc) · 4.03 KB
/
Copy pathMakefile
File metadata and controls
123 lines (95 loc) · 4.03 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
DEPLOY_ECR=411833189048.dkr.ecr.us-east-1.amazonaws.com
CLUSTER_NAME=forage-cluster
SERVICE_NAME=forage
BACKGROUND_WORKER_SERVICE_NAME=forage-worker-background
INTERACTIVE_WORKER_SERVICE_NAME=forage-worker-interactive
BEAT_SERVICE_NAME=forage-beat
build-dev:
docker build --platform linux/amd64 --provenance=false --target forage-dev -t forage-dev -f Dockerfile .
build-prod:
docker build --platform linux/amd64 --provenance=false --target forage-prod -t forage -f Dockerfile .
build: build-prod
push-prod:
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $(DEPLOY_ECR)
docker tag forage:latest $(DEPLOY_ECR)/forage
HTTPS_PROXY=http://http.docker.internal:3128 docker push $(DEPLOY_ECR)/forage
push: push-prod
deploy-app-prod:
aws ecs update-service --cluster $(CLUSTER_NAME) --service $(SERVICE_NAME) --force-new-deployment
deploy-workers: deploy-worker-background deploy-worker-interactive deploy-worker-beat
deploy-worker-background:
aws ecs update-service --cluster $(CLUSTER_NAME) --service $(BACKGROUND_WORKER_SERVICE_NAME) --force-new-deployment
deploy-worker-interactive:
aws ecs update-service --cluster $(CLUSTER_NAME) --service $(INTERACTIVE_WORKER_SERVICE_NAME) --force-new-deployment
deploy-worker-beat:
aws ecs update-service --cluster $(CLUSTER_NAME) --service $(BEAT_SERVICE_NAME) --force-new-deployment
deploy: deploy-all
deploy-all: deploy-app-prod deploy-workers
# Check deployment status
deploy-status:
@echo "=== Service Status ==="
@aws ecs describe-services --cluster $(CLUSTER_NAME) --services $(SERVICE_NAME) --query "services[0].{Status:status,RunningCount:runningCount,DesiredCount:desiredCount,PendingCount:pendingCount}" --output table
@echo "\n=== Recent Events ==="
@aws ecs describe-services --cluster $(CLUSTER_NAME) --services $(SERVICE_NAME) --query "services[0].events[0:3].[createdAt,message]" --output table
# Wait for deployment to complete (polls every 30 seconds)
deploy-wait:
@echo "Waiting for deployment to complete..."
@aws ecs wait services-stable --cluster $(CLUSTER_NAME) --services $(SERVICE_NAME)
@echo "Deployment completed successfully!"
# Full deploy with verification
deploy-and-wait: deploy deploy-wait deploy-status
clean:
rm -Rf build cache
docker image rm forage-dev:latest || true
docker image rm forage:latest || true
# Helper: get the first running task ID from the service.
TASK_ID=$(shell aws ecs list-tasks --cluster $(CLUSTER_NAME) --service-name $(SERVICE_NAME) --desired-status RUNNING --query "taskArns[0]" --output text)
# Open a bash shell on a running ECS container.
ecs-shell:
@echo "Opening a bash shell on task $(TASK_ID)..."
aws ecs execute-command \
--cluster $(CLUSTER_NAME) \
--task $(TASK_ID) \
--container forage \
--interactive \
--command "/bin/bash"
# Access PostgreSQL database in Docker container
db-shell:
docker compose exec db psql -U user -d forage
# Format everything (auto-fix)
format:
cd backend && ruff check --fix .
cd backend && ruff format .
npx prettier --write frontend/
./scripts/run-eslint.sh
# Lint everything (strict, no auto-fix)
lint:
cd backend && ruff check .
cd backend && mypy .
npx prettier --check frontend/
./scripts/run-eslint.sh
# Build frontend apps
build-frontend:
cd frontend && npm run build:all
# Type check Python files
mypy:
cd backend && mypy .
# Run backend tests
test:
cd backend && python -m pytest
# Run pre-commit on staged files (for dev convenience)
precommit:
pre-commit run --hook-stage pre-commit
# Install pre-commit and dev dependencies
install-dev:
@echo "Installing Python development dependencies..."
cd backend && python3 -m pip install -e .[dev]
@echo "Setting up pre-commit hooks..."
pre-commit install
@echo "Installing frontend dependencies..."
cd frontend && npm install
@echo "Setup complete!"
setup-db:
docker compose exec backend flask db upgrade
docker compose exec backend flask init-db
.PHONY: format lint test mypy precommit install-dev install-precommit deploy-all deploy-workers deploy-worker-background deploy-worker-interactive deploy-worker-beat