mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-27 15:37:02 +00:00
fix: resolve Docker Hub authentication issues in multi-platform builds (#180)
This commit is contained in:
@@ -185,11 +185,17 @@ jobs:
|
|||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
driver: docker-container
|
||||||
|
use: true
|
||||||
|
config-inline: |
|
||||||
|
[registry."docker.io"]
|
||||||
|
mirrors = ["https://registry-1.docker.io"]
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Log in to Docker Hub
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
@@ -202,6 +208,31 @@ jobs:
|
|||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Verify Docker authentication and configure buildx
|
||||||
|
run: |
|
||||||
|
echo "Verifying Docker authentication..."
|
||||||
|
docker info
|
||||||
|
|
||||||
|
echo "Testing Docker Hub access..."
|
||||||
|
docker pull hello-world:latest || echo "Warning: Docker Hub access test failed"
|
||||||
|
|
||||||
|
echo "Bootstrap buildx builder..."
|
||||||
|
docker buildx inspect --bootstrap
|
||||||
|
|
||||||
|
echo "Configure buildx authentication..."
|
||||||
|
# Create buildx builder configuration
|
||||||
|
mkdir -p ~/.docker/buildx
|
||||||
|
cat > ~/.docker/buildx/config.toml << EOF
|
||||||
|
[registry."docker.io"]
|
||||||
|
mirrors = ["https://registry-1.docker.io"]
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Test base image access
|
||||||
|
echo "Testing base image access..."
|
||||||
|
docker buildx build --platform=linux/amd64 -t test-auth - <<< "FROM alpine:3.18"
|
||||||
|
docker buildx build --platform=linux/amd64 -t test-auth - <<< "FROM rust:1.85-alpine"
|
||||||
|
echo "Base image access test completed"
|
||||||
|
|
||||||
- name: Extract metadata and generate tags
|
- name: Extract metadata and generate tags
|
||||||
id: meta
|
id: meta
|
||||||
run: |
|
run: |
|
||||||
@@ -293,7 +324,49 @@ jobs:
|
|||||||
echo "📋 Build type: $BUILD_TYPE"
|
echo "📋 Build type: $BUILD_TYPE"
|
||||||
echo "🔖 Version: $VERSION"
|
echo "🔖 Version: $VERSION"
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image (with retry)
|
||||||
|
uses: nick-fields/retry@v3
|
||||||
|
with:
|
||||||
|
timeout_minutes: 30
|
||||||
|
max_attempts: 3
|
||||||
|
retry_on: error
|
||||||
|
command: |
|
||||||
|
# Convert comma-separated tags to multiple --tag arguments
|
||||||
|
TAGS_ARG=""
|
||||||
|
IFS=',' read -ra TAGS <<< "${{ steps.meta.outputs.tags }}"
|
||||||
|
for tag in "${TAGS[@]}"; do
|
||||||
|
TAGS_ARG="$TAGS_ARG --tag $tag"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Convert comma-separated labels to multiple --label arguments
|
||||||
|
LABELS_ARG=""
|
||||||
|
IFS=',' read -ra LABELS <<< "${{ steps.meta.outputs.labels }}"
|
||||||
|
for label in "${LABELS[@]}"; do
|
||||||
|
LABELS_ARG="$LABELS_ARG --label $label"
|
||||||
|
done
|
||||||
|
|
||||||
|
docker buildx build \
|
||||||
|
--platform=${{ matrix.variant.platforms }} \
|
||||||
|
--file=${{ matrix.variant.dockerfile }} \
|
||||||
|
$TAGS_ARG \
|
||||||
|
$LABELS_ARG \
|
||||||
|
--cache-from=type=gha,scope=docker-${{ matrix.variant.name }} \
|
||||||
|
--cache-from=type=registry,ref=${{ env.REGISTRY_GHCR }}:buildcache-${{ matrix.variant.name }} \
|
||||||
|
--cache-to=type=gha,mode=max,scope=docker-${{ matrix.variant.name }} \
|
||||||
|
--cache-to=type=registry,ref=${{ env.REGISTRY_GHCR }}:buildcache-${{ matrix.variant.name }},mode=max \
|
||||||
|
--build-arg=BUILDTIME=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
|
||||||
|
--build-arg=VERSION=${{ needs.build-check.outputs.version }} \
|
||||||
|
--build-arg=BUILD_TYPE=${{ needs.build-check.outputs.build_type }} \
|
||||||
|
--build-arg=REVISION=${{ github.sha }} \
|
||||||
|
--build-arg=BUILDKIT_INLINE_CACHE=1 \
|
||||||
|
--provenance=false \
|
||||||
|
--sbom=false \
|
||||||
|
--pull \
|
||||||
|
${{ needs.build-check.outputs.should_push == 'true' && '--push' || '--load' }} \
|
||||||
|
.
|
||||||
|
|
||||||
|
- name: Build and push Docker image (fallback)
|
||||||
|
if: failure()
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
@@ -317,6 +390,9 @@ jobs:
|
|||||||
# Enable advanced BuildKit features for better performance
|
# Enable advanced BuildKit features for better performance
|
||||||
provenance: false
|
provenance: false
|
||||||
sbom: false
|
sbom: false
|
||||||
|
# Add retry mechanism by splitting the build process
|
||||||
|
no-cache: false
|
||||||
|
pull: true
|
||||||
|
|
||||||
# Create manifest for main production image (only for stable releases)
|
# Create manifest for main production image (only for stable releases)
|
||||||
create-manifest:
|
create-manifest:
|
||||||
|
|||||||
Reference in New Issue
Block a user