-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
83 lines (65 loc) · 2.92 KB
/
Makefile
File metadata and controls
83 lines (65 loc) · 2.92 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
.PHONY: help
help: ## Print this message
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-24s\033[0m %s\n", $$1, $$2}'
install: ## Install Python dependencies
pip install -U -e .[dev]
debug: ## Run Flask app with FLASK_DEBUG=1
FLASK_APP=policyengine_household_api.api FLASK_DEBUG=1 flask run --without-threads --host=0.0.0.0
test: ## Run unit tests
pytest -vv --timeout=150 -rP .github/scripts tests/to_refactor tests/unit
test-with-auth: ## Run integration tests
CONFIG_FILE=config/test_with_auth.yaml pytest -vv --timeout=150 -rP tests/integration_with_auth
debug-test: ## Run tests with FLASK_DEBUG=1
FLASK_DEBUG=1 pytest -vv --durations=0 --timeout=150 -rP tests
format: ## Format code with Ruff
ruff format .
format-check: ## Check code formatting with Ruff
ruff format --check .
deploy: ## Deploy to GCP
python gcp/export.py
gcloud config set app/cloud_build_timeout 1800
cp gcp/policyengine_household_api/* .
y | gcloud app deploy --service-account=github-deployment@policyengine-household-api.iam.gserviceaccount.com
rm app.yaml
rm Dockerfile
rm .gac.json
changelog: ## Build changelog
python .github/scripts/update_versioning.py
COMPOSE_FILE ?= docker/docker-compose.yml
COMPOSE_EXTERNAL_FILE ?= docker/docker-compose.external.yml
DOCKER_IMG ?= policyengine:policyengine-household-api
DOCKER_NAME ?= policyengine-household-api
ifeq (, $(shell which docker))
DOCKER_CONTAINER_ID := docker-is-not-installed
else
DOCKER_CONTAINER_ID := $(shell docker ps --filter ancestor=$(DOCKER_IMG) --format "{{.ID}}")
endif
DOCKER_NETWORK ?= policyengine-api_default
DOCKER_CONSOLE ?= policyengine-api-console
.PHONY: docker-build
docker-build: ## Build the docker image
docker compose --file $(COMPOSE_FILE) build --force-rm
.PHONY: docker-run
docker-run: ## Run the app as docker container with supporting services
docker compose --file $(COMPOSE_FILE) up
.PHONY: docker-run-external
docker-run-external: ## Run with external network (for multi-service setups)
docker compose --file $(COMPOSE_FILE) --file $(COMPOSE_EXTERNAL_FILE) up
.PHONY: services-start
services-start: ## Run the docker containers for supporting services (e.g. Redis)
docker compose --file $(COMPOSE_FILE) up -d redis
.PHONY: services-start-external
services-start-external: ## Start services with external network
docker compose --file $(COMPOSE_FILE) --file $(COMPOSE_EXTERNAL_FILE) up -d redis
.PHONY: services-stop
services-stop: ## Stop the docker containers for supporting services
docker compose --file $(COMPOSE_FILE) down
.PHONY: docker-network-create
docker-network-create: ## Create the external Docker network (for multi-service setups)
docker network create $(DOCKER_NETWORK) || true
.PHONY: docker-console
docker-console: ## Open a one-off container bash session
@docker run -p 8080:5000 -v $(PWD):/code \
--network $(DOCKER_NETWORK) \
--rm --name $(DOCKER_CONSOLE) -it \
$(DOCKER_IMG) bash