Skip to content

Commit ff7ea6b

Browse files
committed
fix(docker): couldn't access coinswap-builder
1 parent 777b617 commit ff7ea6b

File tree

5 files changed

+40
-32
lines changed

5 files changed

+40
-32
lines changed

docker-setup.sh

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -485,22 +485,14 @@ build_image() {
485485
esac
486486
fi
487487

488-
# Set build flags based on single vs multi-platform
489-
local BUILD_FLAGS="--platform $PLATFORM --progress=plain"
490-
if [[ "$IS_MULTI_PLATFORM" == "false" ]]; then
491-
BUILD_FLAGS="$BUILD_FLAGS --load"
492-
print_info "Building single platform - will load into Docker"
493-
else
494-
print_warning "Multi-platform build - images won't be loaded into Docker"
495-
print_info "Use 'docker buildx build --platform <platform> --load' to load a specific platform"
496-
fi
497-
498488
# Build the shared builder image first
499489
print_info "Building builder image..."
490+
500491
if docker buildx build \
501-
$BUILD_FLAGS \
492+
--platform "$PLATFORM" \
493+
$([ "$IS_MULTI_PLATFORM" = "false" ] && echo "--load") \
502494
-f docker/Dockerfile.builder \
503-
-t coinswap-builder \
495+
-t coinswap-builder:latest \
504496
.; then
505497
print_success "Builder image built successfully"
506498
else
@@ -509,34 +501,54 @@ build_image() {
509501
exit 1
510502
fi
511503

504+
# For multi-platform builds, we need to use the buildx cache
505+
# For single-platform builds, the image is already loaded
506+
512507
# Build individual service images
513508
local services=("maker" "taker" "tracker" "test")
514509

515510
for service in "${services[@]}"; do
516511
print_info "Building $service image..."
517-
if docker buildx build \
518-
$BUILD_FLAGS \
519-
-f "docker/Dockerfile.$service" \
520-
--build-arg BUILDER_IMAGE=coinswap-builder \
521-
-t "coinswap-$service" \
522-
.; then
523-
print_success "$service image built successfully"
512+
513+
if [ "$IS_MULTI_PLATFORM" = "false" ]; then
514+
# Single platform: image is in local Docker, can build normally
515+
if docker buildx build \
516+
--platform "$PLATFORM" \
517+
--load \
518+
-f "docker/Dockerfile.$service" \
519+
-t "coinswap-$service" \
520+
.; then
521+
print_success "$service image built successfully"
522+
else
523+
print_error "Failed to build $service image"
524+
exit 1
525+
fi
524526
else
525-
print_error "Failed to build $service image"
526-
exit 1
527+
# Multi-platform: need to reference builder from buildx cache
528+
if docker buildx build \
529+
--platform "$PLATFORM" \
530+
--build-context coinswap-builder=docker-image://coinswap-builder:latest \
531+
-f "docker/Dockerfile.$service" \
532+
-t "coinswap-$service" \
533+
.; then
534+
print_success "$service image built successfully"
535+
else
536+
print_error "Failed to build $service image"
537+
exit 1
538+
fi
527539
fi
528540
done
529541

530542
echo ""
531-
print_success "All Docker images built successfully for $PLATFORM"
543+
print_success "All Docker images built successfully for $PLATFORM"
532544
echo ""
533545

534546
if [[ "$IS_MULTI_PLATFORM" == "false" ]]; then
535547
print_info "Built images:"
536548
docker images | grep -E "coinswap-(builder|maker|taker|tracker|test)" | head -5
537549
else
538-
print_info "Multi-platform images built but not loaded into local Docker"
539-
print_info "To load a specific platform, run:"
550+
print_info "Multi-platform images built in buildx cache"
551+
print_info "To load a specific platform into Docker, run:"
540552
echo " docker buildx build --platform linux/amd64 --load -f docker/Dockerfile.builder -t coinswap-builder ."
541553
fi
542554
}

docker/Dockerfile.maker

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Maker daemon Dockerfile
2-
ARG BUILDER_IMAGE=coinswap-builder
3-
FROM ${BUILDER_IMAGE} AS builder
2+
FROM coinswap-builder:latest AS builder
43

54
FROM alpine:3.20
65

docker/Dockerfile.taker

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Taker Dockerfile
2-
ARG BUILDER_IMAGE=coinswap-builder
3-
FROM ${BUILDER_IMAGE} AS builder
2+
FROM coinswap-builder:latest AS builder
43

54
FROM alpine:3.20
65

docker/Dockerfile.test

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Test environment Dockerfile
2-
ARG BUILDER_IMAGE=coinswap-builder
3-
FROM ${BUILDER_IMAGE} AS builder
2+
FROM coinswap-builder:latest AS builder
43

54
FROM rust:1.90-alpine3.20
65

docker/Dockerfile.tracker

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Tracker Dockerfile
2-
ARG BUILDER_IMAGE=coinswap-builder
3-
FROM ${BUILDER_IMAGE} AS builder
2+
FROM coinswap-builder:latest AS builder
43

54
FROM alpine:3.20
65

0 commit comments

Comments
 (0)