Schedule icon
Webhook icon
Loop icon
Request icon
Script icon
If icon
SlackIncomingWebhook icon
OutputValues icon

Enforce Container Image Size Budgets on GHCR

Gate container image size with Kestra. Audit GHCR images against a budget and alert Slack on bloat.

Categories
Infrastructure

Bloated images slow pulls, scaling, and deploys. This blueprint audits a configurable list of GHCR container images every Monday morning, estimates each image footprint from package version metadata, and posts a Slack alert only when an image exceeds its size budget (default 1200MB). A webhook trigger enables on-demand audits after a base-image bump.

How it works

  1. weekly_audit (io.kestra.plugin.core.trigger.Schedule, cron 0 9 * * MON) launches the run; on_demand_webhook allows ad-hoc audits.
  2. audit_images (io.kestra.plugin.core.flow.Loop, concurrency 4) fans out across inputs.images.
  3. fetch_tags (io.kestra.plugin.core.http.Request) lists GHCR package versions with allowFailed: true.
  4. evaluate_budget (io.kestra.plugin.scripts.python.Script) estimates MB footprint and sets breached.
  5. alert_on_bloat (io.kestra.plugin.core.flow.If) posts to Slack (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) only on breach.
  6. emit_audit_metrics (io.kestra.plugin.core.output.OutputValues) exports audit coverage for history.

What you get

  • Weekly image-size report across any number of images.
  • Budget gate (default 1200MB) with Slack bloat alerts.
  • Remediation hints (multi-stage builds, slimmer bases).
  • Failure alert if the audit itself errors.

Who it's for

  • Platform teams owning base images and pull performance.
  • DevOps engineers fighting slow autoscaling from fat images.
  • Teams replacing ad-hoc docker images checks with code.

Prerequisites

  • A GitHub token with packages:read scope.
  • Slack Incoming Webhook URL.

Secrets

  • GITHUB_TOKEN: token used to read GHCR package metadata.
  • SLACK_WEBHOOK_URL: Slack Incoming Webhook for bloat and failure alerts.
  • WEBHOOK_KEY: auth key for the on-demand webhook trigger.

Quick start

  1. Set GITHUB_TOKEN, SLACK_WEBHOOK_URL, and WEBHOOK_KEY secrets.
  2. Edit images and size_budget_mb inputs.
  3. Run once manually to verify package access.
  4. Enable the weekly_audit schedule.

How to extend

  • Fail the execution on breach to gate promotions.
  • Track size trends in Postgres for burn-down charts.
  • Scan each tag with Trivy and join CVE counts to the report.

Links

Inputs

  • images (ARRAY of STRING): image refs in org/image format.
  • size_budget_mb (INT, default 1200): max allowed image size in MB.
  • slack_channel (STRING, default #platform): digest destination.

Outputs

  • emit_audit_metrics.values.images_audited: number of images audited.
  • emit_audit_metrics.values.audited_at: run timestamp for reports.
See How

New to Kestra?

Use blueprints to kickstart your first workflows.