Usage-based billing lives or dies on ingestion reliability. The fastest way we have found to keep ingestion stable is to ship it as a container, promote it with GitLab CI, and pin the released image in a registry. That workflow lets billing engineers move fast without breaking usage accounting. For reference points, we keep public artifacts in GitLab and ship container builds through Docker Hub.
This article outlines a pipeline that matches the UsageBox stack (Cloud Run ingestion, Firestore storage, and auditable usage events). If you are still designing the ingestion contract, start with the ingestion architecture guide and pair it with the usage API playbook.
Why a Container-First Pipeline Protects Billing Data
- Deterministic releases: A Docker image is immutable, which makes usage counts repeatable across environments.
- Fast rollbacks: If a meter breaks, you can roll back by digest instead of rebuilding code.
- Audit-friendly artifacts: Image tags map cleanly to release notes and billing change logs.
- Security baselines: CI scans run on every build without slowing down engineers.
GitLab CI Stages We Recommend
Start with four stages and add more only when you feel pain:
- Validate: Lint, unit tests, and schema checks for usage payloads.
- Build: Produce a single Linux image, label it, and push to your registry.
- Staging deploy: Roll out to a mirrored environment and replay sample usage events.
- Promote: Re-tag the tested image for production and trigger the Cloud Run deploy.
Minimal GitLab CI Example
stages:
- validate
- build
- deploy
build-image:
stage: build
image: docker:24
services:
- docker:24-dind
script:
- docker build -t pbudzik/usage-ingestion:$CI_COMMIT_SHA .
- docker push pbudzik/usage-ingestion:$CI_COMMIT_SHA
Docker Hub Conventions That Keep Meters Stable
- Tag by commit and environment: Promote
shatags tostagingandprodafter validation. - Pin base images: Use explicit versions so ingestion math does not shift under you.
- Add image labels: Record build time, git SHA, and meter schema version for audit trails.
How This Fits UsageBox
UsageBox expects ingestion to be idempotent and traceable. A containerized pipeline makes that possible by locking in the runtime and publishing change notes alongside every release. Pair this pipeline with audit trail workflows so finance can map each invoice back to a specific image version.
When you are ready to go further, connect the pipeline to real-time metering on Firebase and ship pricing changes using the UsageBox implementation checklist.