From 4625b167225d5210019d576e0b6b8a0cb0fcfd95 Mon Sep 17 00:00:00 2001 From: Lauren TB <162153408+laurentb4@users.noreply.github.com> Date: Mon, 11 Mar 2024 15:00:08 +0000 Subject: [PATCH] Nd 159 dns dhcp product update makefiles (#766) * Docker flag update ND-159 - added --platform flag to enable M* chips to build * Added descriptions for make help Added .phony descriptions for each stage in the makefile * Amend description Amended description of stop start stage in Makefile --- Makefile | 75 ++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index df548a71..efc74159 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ #!make +.DEFAULT_GOAL := help -include .env export @@ -12,67 +13,93 @@ BUNDLE_FLAGS= DOCKER_BUILD_CMD = BUNDLE_INSTALL_FLAGS="$(BUNDLE_FLAGS)" $(DOCKER_COMPOSE) build -authenticate-docker: check-container-registry-account-id +.PHONY: authenticate_docker +authenticate-docker: ## Authenticate docker script ./scripts/authenticate_docker.sh -build: - docker build -t admin . --build-arg RACK_ENV --build-arg DB_HOST --build-arg DB_USER --build-arg DB_PASS --build-arg SECRET_KEY_BASE --build-arg DB_NAME --build-arg BUNDLE_WITHOUT +.PHONY: build +build: ## docker build image + docker build --platform linux/amd64 -t admin . --build-arg RACK_ENV --build-arg DB_HOST --build-arg DB_USER --build-arg DB_PASS --build-arg SECRET_KEY_BASE --build-arg DB_NAME --build-arg BUNDLE_WITHOUT -build-dev: +.PHONY: build-dev +build-dev: ## build-dev image $(DOCKER_COMPOSE) build -start-db: +.PHONY: start-db +start-db: ## start database $(DOCKER_COMPOSE) up -d admin-db ENV=${ENV} ./scripts/wait_for_db.sh -db-setup: start-db +.PHONY: db-setup +db-setup: ## setup database + start-db $(DOCKER_COMPOSE) run --rm app ./bin/rails db:drop db:create db:schema:load -serve: stop start-db +.PHONY: serve +serve: ## Start application + stop + start-db $(DOCKER_COMPOSE) up app -run: serve +# TODO - this is potentially not needed, but we should check by running tests before removing +# run: serve -test: export ENV=test -test: +.PHONY: test +test: ## build and run tests + export ENV=test $(DOCKER_COMPOSE) run -e COVERAGE=true --rm app bundle exec rake -shell: +.PHONY: shell +shell: ## build and run tests in shell $(DOCKER_COMPOSE) run --rm app sh -shell-test: export ENV=test -shell-test: +.PHONY: shell-test +shell-test: ## build and run tests in shell with test variable + export ENV=test $(DOCKER_COMPOSE) run --rm app sh -stop: +.PHONY: stop +stop: ## docker compose down $(DOCKER_COMPOSE) down -migrate: +.PHONY: migrate +migrate: ## run migrate script ./scripts/migrate.sh -seed: +.PHONY: seed +seed: ## run seed script ./scripts/seed.sh -migrate-dev: start-db +.PHONY: migrate-dev +migrate-dev: ## run rails migrate dev $(DOCKER_COMPOSE) run --rm app bundle exec rake db:migrate -bootstrap: +.PHONY: bootstrap +bootstrap: ## run bootstrap script ./scripts/bootstrap.sh -deploy: +.PHONY: deploy +deploy: ## run deploy script ./scripts/deploy.sh -push: +.PHONY: push +push: ## push image to ECR aws ecr get-login-password | docker login --username AWS --password-stdin ${REGISTRY_URL} docker tag admin:latest ${REGISTRY_URL}/staff-device-${ENV}-dhcp-admin:latest docker push ${REGISTRY_URL}/staff-device-${ENV}-dhcp-admin:latest -publish: build push +.PHONY: publish +publish: ## run build and push targets + build + push -lint: +.PHONY: lint +lint: ## lint $(DOCKER_COMPOSE) run --rm app bundle exec rake standard:fix -implode: +.PHONY: implode +implode: ## remove docker container $(DOCKER_COMPOSE) rm -.PHONY: build serve stop test deploy migrate migrate-dev build-dev push publish implode authenticate-docker check-container-registry-account-id start-db db-setup run shell lint bootstrap +help: + @grep -h -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'