|
| 1 | +### This is the Terraform-generated header for ${ecr_name}. If ### |
| 2 | +### this is a Lambda repo, uncomment the FUNCTION line below ### |
| 3 | +### and review the other commented lines in the document. ### |
| 4 | +ECR_NAME_DEV := ${ecr_name} |
| 5 | +ECR_URL_DEV := ${ecr_url} |
| 6 | +CPU_ARCH ?= $(shell cat .aws-architecture 2>/dev/null || echo "linux/amd64") |
| 7 | +# FUNCTION_DEV := ${function} |
| 8 | +### End of Terraform-generated header ### |
| 9 | + |
| 10 | + |
| 11 | +### Terraform-generated Developer Deploy Commands for Dev environment ### |
| 12 | +check-arch: |
| 13 | + @ARCH_FILE=".aws-architecture"; \ |
| 14 | + if [[ "$(CPU_ARCH)" != "linux/amd64" && "$(CPU_ARCH)" != "linux/arm64" ]]; then \ |
| 15 | + echo "Invalid CPU_ARCH: $(CPU_ARCH)"; exit 1; \ |
| 16 | + fi; \ |
| 17 | + if [[ -f $$ARCH_FILE ]]; then \ |
| 18 | + echo "latest-$(shell echo $(CPU_ARCH) | cut -d'/' -f2)" > .arch_tag; \ |
| 19 | + else \ |
| 20 | + echo "latest" > .arch_tag; \ |
| 21 | + fi |
| 22 | + |
| 23 | +dist-dev: check-arch ## Build docker container (intended for developer-based manual build) |
| 24 | + @ARCH_TAG=$$(cat .arch_tag); \ |
| 25 | + docker buildx inspect $(ECR_NAME_DEV) >/dev/null 2>&1 || docker buildx create --name $(ECR_NAME_DEV) --use; \ |
| 26 | + docker buildx use $(ECR_NAME_DEV); \ |
| 27 | + docker buildx build --platform $(CPU_ARCH) \ |
| 28 | + --load \ |
| 29 | + --tag $(ECR_URL_DEV):make-$$ARCH_TAG \ |
| 30 | + --tag $(ECR_URL_DEV):make-$(shell git describe --always) \ |
| 31 | + --tag $(ECR_NAME_DEV):$$ARCH_TAG \ |
| 32 | + . |
| 33 | + |
| 34 | +publish-dev: dist-dev ## Build, tag and push (intended for developer-based manual publish) |
| 35 | + @ARCH_TAG=$$(cat .arch_tag); \ |
| 36 | + aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $(ECR_URL_DEV); \ |
| 37 | + docker push $(ECR_URL_DEV):make-$$ARCH_TAG; \ |
| 38 | + docker push $(ECR_URL_DEV):make-$(shell git describe --always); \ |
| 39 | + docker push $(ECR_URL_DEV):make-$(shell echo $(CPU_ARCH) | cut -d'/' -f2) |
| 40 | + |
| 41 | +### If this is a Lambda repo, uncomment the two lines below ### |
| 42 | +# update-lambda-dev: ## Updates the lambda with whatever is the most recent image in the ecr (intended for developer-based manual update) |
| 43 | +# @ARCH_TAG=$$(cat .arch_tag); \ |
| 44 | +# aws lambda update-function-code \ |
| 45 | +# --region us-east-1 \ |
| 46 | +# --function-name $(FUNCTION_DEV) \ |
| 47 | +# --image-uri $(ECR_URL_DEV):make-$$ARCH_TAG |
| 48 | + |
| 49 | +docker-clean: ## Clean up Docker detritus |
| 50 | + @ARCH_TAG=$$(cat .arch_tag); \ |
| 51 | + echo "Cleaning up Docker leftovers (containers, images, builders)"; \ |
| 52 | + docker rmi -f $(ECR_URL_DEV):make-$$ARCH_TAG; \ |
| 53 | + docker rmi -f $(ECR_URL_DEV):make-$(shell git describe --always) || true; \ |
| 54 | + docker rmi -f $(ECR_URL_DEV):make-$(shell echo $(CPU_ARCH) | cut -d'/' -f2) || true; \ |
| 55 | + docker rmi -f $(ECR_NAME_DEV):$$ARCH_TAG || true; \ |
| 56 | + docker buildx rm $(ECR_NAME_DEV) || true |
| 57 | + @rm -rf .arch_tag |
0 commit comments