Release engineering · Engineering practice

Deploy the image you tested

Use Docker digests and GitHub Actions to keep the tested release intact from staging to production.

AuthorHanif Birgani
Reading timeAbout 5 minutes
Published27 October 2026

A release passes its staging checks. A later production step builds the source again. The second build has the same Git commit, but it can contain different dependencies. An unpinned base image can change between builds.

A reliable release path keeps the tested image intact. The build produces one image. Staging and production then use its recorded digest.

The tested image moves through release checksOne image runs in staging. Schema checks and approval precede deployment of the same image to production. Build one imageStagingAPI + workersProductionSame imageRelease checksSchema + approvalOne recorded image digest
Staging and production use one image digest. The release checks control when that image reaches production.

Identify the image by its content

A Docker image digest identifies image content. Tags can change, but a digest identifies a fixed image or image index.[1]

A tag such as latest is convenient for discovery. A release record needs the repository name and the exact sha256 digest.

A commit identifier links the image to source code. A digest links the release to the built content. The release record needs both identifiers.

  1. Build the application image in GitHub Actions.
  2. Push the image to the selected registry.
  3. Save the registry digest and source commit in the release record.
  4. Use that image reference in staging and production.

A multi-platform image index can select a different image for each platform. Production needs the same tested platform, or separate checks for each supported platform.

Check the application as a system

A container can start successfully before the application is ready. The database, credentials, or task broker can still be unavailable.

A useful staging check crosses the application boundaries. A short request can create test data, submit a background task, and verify its stored result.

A FastAPI or Django service and its Celery workers also need compatible task messages. An older worker can remain active during a deployment.

  1. Run the API and worker checks against the recorded image.
  2. Use a separate test account and a small test document.
  3. Verify the task result through the same API that users call.
  4. Check compatibility with the previous worker message format.

Staging and production still need different credentials and service addresses. The image stays fixed while the deployment supplies each environment with its own settings.

Keep the database compatible during change

An image rollback changes application code. It does not restore database contents or repair a destructive schema change.

Consider a change from customer_name to display_name. An immediate column rename can break an older API process or worker.

A staged schema change provides a safer transition. The old and new application versions share a temporary compatibility period.

  1. Add the new field without removing the old field.
  2. Deploy code that can read old rows and write both fields.
  3. Copy existing values in resumable batches.
  4. Check that all active API processes and workers support the new field.
  5. Remove the old field in a later release.

The copy step needs its own progress record and checks. A repeated batch should not corrupt data that the new code has already changed.

Django supports explicit migration operations and reverse operations. A reverse operation still needs an application-specific review of data loss and compatibility.[2]

Give production one controlled path

GitHub Actions environments can require deployment checks and approval before a job starts. Environment secrets become available only after the configured protection rules pass.[3]

A shared concurrency group limits competing deployment jobs. An environment name alone does not impose that limit. Every production workflow needs the same concurrency policy.[4]

The fragment below assumes an earlier verify-staging job. That job supplies the tested image reference through a job output.

concurrency:
  group: deploy-production
  cancel-in-progress: false

jobs:
  deploy:
    needs: verify-staging
    runs-on: ubuntu-latest
    environment: production
    steps:
      - name: Deploy the tested image
        env:
          IMAGE_REF: ${{ needs.verify-staging.outputs.image_ref }}
        run: ./scripts/deploy-tested-image.sh "$IMAGE_REF"

The application supplies the deployment script and any checkout or artifact steps that it needs. The fragment is not a complete workflow.

The deployment script should verify the approved image reference before it changes the host. A deployment target such as a DigitalOcean server should pull that exact reference.

Concurrency controls do not guarantee deployment order. A release record should also prevent an older pending run from replacing a newer approved release.

Prepare recovery before deployment

The previous image digest is only one part of recovery. The database schema, configuration, and task message formats must still support that version.

  1. Record the previous working image reference.
  2. Check schema and worker compatibility before the release.
  3. Verify the backup and restoration procedure for planned data changes.
  4. Define the signal that stops the deployment.
  5. Run readiness and smoke checks after the change.

A readiness check should have a short time limit and a clear purpose. A live LLM request is usually a poor readiness dependency.

If the new application writes incompatible data, a code rollback can be unsafe. A corrective release or a separate data recovery procedure can be necessary.

A completed release has a tested image identity and a known recovery path. The deployment record connects those facts to the running API and workers.

Sources

  1. Docker: Image digests and multi-platform images.
  2. Django: Database migrations.
  3. GitHub: Deployment environments.
  4. GitHub: Deployment and concurrency controls.

← All writing