2022-01-13 11:41:17 +00:00
|
|
|
REGISTRY := public.ecr.aws/zero-downtime
|
|
|
|
REPOSITORY := jenkins-podman
|
2022-01-18 23:22:21 +00:00
|
|
|
REGION := us-east-1
|
2022-01-15 23:19:44 +00:00
|
|
|
|
|
|
|
# Parse version from latest git semver tag
|
2022-01-18 23:22:21 +00:00
|
|
|
GTAG=$(shell git describe --tags --match v*.*.* 2>/dev/null || git rev-parse --short HEAD 2>/dev/null)
|
2022-01-15 23:19:44 +00:00
|
|
|
TAG ?= $(shell echo $(GTAG) | awk -F '-' '{ print $$1 "-" $$2 }' | sed -e 's/-$$//')
|
2022-01-13 11:41:17 +00:00
|
|
|
|
2022-01-13 15:53:54 +00:00
|
|
|
ifeq ($(TRIVY_REMOTE),)
|
|
|
|
TRIVY_OPTS := image
|
|
|
|
else
|
|
|
|
TRIVY_OPTS := client --remote ${TRIVY_REMOTE}
|
|
|
|
endif
|
|
|
|
|
2022-01-18 23:22:21 +00:00
|
|
|
.PHONY: build push scan test
|
2022-01-13 11:41:17 +00:00
|
|
|
|
|
|
|
all: build
|
|
|
|
|
|
|
|
build:
|
2022-01-18 23:22:21 +00:00
|
|
|
podman build --rm --squash-all -t $(REPOSITORY):$(TAG) -t $(REPOSITORY):latest .
|
2022-01-13 11:41:17 +00:00
|
|
|
|
|
|
|
push:
|
2022-01-18 23:22:21 +00:00
|
|
|
aws ecr-public get-login-password --region $(REGION) | podman login --username AWS --password-stdin $(REGISTRY)
|
2022-01-15 23:19:44 +00:00
|
|
|
podman tag $(REPOSITORY):latest $(REGISTRY)/$(REPOSITORY):$(TAG) $(REGISTRY)/$(REPOSITORY):latest
|
|
|
|
podman push $(REGISTRY)/$(REPOSITORY):$(TAG)
|
|
|
|
podman push $(REGISTRY)/$(REPOSITORY):latest
|
2022-02-03 18:29:47 +00:00
|
|
|
# Delete all untagged images
|
|
|
|
# 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-01-13 11:41:17 +00:00
|
|
|
|
|
|
|
scan:
|
2022-01-15 23:35:26 +00:00
|
|
|
trivy $(TRIVY_OPTS) $(REPOSITORY):$(TAG)
|
2022-01-16 10:55:02 +00:00
|
|
|
|
|
|
|
test:
|
2022-01-18 23:22:21 +00:00
|
|
|
@echo "Not implemented (yet)"
|