-
Notifications
You must be signed in to change notification settings - Fork 0
Update Deployment Workflows #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,57 @@ | ||
| ### This is the Terraform-generated prod-promote.yml workflow for the marimo-launcher-prod repository. ### | ||
| ### If this is a Lambda repo, uncomment the FUNCTION line at the end of the document. ### | ||
| ### This is the Terraform-generated prod-promote.yml workflow for the ### | ||
| ### marimo-launcher-prod repository. ### | ||
| ### If this is a Lambda repo, uncomment the FUNCTION line at the end of ### | ||
| ### the document. ### | ||
|
|
||
| name: Prod Container Promote | ||
| on: | ||
| workflow_dispatch: | ||
| release: | ||
| types: [published] | ||
|
|
||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
|
|
||
| jobs: | ||
| prep: | ||
| name: Prep for Promote | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| cpuarch: ${{ steps.setarch.outputs.cpuarch }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v5 | ||
|
|
||
| - name: Set CPU Architecture | ||
| id: setarch | ||
| run: | | ||
| echo "### :abacus: Architecture Selection" >> $GITHUB_STEP_SUMMARY | ||
| if [[ -f .aws-architecture ]]; then | ||
| ARCH=$(cat .aws-architecture) | ||
| echo "\`$ARCH\` was read from \`.aws-architecture\` and passed to the deploy job." >> $GITHUB_STEP_SUMMARY | ||
| else | ||
| ARCH="linux/amd64" | ||
| echo "No \`.aws-architecture\` file, so default \`$ARCH\` was passed to the deploy job." >> $GITHUB_STEP_SUMMARY | ||
| fi | ||
| if [[ "$ARCH" != "linux/arm64" && "$ARCH" != "linux/amd64" ]]; then | ||
| echo "$ARCH is INVALID architecture!" | ||
| echo "$ARCH is INVALID architecture!" >> $GITHUB_STEP_SUMMARY | ||
| exit 1 | ||
| fi | ||
| echo "cpuarch=$ARCH" >> $GITHUB_OUTPUT | ||
|
|
||
| deploy: | ||
| name: Prod Container Promote | ||
| uses: mitlibraries/.github/.github/workflows/ecr-shared-promote-prod.yml@main | ||
| needs: prep | ||
| name: Deploy | ||
| uses: mitlibraries/.github/.github/workflows/ecr-multi-arch-promote-prod.yml@main | ||
| secrets: inherit | ||
| with: | ||
| AWS_REGION: "us-east-1" | ||
| GHA_ROLE_STAGE: marimo-launcher-gha-stage | ||
| GHA_ROLE_PROD: marimo-launcher-gha-prod | ||
| ECR_STAGE: "marimo-launcher-stage" | ||
| ECR_PROD: "marimo-launcher-prod" | ||
| CPU_ARCH: ${{ needs.prep.outputs.cpuarch }} | ||
| # FUNCTION: "" | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,12 @@ | ||
| SHELL=/bin/bash | ||
| DATETIME:=$(shell date -u +%Y%m%dT%H%M%SZ) | ||
| ### This is the Terraform-generated header for marimo-launcher-dev. ### | ||
| ECR_NAME_DEV:=marimo-launcher-dev | ||
| ECR_URL_DEV:=222053980223.dkr.ecr.us-east-1.amazonaws.com/marimo-launcher-dev | ||
| ECR_NAME_DEV := marimo-launcher-dev | ||
| ECR_URL_DEV := 222053980223.dkr.ecr.us-east-1.amazonaws.com/marimo-launcher-dev | ||
| CPU_ARCH ?= $(shell cat .aws-architecture 2>/dev/null || echo "linux/amd64") | ||
| ### End of Terraform-generated header ### | ||
|
|
||
|
|
||
| help: # Preview Makefile commands | ||
| @awk 'BEGIN { FS = ":.*#"; print "Usage: make <target>\n\nTargets:" } \ | ||
| /^[-_[:alpha:]]+:.?*#/ { printf " %-15s%s\n", $$1, $$2 }' $(MAKEFILE_LIST) | ||
|
|
@@ -111,30 +113,54 @@ docker-test-run: # Test local docker container with test fixture notebook | |
| # Terraform | ||
| #################################### | ||
|
|
||
| ### Terraform-generated Developer Deploy Commands for Dev environment ### | ||
| dist-dev: ## Build docker container (intended for developer-based manual build) | ||
| docker build --platform linux/amd64 \ | ||
| -t $(ECR_URL_DEV):latest \ | ||
| -t $(ECR_URL_DEV):`git describe --always` \ | ||
| -t $(ECR_NAME_DEV):latest . | ||
| ### Terraform-generated Developer Deploy Commands for Dev environment ### | ||
| check-arch: | ||
| @ARCH_FILE=".aws-architecture"; \ | ||
| if [[ "$(CPU_ARCH)" != "linux/amd64" && "$(CPU_ARCH)" != "linux/arm64" ]]; then \ | ||
| echo "Invalid CPU_ARCH: $(CPU_ARCH)"; exit 1; \ | ||
| fi; \ | ||
| if [[ -f $$ARCH_FILE ]]; then \ | ||
| echo "latest-$(shell echo $(CPU_ARCH) | cut -d'/' -f2)" > .arch_tag; \ | ||
| else \ | ||
| echo "latest" > .arch_tag; \ | ||
| fi | ||
|
|
||
| dist-dev: check-arch ## Build docker container (intended for developer-based manual build) | ||
| @ARCH_TAG=$$(cat .arch_tag); \ | ||
| docker buildx inspect $(ECR_NAME_DEV) >/dev/null 2>&1 || docker buildx create --name $(ECR_NAME_DEV) --use; \ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cabutlermit - so you did end up going with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, I still ended up with |
||
| docker buildx use $(ECR_NAME_DEV); \ | ||
| docker buildx build --platform $(CPU_ARCH) \ | ||
| --load \ | ||
| --tag $(ECR_URL_DEV):$$ARCH_TAG \ | ||
| --tag $(ECR_URL_DEV):make-$$ARCH_TAG \ | ||
| --tag $(ECR_URL_DEV):make-$(shell git describe --always) \ | ||
| --tag $(ECR_NAME_DEV):$$ARCH_TAG \ | ||
| . | ||
|
|
||
| publish-dev: dist-dev ## Build, tag and push (intended for developer-based manual publish) | ||
| docker login -u AWS -p $$(aws ecr get-login-password --region us-east-1) $(ECR_URL_DEV) | ||
| docker push $(ECR_URL_DEV):latest | ||
| docker push $(ECR_URL_DEV):`git describe --always` | ||
|
|
||
| ### Terraform-generated manual shortcuts for deploying to Stage. This requires ### | ||
| ### that ECR_NAME_STAGE, ECR_URL_STAGE, and FUNCTION_STAGE environment ### | ||
| ### variables are set locally by the developer and that the developer has ### | ||
| ### authenticated to the correct AWS Account. The values for the environment ### | ||
| ### variables can be found in the stage_build.yml caller workflow. ### | ||
| dist-stage: ## Only use in an emergency | ||
| docker build --platform linux/amd64 \ | ||
| -t $(ECR_URL_STAGE):latest \ | ||
| -t $(ECR_URL_STAGE):`git describe --always` \ | ||
| -t $(ECR_NAME_STAGE):latest . | ||
|
|
||
| publish-stage: ## Only use in an emergency | ||
| docker login -u AWS -p $$(aws ecr get-login-password --region us-east-1) $(ECR_URL_STAGE) | ||
| docker push $(ECR_URL_STAGE):latest | ||
| docker push $(ECR_URL_STAGE):`git describe --always` | ||
| @ARCH_TAG=$$(cat .arch_tag); \ | ||
| aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $(ECR_URL_DEV); \ | ||
| docker push $(ECR_URL_DEV):$$ARCH_TAG; \ | ||
| docker push $(ECR_URL_DEV):make-$$ARCH_TAG; \ | ||
| docker push $(ECR_URL_DEV):make-$(shell git describe --always); \ | ||
| echo "Cleaning up dangling Docker images..."; \ | ||
| docker image prune -f --filter "dangling=true" | ||
|
|
||
|
|
||
| ### If this is a Lambda repo, uncomment the two lines below ### | ||
| # update-lambda-dev: ## Updates the lambda with whatever is the most recent image in the ecr (intended for developer-based manual update) | ||
| # @ARCH_TAG=$$(cat .arch_tag); \ | ||
| # aws lambda update-function-code \ | ||
| # --region us-east-1 \ | ||
| # --function-name $(FUNCTION_DEV) \ | ||
| # --image-uri $(ECR_URL_DEV):make-$$ARCH_TAG | ||
|
|
||
| docker-clean: ## Clean up Docker detritus | ||
| @ARCH_TAG=$$(cat .arch_tag); \ | ||
| echo "Cleaning up Docker leftovers (containers, images, builders)"; \ | ||
| docker rmi -f $(ECR_URL_DEV):$$ARCH_TAG; \ | ||
| docker rmi -f $(ECR_URL_DEV):make-$$ARCH_TAG; \ | ||
| docker rmi -f $(ECR_URL_DEV):make-$(shell git describe --always) || true; \ | ||
| docker rmi -f $(ECR_NAME_DEV):$$ARCH_TAG || true; \ | ||
| docker buildx rm $(ECR_NAME_DEV) || true | ||
| @rm -rf .arch_tag | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this
check-archcommand. After some cycles with all this, might be neat to weave this into eitherpre-commit, ormake lint, or something.