Intégration Continue Docker
Guide pour intégrer Docker dans vos pipelines CI/CD.
| Plateforme |
Documentation |
| GitLab CI |
Build, push et déploiement avec GitLab |
| GitHub Actions |
Workflows Docker pour GitHub |
Concepts clés
Pipeline typique Docker
graph LR
A[Lint] --> B[Build]
B --> C[Security Scan]
C --> D[Push Registry]
D --> E[Deploy]
Stages recommandés
- Lint - Validation des Dockerfiles (hadolint)
- Build - Construction des images
- Test - Tests unitaires et d'intégration
- Security - Scan de vulnérabilités (Trivy, Snyk)
- Push - Publication vers le registry
- Deploy - Déploiement sur les environnements
Bonnes pratiques
Tagging des images
# Format recommandé
registry/image:env-commit_sha
registry/image:env-latest
# Exemples
registry.gitlab.com/myproject/api:prod-abc1234
registry.gitlab.com/myproject/api:prod-latest
Variables d'environnement
| Variable |
Description |
CI_REGISTRY |
URL du registry |
CI_REGISTRY_IMAGE |
Chemin complet de l'image |
CI_COMMIT_SHORT_SHA |
Hash court du commit |
CI_ENVIRONMENT_NAME |
Nom de l'environnement |
Multi-environnements
# Structure recommandée
environments:
- dev # Développement (auto-deploy)
- staging # Pré-production (manual)
- prod # Production (manual + approval)