-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathMakefile
More file actions
77 lines (58 loc) · 2.39 KB
/
Makefile
File metadata and controls
77 lines (58 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
export AWS_ACCESS_KEY_ID ?= test
export AWS_SECRET_ACCESS_KEY ?= test
export AWS_DEFAULT_REGION = us-east-1
TERRAFORM_VERSION ?= 1.9.8
check: ## Check if all required prerequisites are installed
@command -v docker > /dev/null 2>&1 || { echo "Docker is not installed. Please install Docker and try again."; exit 1; }
@command -v terraform > /dev/null 2>&1 || { echo "Terraform is not installed. Please install Terraform and try again."; exit 1; }
@command -v localstack > /dev/null 2>&1 || { echo "LocalStack CLI is not installed. Please install it and try again."; exit 1; }
@command -v awslocal > /dev/null 2>&1 || { echo "awslocal is not installed. Please run: pip install awscli-local"; exit 1; }
@echo "All required prerequisites are available."
install-ci-dependencies:
@if ! command -v terraform > /dev/null 2>&1; then \
tmp_dir=$$(mktemp -d); \
curl -fsSL "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip" -o "$$tmp_dir/terraform.zip"; \
unzip -q "$$tmp_dir/terraform.zip" -d "$$tmp_dir"; \
sudo install -m 0755 "$$tmp_dir/terraform" /usr/local/bin/terraform; \
rm -rf "$$tmp_dir"; \
fi
init:
terraform workspace new local &
terraform workspace new aws &
terraform init
build:
docker build . --file Dockerfile-localstack --output .
build-aws:
docker build . --file Dockerfile-aws --output .
deploy:
docker compose up --detach
terraform workspace select local
AWS_ENDPOINT_URL=https://localhost.localstack.cloud:4566 terraform apply --auto-approve
deploy-aws:
terraform workspace select aws
terraform apply --auto-approve
run:
terraform workspace select local
./start_job.sh local
run-aws:
terraform workspace select aws
./start_job.sh aws
start: ## Start LocalStack
@test -n "${LOCALSTACK_AUTH_TOKEN}" || (echo "LOCALSTACK_AUTH_TOKEN is not set. Find your token at https://app.localstack.cloud/workspace/auth-token"; exit 1)
DEBUG=1 LOCALSTACK_AUTH_TOKEN=$(LOCALSTACK_AUTH_TOKEN) localstack start -d
stop:
docker compose down
logs:
@localstack logs > logs.txt
cat logs.txt
destroy:
terraform workspace select local
./stop-application.sh
terraform destroy --auto-approve
destroy-aws:
terraform workspace select aws
./stop-application.sh aws
terraform destroy --auto-approve
test-ci:
make install-ci-dependencies check init build deploy logs run; return_code=`echo $$?`;\
make logs; make stop; exit $$return_code;