mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-19 19:16:17 +00:00
fix: docker build
This commit is contained in:
@@ -183,19 +183,7 @@ jobs:
|
|||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Login to Docker Hub
|
||||||
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
|
|
||||||
uses: docker/setup-qemu-action@v3
|
|
||||||
|
|
||||||
- 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 }}
|
||||||
@@ -208,30 +196,11 @@ jobs:
|
|||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Verify Docker authentication and configure buildx
|
- name: Set up QEMU
|
||||||
run: |
|
uses: docker/setup-qemu-action@v3
|
||||||
echo "Verifying Docker authentication..."
|
|
||||||
docker info
|
|
||||||
|
|
||||||
echo "Testing Docker Hub access..."
|
- name: Set up Docker Buildx
|
||||||
docker pull hello-world:latest || echo "Warning: Docker Hub access test failed"
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
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
|
||||||
@@ -324,50 +293,8 @@ jobs:
|
|||||||
echo "📋 Build type: $BUILD_TYPE"
|
echo "📋 Build type: $BUILD_TYPE"
|
||||||
echo "🔖 Version: $VERSION"
|
echo "🔖 Version: $VERSION"
|
||||||
|
|
||||||
- name: Build and push Docker image (with retry)
|
- name: Build and push Docker image
|
||||||
uses: nick-fields/retry@v3
|
uses: docker/build-push-action@v6
|
||||||
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
|
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: ${{ matrix.variant.dockerfile }}
|
file: ${{ matrix.variant.dockerfile }}
|
||||||
|
|||||||
Reference in New Issue
Block a user