1- # ## This is the Terraform-generated header for browsertrix-harvester-dev. 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: =browsertrix-harvester-dev
5- ECR_URL_DEV: =222053980223.dkr.ecr.us-east-1.amazonaws.com/browsertrix-harvester-dev
6- # ## End of Terraform-generated header ###
1+ # ## This is the Terraform-generated header for browsertrix-harvester-dev. 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 := browsertrix-harvester-dev
5+ ECR_URL_DEV := 222053980223.dkr.ecr.us-east-1.amazonaws.com/browsertrix-harvester-dev
6+ CPU_ARCH ?= $(shell cat .aws-architecture 2>/dev/null || echo "linux/amd64")
7+ # ## End of Terraform-generated header ###
78SHELL =/bin/bash
89DATETIME: =$(shell date -u +% Y% m% dT% H% M% SZ)
910
4142 pipenv run ruff check .
4243
4344safety : # Check for security vulnerabilities and verify Pipfile.lock is up-to-date
44- pipenv run pip-audit
45+ pipenv run pip-audit --ignore-vuln GHSA-4xh5-x5gv-qwph
4546 pipenv verify
4647
4748# apply changes to resolve any linting errors
@@ -85,30 +86,46 @@ test-parse-url-content:
8586 --wacz-input-file=" tests/fixtures/example.wacz" \
8687 --url=" https://example.com/hello-world"
8788
89+
8890# ## Terraform-generated Developer Deploy Commands for Dev environment ###
89- dist-dev : # # Build docker container (intended for developer-based manual build)
90- docker build --platform linux/amd64 \
91- -t $(ECR_URL_DEV ) :latest \
92- -t $(ECR_URL_DEV ) :` git describe --always` \
93- -t $(ECR_NAME_DEV ) :latest .
91+ check-arch :
92+ @ARCH_FILE=" .aws-architecture" ; \
93+ if [[ " $( CPU_ARCH) " != " linux/amd64" && " $( CPU_ARCH) " != " linux/arm64" ]]; then \
94+ echo "Invalid CPU_ARCH : $(CPU_ARCH ) "; exit 1; \
95+ fi; \
96+ if [[ -f $$ARCH_FILE ]]; then \
97+ echo "latest-$(shell echo $(CPU_ARCH) | cut -d'/' -f2)" > .arch_tag; \
98+ else \
99+ echo "latest" > .arch_tag; \
100+ fi
101+
102+ dist-dev : check-arch # # Build docker container (intended for developer-based manual build)
103+ @ARCH_TAG=$$(cat .arch_tag ) ; \
104+ docker buildx inspect $(ECR_NAME_DEV ) > /dev/null 2>&1 || docker buildx create --name $(ECR_NAME_DEV ) --use; \
105+ docker buildx use $(ECR_NAME_DEV ) ; \
106+ docker buildx build --platform $(CPU_ARCH ) \
107+ --load \
108+ --tag $(ECR_URL_DEV ) :$$ ARCH_TAG \
109+ --tag $(ECR_URL_DEV ) :make-$$ ARCH_TAG \
110+ --tag $(ECR_URL_DEV ) :make-$(shell git describe --always) \
111+ --tag $(ECR_NAME_DEV ) :$$ ARCH_TAG \
112+ .
94113
95114publish-dev : dist-dev # # Build, tag and push (intended for developer-based manual publish)
96- docker login -u AWS -p $$(aws ecr get-login-password --region us-east-1 ) $(ECR_URL_DEV )
97- docker push $(ECR_URL_DEV ) :latest
98- docker push $(ECR_URL_DEV ) :` git describe --always`
99-
100- # ## Terraform-generated manual shortcuts for deploying to Stage. This requires ###
101- # ## that ECR_NAME_STAGE, ECR_URL_STAGE, and FUNCTION_STAGE environment ###
102- # ## variables are set locally by the developer and that the developer has ###
103- # ## authenticated to the correct AWS Account. The values for the environment ###
104- # ## variables can be found in the stage_build.yml caller workflow. ###
105- dist-stage : # # Only use in an emergency
106- docker build --platform linux/amd64 \
107- -t $(ECR_URL_STAGE ) :latest \
108- -t $(ECR_URL_STAGE ) :` git describe --always` \
109- -t $(ECR_NAME_STAGE ) :latest .
110-
111- publish-stage : # # Only use in an emergency
112- docker login -u AWS -p $$(aws ecr get-login-password --region us-east-1 ) $(ECR_URL_STAGE )
113- docker push $(ECR_URL_STAGE ) :latest
114- docker push $(ECR_URL_STAGE ) :` git describe --always`
115+ @ARCH_TAG=$$(cat .arch_tag ) ; \
116+ aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $(ECR_URL_DEV ) ; \
117+ docker push $(ECR_URL_DEV ) :$$ ARCH_TAG; \
118+ docker push $(ECR_URL_DEV ) :make-$$ ARCH_TAG; \
119+ docker push $(ECR_URL_DEV ) :make-$(shell git describe --always) ; \
120+ echo "Cleaning up dangling Docker images..."; \
121+ docker image prune -f --filter "dangling=true"
122+
123+ docker-clean : # # Clean up Docker detritus
124+ @ARCH_TAG=$$(cat .arch_tag ) ; \
125+ echo " Cleaning up Docker leftovers (containers, images, builders)" ; \
126+ docker rmi -f $(ECR_URL_DEV ) :$$ ARCH_TAG; \
127+ docker rmi -f $(ECR_URL_DEV ) :make-$$ ARCH_TAG; \
128+ docker rmi -f $(ECR_URL_DEV ) :make-$(shell git describe --always) || true ; \
129+ docker rmi -f $(ECR_NAME_DEV ) :$$ARCH_TAG || true; \
130+ docker buildx rm $(ECR_NAME_DEV ) || true
131+ @rm -rf .arch_tag
0 commit comments