mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 10:21:14 -05:00
streamline makefile
This commit is contained in:
92
Makefile
92
Makefile
@@ -7,8 +7,6 @@ APP_VERSION_FILE = app/version.py
|
||||
GIT_BRANCH ?= $(shell git symbolic-ref --short HEAD 2> /dev/null || echo "detached")
|
||||
GIT_COMMIT ?= $(shell git rev-parse HEAD)
|
||||
|
||||
CF_API ?= api.cloud.service.gov.uk
|
||||
CF_ORG ?= govuk-notify
|
||||
CF_SPACE ?= ${DEPLOY_ENV}
|
||||
CF_HOME ?= ${HOME}
|
||||
$(eval export CF_HOME)
|
||||
@@ -90,24 +88,6 @@ clean:
|
||||
|
||||
## DEPLOYMENT
|
||||
|
||||
.PHONY: preview
|
||||
preview: ## Set environment to preview
|
||||
$(eval export DEPLOY_ENV=preview)
|
||||
$(eval export DNS_NAME="notify.works")
|
||||
@true
|
||||
|
||||
.PHONY: staging
|
||||
staging: ## Set environment to staging
|
||||
$(eval export DEPLOY_ENV=staging)
|
||||
$(eval export DNS_NAME="staging-notify.works")
|
||||
@true
|
||||
|
||||
.PHONY: production
|
||||
production: ## Set environment to production
|
||||
$(eval export DEPLOY_ENV=production)
|
||||
$(eval export DNS_NAME="notifications.service.gov.uk")
|
||||
@true
|
||||
|
||||
.PHONY: cf-login
|
||||
cf-login: ## Log in to Cloud Foundry
|
||||
$(if ${CF_USERNAME},,$(error Must specify CF_USERNAME))
|
||||
@@ -116,64 +96,40 @@ cf-login: ## Log in to Cloud Foundry
|
||||
@echo "Logging in to Cloud Foundry on ${CF_API}"
|
||||
@cf login -a "${CF_API}" -u ${CF_USERNAME} -p "${CF_PASSWORD}" -o "${CF_ORG}" -s "${CF_SPACE}"
|
||||
|
||||
.PHONY: cf-deploy
|
||||
cf-deploy: ## Deploys the app to Cloud Foundry
|
||||
$(if ${CF_SPACE},,$(error Must specify CF_SPACE))
|
||||
$(if ${CF_APP},,$(error Must specify CF_APP))
|
||||
cf target -o ${CF_ORG} -s ${CF_SPACE}
|
||||
@cf app --guid ${CF_APP} || exit 1
|
||||
|
||||
# cancel any existing deploys to ensure we can apply manifest (if a deploy is in progress you'll see ScaleDisabledDuringDeployment)
|
||||
cf cancel-deployment ${CF_APP} || true
|
||||
|
||||
# fails after 15 mins if deploy doesn't work
|
||||
CF_STARTUP_TIMEOUT=15 cf push ${CF_APP} --strategy=rolling
|
||||
|
||||
.PHONY: cf-deploy-api-db-migration
|
||||
cf-deploy-api-db-migration:
|
||||
$(if ${CF_SPACE},,$(error Must specify CF_SPACE))
|
||||
cf target -o ${CF_ORG} -s ${CF_SPACE}
|
||||
make -s CF_APP=notifications-api generate-manifest > ${CF_MANIFEST_PATH}
|
||||
|
||||
cf push notifications-api --no-route -f ${CF_MANIFEST_PATH}
|
||||
rm ${CF_MANIFEST_PATH}
|
||||
|
||||
cf run-task notifications-api --command="flask db upgrade" --name api_db_migration
|
||||
|
||||
.PHONY: cf-check-api-db-migration-task
|
||||
cf-check-api-db-migration-task: ## Get the status for the last notifications-api task
|
||||
@cf curl /v3/apps/`cf app --guid notifications-api`/tasks?order_by=-created_at | jq -r ".resources[0].state"
|
||||
|
||||
.PHONY: cf-rollback
|
||||
cf-rollback: ## Rollbacks the app to the previous release
|
||||
$(if ${CF_APP},,$(error Must specify CF_APP))
|
||||
rm ${CF_MANIFEST_PATH}
|
||||
cf cancel-deployment ${CF_APP}
|
||||
# .PHONY: cf-rollback
|
||||
# cf-rollback: ## Rollbacks the app to the previous release
|
||||
# $(if ${CF_APP},,$(error Must specify CF_APP))
|
||||
# rm ${CF_MANIFEST_PATH}
|
||||
# cf cancel-deployment ${CF_APP}
|
||||
|
||||
.PHONY: check-if-migrations-to-run
|
||||
check-if-migrations-to-run:
|
||||
@echo $(shell python3 scripts/check_if_new_migration.py)
|
||||
|
||||
.PHONY: cf-deploy-failwhale
|
||||
cf-deploy-failwhale:
|
||||
$(if ${CF_SPACE},,$(error Must target space, eg `make preview cf-deploy-failwhale`))
|
||||
cd ./paas-failwhale; cf push notify-api-failwhale -f manifest.yml
|
||||
# .PHONY: cf-deploy-failwhale
|
||||
# cf-deploy-failwhale:
|
||||
# $(if ${CF_SPACE},,$(error Must target space, eg `make preview cf-deploy-failwhale`))
|
||||
# cd ./paas-failwhale; cf push notify-api-failwhale -f manifest.yml
|
||||
|
||||
.PHONY: enable-failwhale
|
||||
enable-failwhale: ## Enable the failwhale app and disable api
|
||||
$(if ${DNS_NAME},,$(error Must target space, eg `make preview enable-failwhale`))
|
||||
# make sure failwhale is running first
|
||||
cf start notify-api-failwhale
|
||||
# .PHONY: enable-failwhale
|
||||
# enable-failwhale: ## Enable the failwhale app and disable api
|
||||
# $(if ${DNS_NAME},,$(error Must target space, eg `make preview enable-failwhale`))
|
||||
# # make sure failwhale is running first
|
||||
# cf start notify-api-failwhale
|
||||
|
||||
cf map-route notify-api-failwhale ${DNS_NAME} --hostname api
|
||||
cf unmap-route notify-api ${DNS_NAME} --hostname api
|
||||
@echo "Failwhale is enabled"
|
||||
# cf map-route notify-api-failwhale ${DNS_NAME} --hostname api
|
||||
# cf unmap-route notify-api ${DNS_NAME} --hostname api
|
||||
# @echo "Failwhale is enabled"
|
||||
|
||||
.PHONY: disable-failwhale
|
||||
disable-failwhale: ## Disable the failwhale app and enable api
|
||||
$(if ${DNS_NAME},,$(error Must target space, eg `make preview disable-failwhale`))
|
||||
# .PHONY: disable-failwhale
|
||||
# disable-failwhale: ## Disable the failwhale app and enable api
|
||||
# $(if ${DNS_NAME},,$(error Must target space, eg `make preview disable-failwhale`))
|
||||
|
||||
cf map-route notify-api ${DNS_NAME} --hostname api
|
||||
cf unmap-route notify-api-failwhale ${DNS_NAME} --hostname api
|
||||
cf stop notify-api-failwhale
|
||||
@echo "Failwhale is disabled"
|
||||
# cf map-route notify-api ${DNS_NAME} --hostname api
|
||||
# cf unmap-route notify-api-failwhale ${DNS_NAME} --hostname api
|
||||
# cf stop notify-api-failwhale
|
||||
# @echo "Failwhale is disabled"
|
||||
|
||||
Reference in New Issue
Block a user