2021-09-23 17:27:06 +00:00
|
|
|
REGISTRY := public.ecr.aws/zero-downtime
|
|
|
|
REPOSITORY := cloudbender
|
2022-02-08 12:49:08 +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
|
2021-09-23 17:27:06 +00:00
|
|
|
|
2022-02-08 13:14:24 +00:00
|
|
|
.PHONY: pytest build test_upload upload all dev_setup pybuild
|
2019-06-18 16:48:39 +00:00
|
|
|
|
2022-02-08 13:14:24 +00:00
|
|
|
all: pybuild pytest
|
2019-02-07 22:05:33 +00:00
|
|
|
|
2021-09-23 17:27:06 +00:00
|
|
|
dev_setup:
|
2022-02-08 13:14:24 +00:00
|
|
|
pip install -r dev-requirements.txt --user
|
2021-09-23 17:27:06 +00:00
|
|
|
|
2022-02-08 13:14:24 +00:00
|
|
|
pytest:
|
2019-06-18 16:48:39 +00:00
|
|
|
flake8 --ignore=E501 cloudbender tests
|
|
|
|
TEST=True pytest --log-cli-level=DEBUG
|
2019-02-07 22:05:33 +00:00
|
|
|
|
|
|
|
clean:
|
2019-09-02 11:13:40 +00:00
|
|
|
rm -rf .cache build .coverage .eggs cloudbender.egg-info .pytest_cache dist
|
2019-06-18 16:48:39 +00:00
|
|
|
|
2022-02-08 13:14:24 +00:00
|
|
|
pybuild:
|
|
|
|
# Set version in Python
|
|
|
|
sed -i cloudbender/__init__.py -e 's/__version__.*/__version__ = "$(TAG)"/'
|
2019-02-07 22:05:33 +00:00
|
|
|
python setup.py bdist_wheel --universal
|
|
|
|
|
2019-06-18 16:48:39 +00:00
|
|
|
test_upload: $(PACKAGE_FILE)
|
2019-02-07 22:05:33 +00:00
|
|
|
twine upload --repository-url https://test.pypi.org/legacy/ dist/cloudbender-*.whl
|
|
|
|
|
2019-06-18 16:48:39 +00:00
|
|
|
upload: $(PACKAGE_FILE)
|
2021-02-22 18:38:44 +00:00
|
|
|
twine upload --repository-url https://upload.pypi.org/legacy/ dist/cloudbender-*.whl
|
2021-09-23 17:27:06 +00:00
|
|
|
|
2022-02-08 13:14:24 +00:00
|
|
|
build:
|
2022-02-08 12:49:08 +00:00
|
|
|
podman build --rm --squash-all -t $(REPOSITORY):$(TAG) -t $(REPOSITORY):latest .
|
2021-09-23 17:27:06 +00:00
|
|
|
|
2022-02-08 13:14:24 +00:00
|
|
|
test:
|
|
|
|
@echo "Not implemented (yet)"
|
|
|
|
|
2021-09-23 17:27:06 +00:00
|
|
|
push:
|
2022-02-08 12:49:08 +00:00
|
|
|
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
|
|
|
|
# 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)
|
2021-09-23 17:27:06 +00:00
|
|
|
|
|
|
|
scan:
|
2022-02-08 12:49:08 +00:00
|
|
|
trivy $(TRIVY_OPTS) $(REPOSITORY):$(TAG)
|