Skip to content
StackDecode
AdvancedLesson 21 of 26

Docker in CI/CD

Build once, test the image, push it with a traceable tag.

A typical pipeline: build, test inside the container, scan, then push with the git commit SHA and promote the same image through environments.

yaml
# .github/workflows/build.yml (excerpt)
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
  with:
    username: ${{ secrets.DOCKERHUB_USER }}
    password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: docker/build-push-action@v6
  with:
    push: true
    tags: myuser/myapp:${{ github.sha }}
    cache-from: type=gha
    cache-to: type=gha,mode=max