RousselTMLEARNING

DevOps

End-to-end CI/CD (3/5): artifacts, registries and environments

Deliver continuously: immutable, versioned artifacts, image and package registries, promoting the same artifact across environments, per-environment configuration and secrets, approvals, ephemeral environments and database migrations.

1. Artifacts and versions #

What you actually deploy.

An immutable artifact #

The artifact is the result of the build: container image, binary, package (jar, wheel, npm), archive. It must be immutable (never overwritten), versioned and traceable back to the commit that produced it.

TagUsage
Commit SHA (3f9c2e1)unique identifier of each build: it is what gets deployed
Semantic version (1.5.0)published versions, readable by humans
Digest (sha256:…)exact cryptographic reference of an image
latestto avoid for deployment: ambiguous and moving
docker build -t registry.example.com/shop/api:${GIT_SHA} \
  --label org.opencontainers.image.revision=${GIT_SHA} \
  --label org.opencontainers.image.source=https://git.example.com/shop/api .
docker push registry.example.com/shop/api:${GIT_SHA}
docker tag registry.example.com/shop/api:${GIT_SHA} registry.example.com/shop/api:1.5.0   # même image, nom de version
docker buildx imagetools inspect registry.example.com/shop/api:1.5.0   # digest

Registries #

Artifact typeRegistries
OCI imagesGitHub Container Registry, GitLab Registry, Harbor, Amazon ECR, Google Artifact Registry, Docker Hub
PackagesNexus, Artifactory, GitLab Package Registry, private PyPI/npm
Helm chartsOCI registries, ChartMuseum
Good practice: Configure retention (delete branch images after a few days, keep published versions) and the registry's vulnerability scanning.

2. Environments and promotion #

From staging to production.

Promoting the same artifact #

Promotion between environments
Never rebuild for production.
EnvironmentPurposeDeployment
Ephemeral (per pull request)test and demo an isolated changeautomatic, destroyed on merge
Staging / preproductionvalidate in conditions close to productionautomatic from main
Productionserve usersautomatic (continuous deployment) or after approval

Configuration and secrets #

The artifact contains no environment-specific configuration: URLs, sizes, flags and secrets are injected at deployment (environment variables, ConfigMaps, secrets manager).

# GitHub Actions : un job lié à un environnement protégé
deploy-prod:
  needs: deploy-staging
  environment: { name: production, url: https://shop.example.com }   # approbateurs, secrets dédiés
  permissions: { id-token: write, contents: read }                   # OIDC
  runs-on: ubuntu-latest
  steps:
    - uses: aws-actions/configure-aws-credentials@v4
      with: { role-to-assume: arn:aws:iam::123456789012:role/deploy-prod, aws-region: eu-west-3 }
    - run: ./deploy.sh production ${{ github.sha }}
Good practice: Prefer OIDC identity federation between CI and the cloud to long-lived access keys stored as secrets: the token is temporary and limited to a repository, a branch or an environment.

3. Databases #

The tricky part of continuous deployment.

Versioned migrations #

The schema evolves with the code, through migrations versioned in the repository (Flyway, Liquibase, Alembic, Django or Rails migrations), applied automatically by the pipeline before or during deployment.

# Alembic : une migration par changement de schéma, versionnée avec le code
alembic revision -m "ajouter colonne email_verifie"
alembic upgrade head          # exécuté par le pipeline (job dédié ou init container)

Expand / contract #

  1. Expand: add the new column, compatible with the old version of the code.
  2. Deploy code that writes to both columns and reads the new one.
  3. Migrate existing data.
  4. Contract: drop the old column in a later version.
Common mistake: A destructive migration (rename, drop) in the same deployment as the code prevents any rollback and breaks instances still on the old version during a progressive deployment.

4. Traceability #

Knowing what is running and why.

Linking everything together #

  • Every deployment is recorded: version, commit, author, date, environment, result.
  • Observability tools receive a deployment event to correlate a degradation with a version.
  • Release notes are generated from conventional commits.
  • An SBOM and a signature accompany the artifact (see the DevSecOps lesson).

Related articles

DevOps, Agile, Lean and ITSM: frameworks that fit together

Placing DevOps among other frameworks: the agile manifesto, Scrum and Kanban, Lean thinking (flow, waste, the…

Testing continuously and in production: contracts, performance and chaos engineering

Going beyond the test pyramid: component tests with Testcontainers, contract tests (Pact), mutation testing, …

Leading a DevOps transformation: start, change, measure

Running a DevOps transformation in an organization: assess the starting point, choose a pilot team, lead chan…

Keep learning

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!