1- install :
1+ .PHONY : help
2+ help : # # Print this message
3+ @grep -E ' ^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | sort | awk ' BEGIN {FS = ":.*?## "}; {printf "\033[36m%-24s\033[0m %s\n", $$1, $$2}'
4+
5+ install : # # Install Python dependencies
26 pip install -U -e .[dev]
37
4- debug :
5- FLASK_APP=policyengine_household_api.api FLASK_DEBUG=1 flask run --without-threads
8+ debug : # # Run Flask app with FLASK_DEBUG=1
9+ FLASK_APP=policyengine_household_api.api FLASK_DEBUG=1 flask run --without-threads --host=0.0.0.0
610
7- test :
11+ test : # # Run unit tests
812 pytest -vv --timeout=150 -rP tests/to_refactor tests/unit
913
10- test-with-auth :
14+ test-with-auth : # # Run integration tests
1115 CONFIG_FILE=config/test_with_auth.yaml pytest -vv --timeout=150 -rP tests/integration_with_auth
1216
13- debug-test :
17+ debug-test : # # Run tests with FLASK_DEBUG=1
1418 FLASK_DEBUG=1 pytest -vv --durations=0 --timeout=150 -rP tests
1519
16- format :
20+ format : # # Run black
1721 black . -l 79
1822
19- deploy :
23+ deploy : # # Deploy to GCP
2024 python gcp/export.py
2125 gcloud config set app/cloud_build_timeout 1800
2226 cp gcp/policyengine_household_api/* .
@@ -25,9 +29,56 @@ deploy:
2529 rm Dockerfile
2630 rm .gac.json
2731
28- changelog :
32+ changelog : # # Build changelog
2933 build-changelog changelog.yaml --output changelog.yaml --update-last-date --start-from 0.1.0 --append-file changelog_entry.yaml
3034 build-changelog changelog.yaml --org PolicyEngine --repo policyengine-household-api --output CHANGELOG.md --template .github/changelog_template.md
3135 bump-version changelog.yaml setup.py policyengine_household_api/constants.py
3236 rm changelog_entry.yaml || true
33- touch changelog_entry.yaml
37+ touch changelog_entry.yaml
38+
39+ COMPOSE_FILE ?= docker/docker-compose.yml
40+ COMPOSE_EXTERNAL_FILE ?= docker/docker-compose.external.yml
41+ DOCKER_IMG ?= policyengine:policyengine-household-api
42+ DOCKER_NAME ?= policyengine-household-api
43+ ifeq (, $(shell which docker) )
44+ DOCKER_CONTAINER_ID := docker-is-not-installed
45+ else
46+ DOCKER_CONTAINER_ID := $(shell docker ps --filter ancestor=$(DOCKER_IMG ) --format "{{.ID}}")
47+ endif
48+ DOCKER_NETWORK ?= policyengine-api_default
49+ DOCKER_CONSOLE ?= policyengine-api-console
50+
51+ .PHONY : docker-build
52+ docker-build : # # Build the docker image
53+ docker compose --file $(COMPOSE_FILE ) build --force-rm
54+
55+ .PHONY : docker-run
56+ docker-run : # # Run the app as docker container with supporting services
57+ docker compose --file $(COMPOSE_FILE ) up
58+
59+ .PHONY : docker-run-external
60+ docker-run-external : # # Run with external network (for multi-service setups)
61+ docker compose --file $(COMPOSE_FILE ) --file $(COMPOSE_EXTERNAL_FILE ) up
62+
63+ .PHONY : services-start
64+ services-start : # # Run the docker containers for supporting services (e.g. Redis)
65+ docker compose --file $(COMPOSE_FILE ) up -d redis
66+
67+ .PHONY : services-start-external
68+ services-start-external : # # Start services with external network
69+ docker compose --file $(COMPOSE_FILE ) --file $(COMPOSE_EXTERNAL_FILE ) up -d redis
70+
71+ .PHONY : services-stop
72+ services-stop : # # Stop the docker containers for supporting services
73+ docker compose --file $(COMPOSE_FILE ) down
74+
75+ .PHONY : docker-network-create
76+ docker-network-create : # # Create the external Docker network (for multi-service setups)
77+ docker network create $(DOCKER_NETWORK ) || true
78+
79+ .PHONY : docker-console
80+ docker-console : # # Open a one-off container bash session
81+ @docker run -p 8080:5000 -v $(PWD ) :/code \
82+ --network $(DOCKER_NETWORK) \
83+ --rm --name $(DOCKER_CONSOLE) -it \
84+ $(DOCKER_IMG) bash
0 commit comments