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.
| Tag | Usage |
|---|---|
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 |
latest | to 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 # digestRegistries #
| Artifact type | Registries |
|---|---|
| OCI images | GitHub Container Registry, GitLab Registry, Harbor, Amazon ECR, Google Artifact Registry, Docker Hub |
| Packages | Nexus, Artifactory, GitLab Package Registry, private PyPI/npm |
| Helm charts | OCI 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 #
| Environment | Purpose | Deployment |
|---|---|---|
| Ephemeral (per pull request) | test and demo an isolated change | automatic, destroyed on merge |
| Staging / preproduction | validate in conditions close to production | automatic from main |
| Production | serve users | automatic (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 #
- Expand: add the new column, compatible with the old version of the code.
- Deploy code that writes to both columns and reads the new one.
- Migrate existing data.
- 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).
