|
| 1 | +export AWS_ACCESS_KEY_ID ?= test |
| 2 | +export AWS_SECRET_ACCESS_KEY ?= test |
| 3 | +export AWS_DEFAULT_REGION=us-east-1 |
| 4 | +SHELL := /bin/bash |
| 5 | + |
| 6 | +## Show this help |
| 7 | +usage: |
| 8 | + @fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//' |
| 9 | + |
| 10 | +## Check if all required prerequisites are installed |
| 11 | +check: |
| 12 | + @command -v docker > /dev/null 2>&1 || { echo "Docker is not installed. Please install Docker and try again."; exit 1; } |
| 13 | + @command -v node > /dev/null 2>&1 || { echo "Node.js is not installed. Please install Node.js and try again."; exit 1; } |
| 14 | + @command -v localstack > /dev/null 2>&1 || { echo "LocalStack is not installed. Please install LocalStack and try again."; exit 1; } |
| 15 | + @command -v terraform > /dev/null 2>&1 || { echo "Terraform is not installed. Please install Terraform and try again."; exit 1; } |
| 16 | + @command -v tflocal > /dev/null 2>&1 || { echo "tflocal is not installed. Please install tflocal and try again."; exit 1; } |
| 17 | + @command -v mvn > /dev/null 2>&1 || { echo "Maven is not installed. Please install Maven and try again."; exit 1; } |
| 18 | + @command -v java > /dev/null 2>&1 || { echo "Java is not installed. Please install Java and try again."; exit 1; } |
| 19 | + @echo "All required prerequisites are available." |
| 20 | + |
| 21 | +## Install dependencies |
| 22 | +install: |
| 23 | + @echo "Installing dependencies..." |
| 24 | + cd shipment-picture-lambda-validator && mvn clean package shade:shade && cd .. |
| 25 | + @if [ ! -d "shipment-list-frontend/node_modules" ]; then \ |
| 26 | + echo "node_modules not found. Running npm install..."; \ |
| 27 | + cd shipment-list-frontend && npm install; \ |
| 28 | + fi |
| 29 | + @echo "All required dependencies are now available." |
| 30 | + |
| 31 | +## Deploy the infrastructure |
| 32 | +deploy: |
| 33 | + @echo "Deploying the infrastructure..." |
| 34 | + cd terraform && tflocal init && tflocal plan && tflocal apply --auto-approve |
| 35 | + @echo "Infrastructure deployed successfully." |
| 36 | + |
| 37 | +## Test the application |
| 38 | +test: |
| 39 | + @echo "Running the tests..." |
| 40 | + mvn test -Dtest=dev.ancaghenade.shipmentlistdemo.integrationtests.ShipmentServiceIntegrationTest |
| 41 | + @echo "Tests run successfully." |
| 42 | + |
| 43 | +## Run the application |
| 44 | +run: |
| 45 | + @echo "Running the Spring Boot application..." |
| 46 | + mvn spring-boot:run -Dspring-boot.run.profiles=dev |
| 47 | + |
| 48 | +## Run the React application |
| 49 | +frontend: |
| 50 | + @echo "Running the React application..." |
| 51 | + cd shipment-list-frontend && npm start |
| 52 | + |
| 53 | +## Start LocalStack in detached mode |
| 54 | +start: |
| 55 | + localstack start -d |
| 56 | + |
| 57 | +## Stop the Running LocalStack container |
| 58 | +stop: |
| 59 | + @echo |
| 60 | + localstack stop |
| 61 | + |
| 62 | +## Make sure the LocalStack container is up |
| 63 | +ready: |
| 64 | + @echo Waiting on the LocalStack container... |
| 65 | + @localstack wait -t 30 && echo LocalStack is ready to use! || (echo Gave up waiting on LocalStack, exiting. && exit 1) |
| 66 | + |
| 67 | +## Save the logs in a separate file |
| 68 | +logs: |
| 69 | + @localstack logs > logs.txt |
| 70 | + |
| 71 | +.PHONY: usage install check start ready deploy logs stop test |
0 commit comments