Skip to content

Improve Docker build workflow with Buildx and caching - #11

Merged
tanutapi merged 1 commit into
masterfrom
claude/docker-image-push-pipeline-fpz8rs
Aug 15, 2026
Merged

Improve Docker build workflow with Buildx and caching#11
tanutapi merged 1 commit into
masterfrom
claude/docker-image-push-pipeline-fpz8rs

Conversation

@tanutapi

Copy link
Copy Markdown
Owner

Summary

Refactored the Docker image build and push workflow to use Docker Buildx with improved caching and conditional authentication, enabling better build performance and security.

Key Changes

  • Replaced basic docker build and docker push commands with the official docker/build-push-action@v6 for more robust image building
  • Added Docker Buildx setup via docker/setup-buildx-action@v3 for enhanced build capabilities
  • Implemented conditional Docker Hub authentication that only runs on push events (not on pull requests), improving security by avoiding unnecessary credential exposure
  • Added GitHub Actions cache integration (type=gha) for both cache source and destination to speed up subsequent builds
  • Extended image tagging to include both latest and commit SHA-based tags for better version tracking
  • Made push operation conditional: images are only pushed to Docker Hub on push events, while pull requests build the image locally without pushing

Implementation Details

  • The push parameter is conditionally set based on the event type (github.event_name != 'pull_request')
  • GitHub Actions cache is configured with mode=max to maximize cache reuse across builds
  • Credentials are securely handled by only logging in when necessary (push events)

https://claude.ai/code/session_01UCVZxJxkKSJwWJKDNoiAs4

The push step failed with 'unauthorized: access token has insufficient
scopes' because the workflow never logged in — Docker Hub issued an
anonymous, pull-only token.

- Log in with docker/login-action using DOCKERHUB_USERNAME/DOCKERHUB_TOKEN
- Build and push via docker/build-push-action with GitHub Actions layer cache
- Skip login and push on pull_request events, where secrets are unavailable
  and unreviewed images should not be published
- Also tag each build with the commit SHA alongside :latest

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCVZxJxkKSJwWJKDNoiAs4
@tanutapi
tanutapi merged commit 4586aa9 into master Aug 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants