sns-alert-hub/Makefile

45 lines
1.7 KiB
Makefile
Raw Normal View History

2022-02-09 11:22:59 +00:00
REGISTRY := public.ecr.aws/zero-downtime
2022-02-09 10:57:23 +00:00
REPOSITORY := sns-alert-hub
2022-02-09 11:22:59 +00:00
REGION := us-east-1
# Parse version from latest git semver tag
GTAG=$(shell git describe --tags --match v*.*.* 2>/dev/null || git rev-parse --short HEAD 2>/dev/null)
TAG ?= $(shell echo $(GTAG) | awk -F '-' '{ print $$1 "-" $$2 }' | sed -e 's/-$$//')
ifeq ($(TRIVY_REMOTE),)
TRIVY_OPTS := image
else
TRIVY_OPTS := client --remote ${TRIVY_REMOTE}
endif
.PHONY: build push scan test
all: build
build:
2022-02-09 22:24:12 +00:00
podman build --target release --rm -t $(REPOSITORY):$(TAG) -t $(REPOSITORY):latest .
2022-02-09 11:22:59 +00:00
push:
aws ecr-public get-login-password --region $(REGION) | podman login --username AWS --password-stdin $(REGISTRY)
podman tag $(REPOSITORY):latest $(REGISTRY)/$(REPOSITORY):$(TAG) $(REGISTRY)/$(REPOSITORY):latest
podman push $(REGISTRY)/$(REPOSITORY):$(TAG)
podman push $(REGISTRY)/$(REPOSITORY):latest
# Delete all untagged images
2022-02-09 10:57:23 +00:00
# aws ecr-public batch-delete-image --repository-name $(REPOSITORY) --region $(REGION) --image-ids $$(for image in $$(aws ecr-public describe-images --repository-name $(REPOSITORY) --region $(REGION) --output json | jq -r '.imageDetails[] | select(.imageTags | not ).imageDigest'); do echo -n "imageDigest=$$image "; done)
2022-02-09 11:22:59 +00:00
scan:
trivy $(TRIVY_OPTS) $(REPOSITORY):$(TAG)
test:
2022-02-09 22:24:12 +00:00
podman build --target test --rm -t $(REPOSITORY):$(TAG) -t $(REPOSITORY):latest .
2022-02-09 10:57:23 +00:00
aws_lambda:
@[ -z $(AWS_LAMBDA) ] && { echo "Missing aws-lambda-rie in PATH"; exit 1;} || true
run: aws_lambda
podman run --rm -v $(AWS_LAMBDA):/aws-lambda -p 8080:8080 --entrypoint /aws-lambda/aws-lambda-rie $(TAG) /usr/local/bin/python -m awslambdaric app.handler
dev: aws_lambda
cd app && aws-lambda-rie /usr/bin/python -m awslambdaric app.handler