Skip to content

Modern Docker Management, Designed for Everyone

chore: add aws publishing

Kyle Mendell796409b32f0b
diff --git a/.depot/actions/publish-images/action.yml b/.depot/actions/publish-images/action.yml
index 05b4f46b8..ffb8a9c94 100644
--- a/.depot/actions/publish-images/action.yml
+++ b/.depot/actions/publish-images/action.yml
@@ -37,12 +37,14 @@ runs:
registry: ${{ inputs.registry }}
username: ${{ inputs.username }}
password: ${{ inputs.password }}
+ env:
+ AWS_REGION: us-east-1
- name: Validate destination registry
shell: bash
run: |
case '${{ inputs.registry }}' in
- ghcr.io|docker.io|quay.io) ;;
+ ghcr.io|docker.io|quay.io|public.ecr.aws) ;;
*) echo 'Unsupported image registry' >&2; exit 1 ;;
esac
diff --git a/.depot/workflows/build-next-images.yml b/.depot/workflows/build-next-images.yml
index ad68d8f0a..79371b751 100644
--- a/.depot/workflows/build-next-images.yml
+++ b/.depot/workflows/build-next-images.yml
@@ -124,6 +124,9 @@ jobs:
- registry: quay.io
username-secret: QUAY_USERNAME
password-secret: QUAY_TOKEN
+ - registry: public.ecr.aws
+ username-secret: ECR_PUBLIC_ACCESS_KEY_ID
+ password-secret: ECR_PUBLIC_SECRET_ACCESS_KEY
steps:
- name: Checkout code
diff --git a/.depot/workflows/prune-ecr-public-next-images.yml b/.depot/workflows/prune-ecr-public-next-images.yml
new file mode 100644
index 000000000..2dcdda5e9
--- /dev/null
+++ b/.depot/workflows/prune-ecr-public-next-images.yml
@@ -0,0 +1,47 @@
+name: Prune ECR Public Next Images
+
+on:
+ schedule:
+ - cron: '17 4 * * *'
+ workflow_dispatch:
+
+concurrency:
+ group: prune-ecr-public-next-images
+ cancel-in-progress: false
+
+permissions: {}
+
+jobs:
+ prune:
+ runs-on:
+ size: 4x16
+ image: g7r5wqb57k.registry.depot.dev/ci:latest
+ env:
+ AWS_REGION: us-east-1
+ AWS_ACCESS_KEY_ID: ${{ secrets.ECR_PUBLIC_ACCESS_KEY_ID }}
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.ECR_PUBLIC_SECRET_ACCESS_KEY }}
+
+ steps:
+ - name: Login to ECR Public
+ uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
+ with:
+ registry: public.ecr.aws
+ username: ${{ secrets.ECR_PUBLIC_ACCESS_KEY_ID }}
+ password: ${{ secrets.ECR_PUBLIC_SECRET_ACCESS_KEY }}
+
+ - name: Delete stale next images
+ run: |
+ # Release and next tags stay; only untagged manifests no longer referenced by any tag are removed.
+ # ECR Public has no lifecycle policies, so this keeps overwritten next images from eating the free tier.
+ cutoff=$(date -u -d '1 hour ago' +%FT%T)
+ for repo in manager agent; do
+ aws ecr-public describe-images --repository-name "$repo" --output json > "$RUNNER_TEMP/images.json"
+ jq -r '.imageDetails[] | select(.imageTags) | .imageDigest' "$RUNNER_TEMP/images.json" > "$RUNNER_TEMP/tagged.txt"
+ while read -r digest; do
+ docker buildx imagetools inspect "public.ecr.aws/getarcaneapp/$repo@$digest" --raw | jq -r '.manifests[]?.digest'
+ done < "$RUNNER_TEMP/tagged.txt" | cat - "$RUNNER_TEMP/tagged.txt" | sort -u > "$RUNNER_TEMP/keep.txt"
+ jq -r --arg cutoff "$cutoff" '.imageDetails[] | select((.imageTags | not) and .imagePushedAt < $cutoff) | .imageDigest' "$RUNNER_TEMP/images.json" \
+ | sort -u | comm -23 - "$RUNNER_TEMP/keep.txt" > "$RUNNER_TEMP/delete.txt"
+ sed 's/^/imageDigest=/' "$RUNNER_TEMP/delete.txt" | xargs -r -n 100 aws ecr-public batch-delete-image --repository-name "$repo" --image-ids > /dev/null
+ echo "$repo: deleted $(wc -l < "$RUNNER_TEMP/delete.txt" | tr -d ' ') stale manifests" >> "$GITHUB_STEP_SUMMARY"
+ done
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index e0cd8e761..5fddc8f7b 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -179,6 +179,11 @@ jobs:
- registry: docker.io
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PAT }}
+ - registry: public.ecr.aws
+ username: ${{ secrets.ECR_PUBLIC_ACCESS_KEY_ID }}
+ password: ${{ secrets.ECR_PUBLIC_SECRET_ACCESS_KEY }}
+ env:
+ AWS_REGION: us-east-1
- name: Install Frontend Dependencies
run: just deps install frontend
diff --git a/.goreleaser.yaml b/.goreleaser.yaml
index 6db0273a1..3829ad47f 100644
--- a/.goreleaser.yaml
+++ b/.goreleaser.yaml
@@ -284,9 +284,11 @@ dockers_v2:
- '{{ if or (not (index .Env "IMAGE_REGISTRY")) (eq (index .Env "IMAGE_REGISTRY") "ghcr.io") }}ghcr.io/getarcaneapp/manager{{ end }}'
- '{{ if or (not (index .Env "IMAGE_REGISTRY")) (eq (index .Env "IMAGE_REGISTRY") "docker.io") }}getarcaneapp/manager{{ end }}'
- '{{ if or (not (index .Env "IMAGE_REGISTRY")) (eq (index .Env "IMAGE_REGISTRY") "quay.io") }}quay.io/getarcaneapp/manager{{ end }}'
+ - '{{ if or (not (index .Env "IMAGE_REGISTRY")) (eq (index .Env "IMAGE_REGISTRY") "public.ecr.aws") }}public.ecr.aws/getarcaneapp/manager{{ end }}'
tags:
- '{{ if index .Env "BUILD_NEXT" }}next{{ end }}'
- - 'v{{ .Version }}'
+ # ECR Public next builds publish only the moving next tag so nothing accumulates there
+ - '{{ if not (and (index .Env "BUILD_NEXT") (eq (index .Env "IMAGE_REGISTRY") "public.ecr.aws")) }}v{{ .Version }}{{ end }}'
- '{{ if not (index .Env "BUILD_NEXT") }}v{{ .Major }}.{{ .Minor }}{{ end }}'
- '{{ if not (index .Env "BUILD_NEXT") }}v{{ .Major }}{{ end }}'
- '{{ if not (index .Env "BUILD_NEXT") }}latest{{ end }}'
@@ -317,9 +319,11 @@ dockers_v2:
- '{{ if or (not (index .Env "IMAGE_REGISTRY")) (eq (index .Env "IMAGE_REGISTRY") "ghcr.io") }}ghcr.io/getarcaneapp/agent{{ end }}'
- '{{ if or (not (index .Env "IMAGE_REGISTRY")) (eq (index .Env "IMAGE_REGISTRY") "docker.io") }}getarcaneapp/agent{{ end }}'
- '{{ if or (not (index .Env "IMAGE_REGISTRY")) (eq (index .Env "IMAGE_REGISTRY") "quay.io") }}quay.io/getarcaneapp/agent{{ end }}'
+ - '{{ if or (not (index .Env "IMAGE_REGISTRY")) (eq (index .Env "IMAGE_REGISTRY") "public.ecr.aws") }}public.ecr.aws/getarcaneapp/agent{{ end }}'
tags:
- '{{ if index .Env "BUILD_NEXT" }}next{{ end }}'
- - 'v{{ .Version }}'
+ # ECR Public next builds publish only the moving next tag so nothing accumulates there
+ - '{{ if not (and (index .Env "BUILD_NEXT") (eq (index .Env "IMAGE_REGISTRY") "public.ecr.aws")) }}v{{ .Version }}{{ end }}'
- '{{ if not (index .Env "BUILD_NEXT") }}v{{ .Major }}.{{ .Minor }}{{ end }}'
- '{{ if not (index .Env "BUILD_NEXT") }}v{{ .Major }}{{ end }}'
- '{{ if not (index .Env "BUILD_NEXT") }}latest{{ end }}'