@@ -2,12 +2,20 @@ SHELL=/bin/bash
22DATETIME: =$(shell date -u +% Y% m% dT% H% M% SZ)
33CPU_ARCH ?= $(shell cat .aws-architecture 2>/dev/null || echo "linux/amd64")
44
5+ # ## This is the Terraform-generated header for timdex-embeddings-dev. If ###
6+ # ## this is a Lambda repo, uncomment the FUNCTION line below ###
7+ # ## and review the other commented lines in the document. ###
8+ ECR_NAME_DEV := timdex-embeddings-dev
9+ ECR_URL_DEV := 222053980223.dkr.ecr.us-east-1.amazonaws.com/timdex-embeddings-dev
10+ CPU_ARCH ?= $(shell cat .aws-architecture 2>/dev/null || echo "linux/amd64")
11+ # ## End of Terraform-generated header ###
12+
513help : # Preview Makefile commands
614 @awk ' BEGIN { FS = ":.*#"; print "Usage: make <target>\n\nTargets:" } \
715/^[-_[ :alpha:]]+:.?* # / { printf " %-15s%s\n", $$1, $$2 }' $(MAKEFILE_LIST)
816
917# ensure OS binaries aren't called if naming conflict with Make recipes
10- .PHONY : help venv install update test coveralls lint black mypy ruff safety lint-apply black-apply ruff-apply
18+ .PHONY : help venv install update test coveralls lint black mypy ruff safety lint-apply black-apply ruff-apply check-arch dist-dev publish-dev docker-clean
1119
1220# #############################################
1321# Python Environment and Dependency commands
@@ -85,3 +93,47 @@ docker-shell: # Shell into local container for testing
8593
8694docker-run : # Run main entrypoint + command without arguments
8795 docker run timdex-embeddings:latest
96+
97+
98+ # ## Terraform-generated Developer Deploy Commands for Dev environment ###
99+ check-arch :
100+ @ARCH_FILE=" .aws-architecture" ; \
101+ if [[ " $( CPU_ARCH) " != " linux/amd64" && " $( CPU_ARCH) " != " linux/arm64" ]]; then \
102+ echo "Invalid CPU_ARCH : $(CPU_ARCH ) "; exit 1; \
103+ fi; \
104+ if [[ -f $$ARCH_FILE ]]; then \
105+ echo "latest-$(shell echo $(CPU_ARCH) | cut -d'/' -f2)" > .arch_tag; \
106+ else \
107+ echo "latest" > .arch_tag; \
108+ fi
109+
110+ dist-dev : check-arch # # Build docker container (intended for developer-based manual build)
111+ @ARCH_TAG=$$(cat .arch_tag ) ; \
112+ docker buildx inspect $(ECR_NAME_DEV ) > /dev/null 2>&1 || docker buildx create --name $(ECR_NAME_DEV ) --use; \
113+ docker buildx use $(ECR_NAME_DEV ) ; \
114+ docker buildx build --platform $(CPU_ARCH ) \
115+ --load \
116+ --tag $(ECR_URL_DEV ) :$$ ARCH_TAG \
117+ --tag $(ECR_URL_DEV ) :make-$$ ARCH_TAG \
118+ --tag $(ECR_URL_DEV ) :make-$(shell git describe --always) \
119+ --tag $(ECR_NAME_DEV ) :$$ ARCH_TAG \
120+ .
121+
122+ publish-dev : dist-dev # # Build, tag and push (intended for developer-based manual publish)
123+ @ARCH_TAG=$$(cat .arch_tag ) ; \
124+ aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $(ECR_URL_DEV ) ; \
125+ docker push $(ECR_URL_DEV ) :$$ ARCH_TAG; \
126+ docker push $(ECR_URL_DEV ) :make-$$ ARCH_TAG; \
127+ docker push $(ECR_URL_DEV ) :make-$(shell git describe --always) ; \
128+ echo "Cleaning up dangling Docker images..."; \
129+ docker image prune -f --filter "dangling=true"
130+
131+ docker-clean : # # Clean up Docker detritus
132+ @ARCH_TAG=$$(cat .arch_tag ) ; \
133+ echo " Cleaning up Docker leftovers (containers, images, builders)" ; \
134+ docker rmi -f $(ECR_URL_DEV ) :$$ ARCH_TAG; \
135+ docker rmi -f $(ECR_URL_DEV ) :make-$$ ARCH_TAG; \
136+ docker rmi -f $(ECR_URL_DEV ) :make-$(shell git describe --always) || true ; \
137+ docker rmi -f $(ECR_NAME_DEV ) :$$ARCH_TAG || true; \
138+ docker buildx rm $(ECR_NAME_DEV ) || true
139+ @rm -rf .arch_tag
0 commit comments