|
1 | 1 | SHELL=/bin/bash |
2 | 2 | DATETIME:=$(shell date -u +%Y%m%dT%H%M%SZ) |
3 | 3 | ### This is the Terraform-generated header for marimo-launcher-dev. ### |
4 | | -ECR_NAME_DEV:=marimo-launcher-dev |
5 | | -ECR_URL_DEV:=222053980223.dkr.ecr.us-east-1.amazonaws.com/marimo-launcher-dev |
| 4 | +ECR_NAME_DEV := marimo-launcher-dev |
| 5 | +ECR_URL_DEV := 222053980223.dkr.ecr.us-east-1.amazonaws.com/marimo-launcher-dev |
| 6 | +CPU_ARCH ?= $(shell cat .aws-architecture 2>/dev/null || echo "linux/amd64") |
6 | 7 | ### End of Terraform-generated header ### |
7 | 8 |
|
| 9 | + |
8 | 10 | help: # Preview Makefile commands |
9 | 11 | @awk 'BEGIN { FS = ":.*#"; print "Usage: make <target>\n\nTargets:" } \ |
10 | 12 | /^[-_[:alpha:]]+:.?*#/ { printf " %-15s%s\n", $$1, $$2 }' $(MAKEFILE_LIST) |
@@ -111,30 +113,54 @@ docker-test-run: # Test local docker container with test fixture notebook |
111 | 113 | # Terraform |
112 | 114 | #################################### |
113 | 115 |
|
114 | | -### Terraform-generated Developer Deploy Commands for Dev environment ### |
115 | | -dist-dev: ## Build docker container (intended for developer-based manual build) |
116 | | - docker build --platform linux/amd64 \ |
117 | | - -t $(ECR_URL_DEV):latest \ |
118 | | - -t $(ECR_URL_DEV):`git describe --always` \ |
119 | | - -t $(ECR_NAME_DEV):latest . |
| 116 | +### Terraform-generated Developer Deploy Commands for Dev environment ### |
| 117 | +check-arch: |
| 118 | + @ARCH_FILE=".aws-architecture"; \ |
| 119 | + if [[ "$(CPU_ARCH)" != "linux/amd64" && "$(CPU_ARCH)" != "linux/arm64" ]]; then \ |
| 120 | + echo "Invalid CPU_ARCH: $(CPU_ARCH)"; exit 1; \ |
| 121 | + fi; \ |
| 122 | + if [[ -f $$ARCH_FILE ]]; then \ |
| 123 | + echo "latest-$(shell echo $(CPU_ARCH) | cut -d'/' -f2)" > .arch_tag; \ |
| 124 | + else \ |
| 125 | + echo "latest" > .arch_tag; \ |
| 126 | + fi |
| 127 | + |
| 128 | +dist-dev: check-arch ## Build docker container (intended for developer-based manual build) |
| 129 | + @ARCH_TAG=$$(cat .arch_tag); \ |
| 130 | + docker buildx inspect $(ECR_NAME_DEV) >/dev/null 2>&1 || docker buildx create --name $(ECR_NAME_DEV) --use; \ |
| 131 | + docker buildx use $(ECR_NAME_DEV); \ |
| 132 | + docker buildx build --platform $(CPU_ARCH) \ |
| 133 | + --load \ |
| 134 | + --tag $(ECR_URL_DEV):$$ARCH_TAG \ |
| 135 | + --tag $(ECR_URL_DEV):make-$$ARCH_TAG \ |
| 136 | + --tag $(ECR_URL_DEV):make-$(shell git describe --always) \ |
| 137 | + --tag $(ECR_NAME_DEV):$$ARCH_TAG \ |
| 138 | + . |
120 | 139 |
|
121 | 140 | publish-dev: dist-dev ## Build, tag and push (intended for developer-based manual publish) |
122 | | - docker login -u AWS -p $$(aws ecr get-login-password --region us-east-1) $(ECR_URL_DEV) |
123 | | - docker push $(ECR_URL_DEV):latest |
124 | | - docker push $(ECR_URL_DEV):`git describe --always` |
125 | | - |
126 | | -### Terraform-generated manual shortcuts for deploying to Stage. This requires ### |
127 | | -### that ECR_NAME_STAGE, ECR_URL_STAGE, and FUNCTION_STAGE environment ### |
128 | | -### variables are set locally by the developer and that the developer has ### |
129 | | -### authenticated to the correct AWS Account. The values for the environment ### |
130 | | -### variables can be found in the stage_build.yml caller workflow. ### |
131 | | -dist-stage: ## Only use in an emergency |
132 | | - docker build --platform linux/amd64 \ |
133 | | - -t $(ECR_URL_STAGE):latest \ |
134 | | - -t $(ECR_URL_STAGE):`git describe --always` \ |
135 | | - -t $(ECR_NAME_STAGE):latest . |
136 | | - |
137 | | -publish-stage: ## Only use in an emergency |
138 | | - docker login -u AWS -p $$(aws ecr get-login-password --region us-east-1) $(ECR_URL_STAGE) |
139 | | - docker push $(ECR_URL_STAGE):latest |
140 | | - docker push $(ECR_URL_STAGE):`git describe --always` |
| 141 | + @ARCH_TAG=$$(cat .arch_tag); \ |
| 142 | + aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $(ECR_URL_DEV); \ |
| 143 | + docker push $(ECR_URL_DEV):$$ARCH_TAG; \ |
| 144 | + docker push $(ECR_URL_DEV):make-$$ARCH_TAG; \ |
| 145 | + docker push $(ECR_URL_DEV):make-$(shell git describe --always); \ |
| 146 | + echo "Cleaning up dangling Docker images..."; \ |
| 147 | + docker image prune -f --filter "dangling=true" |
| 148 | + |
| 149 | + |
| 150 | +### If this is a Lambda repo, uncomment the two lines below ### |
| 151 | +# update-lambda-dev: ## Updates the lambda with whatever is the most recent image in the ecr (intended for developer-based manual update) |
| 152 | +# @ARCH_TAG=$$(cat .arch_tag); \ |
| 153 | +# aws lambda update-function-code \ |
| 154 | +# --region us-east-1 \ |
| 155 | +# --function-name $(FUNCTION_DEV) \ |
| 156 | +# --image-uri $(ECR_URL_DEV):make-$$ARCH_TAG |
| 157 | + |
| 158 | +docker-clean: ## Clean up Docker detritus |
| 159 | + @ARCH_TAG=$$(cat .arch_tag); \ |
| 160 | + echo "Cleaning up Docker leftovers (containers, images, builders)"; \ |
| 161 | + docker rmi -f $(ECR_URL_DEV):$$ARCH_TAG; \ |
| 162 | + docker rmi -f $(ECR_URL_DEV):make-$$ARCH_TAG; \ |
| 163 | + docker rmi -f $(ECR_URL_DEV):make-$(shell git describe --always) || true; \ |
| 164 | + docker rmi -f $(ECR_NAME_DEV):$$ARCH_TAG || true; \ |
| 165 | + docker buildx rm $(ECR_NAME_DEV) || true |
| 166 | + @rm -rf .arch_tag |
0 commit comments