Skip to content

Commit

Permalink
Nd 159 dns dhcp product update makefiles (#766)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
laurentb4 authored Mar 11, 2024
1 parent 0c7fa06 commit 4625b16
Showing 1 changed file with 51 additions and 24 deletions.
75 changes: 51 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!make
.DEFAULT_GOAL := help
-include .env
export

Expand All @@ -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}'

0 comments on commit 4625b16

Please sign in to comment.