Skip to content

revamp the makefile target #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 64 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,38 +1,77 @@
export AWS_ACCESS_KEY_ID ?= test
export AWS_SECRET_ACCESS_KEY ?= test
export AWS_DEFAULT_REGION=us-east-1
SHELL := /bin/bash

include .env
## Show this help
usage:
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'

usage: ## Show this help
@grep -F -h "##" $(MAKEFILE_LIST) | grep -F -v grep -F | sed -e 's/\\$$//' -e 's/##//'
## Check if all required prerequisites are installed
check:
@command -v docker > /dev/null 2>&1 || { echo "Docker is not installed. Please install Docker and try again."; exit 1; }
@command -v localstack > /dev/null 2>&1 || { echo "LocalStack is not installed. Please install LocalStack and try again."; exit 1; }
@command -v aws > /dev/null 2>&1 || { echo "AWS CLI is not installed. Please install AWS CLI and try again."; exit 1; }
@command -v awslocal > /dev/null 2>&1 || { echo "awslocal is not installed. Please install awslocal and try again."; exit 1; }
@command -v python > /dev/null 2>&1 || { echo "Python is not installed. Please install Python and try again."; exit 1; }
@command -v jq > /dev/null 2>&1 || { echo "jq is not installed. Please install jq and try again."; exit 1; }
@echo "All required prerequisites are available."

## Install dependencies
install:
@echo "Installing dependencies..."
pip install virtualenv
virtualenv venv
bash -c "source venv/bin/activate && pip install -r requirements-dev.txt"
@echo "Dependencies installed successfully."

install: ## Install dependencies
@pip install -r requirements-dev.txt
## Build the Lambda functions
build-lambdas:
@echo "Building the Lambda functions..."
bash -c "source venv/bin/activate && bin/build_lambdas.sh"
@echo "Lambda functions built successfully."

build: ## Build lambdas in the lambdas folder
bin/build_lambdas.sh;
## Deploy the application locally using `awslocal`, a wrapper for the AWS CLI
deploy:
@echo "Deploying the application..."
@make build-lambdas
deployment/awslocal/deploy.sh
@echo "Application deployed successfully."

awslocal-setup: ## Deploy the application locally using `awslocal`, a wrapper for the AWS CLI
$(MAKE) build
deployment/awslocal/deploy.sh
## Deploy the application locally using `tflocal`, a wrapper for the Terraform CLI
deploy-terraform:
@command -v terraform > /dev/null 2>&1 || { echo "Terraform is not installed. Please install Terraform and try again."; exit 1; }
@which tflocal || pip install terraform-local
@echo "Deploying the application..."
@make build-lambdas
deployment/tflocal/deploy.sh
@echo "Application deployed successfully."

terraform-setup: ## Deploy the application locally using `tflocal`, a wrapper for Terraform CLI
$(MAKE) build
cd deployment/terraform; \
tflocal init; \
echo "Deploying Terraform configuration 🚀"; \
tflocal apply --auto-approve; \
echo "Paste the function URLs above to the WebApp 🎉";
## Run tests locally
test:
@echo "Running tests..."
bash -c "source venv/bin/activate && pytest tests"
@echo "Tests completed successfully."

terraform-destroy: ## Destroy all resources created locally using terraform scripts
cd deployment/terraform; \
tflocal destroy --auto-approve;
## Start LocalStack
start:
@echo "Starting LocalStack..."
@LOCALSTACK_AUTH_TOKEN=$(LOCALSTACK_AUTH_TOKEN) localstack start -d
@echo "LocalStack started successfully."

start: ## Start the LocalStack Pro container in the detached mode
@LOCALSTACK_AUTH_TOKEN=$(LOCALSTACK_AUTH_TOKEN) localstack start -d
## Stop LocalStack
stop:
@echo "Stopping LocalStack..."
@localstack stop
@echo "LocalStack stopped successfully."

stop: ## Stop the LocalStack Pro container
localstack stop
## Make sure the LocalStack container is up
ready:
@echo Waiting on the LocalStack container...
@localstack wait -t 30 && echo LocalStack is ready to use! || (echo Gave up waiting on LocalStack, exiting. && exit 1)

.PHONY: usage install build awslocal-setup terraform-setup terraform-destroy start stop
## Save the logs in a separate file
logs:
@localstack logs > logs.txt

.PHONY: usage install start ready build-lambdas deploy test logs stop