@@ -430,6 +430,15 @@ publish_image() {
430430
431431# Publish the Bitcoin Docker image
432432publish_bitcoin_image () {
433+ local presynced=" false"
434+
435+ for arg in " $@ " ; do
436+ if [[ " $arg " == " --pre-sync" ]]; then
437+ presynced=" true"
438+ break
439+ fi
440+ done
441+
433442 local username=" ${DOCKERHUB_USERNAME} "
434443
435444 if [ -z " $username " ]; then
@@ -445,26 +454,58 @@ publish_bitcoin_image() {
445454 local repo_name=$( echo " $BITCOIN_IMAGE_NAME " | awk -F/ ' {print $NF}' )
446455 local target_repo=" ${username} /${repo_name} "
447456
448- # Ensure image is built
449- build_bitcoin_image
457+ local tag=" latest"
458+ if [ -f " $VERSION_FILE " ]; then
459+ tag=$( grep " ^TAG=" " $VERSION_FILE " | cut -d' =' -f2)
460+ fi
450461
451- # Get tag from version file
452- local tag=$( grep " ^TAG=" " $VERSION_FILE " | cut -d' =' -f2)
462+ if [[ " $presynced " == " true" ]]; then
463+ print_info " Preparing to publish pre-synced image to ${target_repo} :presynced-latest"
464+ print_warning " This process will build a Docker image that syncs the Bitcoin node during build."
465+ print_warning " This may take a significant amount of time."
466+ read -p " Are you sure? [y/N]: " confirm
467+ if [[ ! " ${confirm} " =~ ^[Yy]$ ]]; then
468+ exit 0
469+ fi
470+
471+ print_info " Building pre-synced image using Dockerfile..."
472+
473+ if docker build \
474+ --build-arg TAG=" $tag " \
475+ --network=host \
476+ -f docker/Dockerfile.bitcoin-mutinynet.presynced \
477+ -t " ${target_repo} :presynced-latest" . ; then
478+
479+ if [ -n " $tag " ]; then
480+ docker tag " ${target_repo} :presynced-latest" " ${target_repo} :presynced-${tag} "
481+ fi
482+
483+ print_info " Pushing images..."
484+ docker push " ${target_repo} :presynced-latest"
485+ if [ -n " $tag " ]; then
486+ docker push " ${target_repo} :presynced-${tag} "
487+ fi
488+ print_success " Published pre-synced images successfully"
489+ else
490+ print_error " Failed to build pre-synced image"
491+ exit 1
492+ fi
493+ else
494+ build_bitcoin_image
453495
454496 print_info " Tagging and pushing image to $target_repo ..."
455497
456- # Tag and push latest
457498 docker tag " ${BITCOIN_IMAGE_NAME} :latest" " ${target_repo} :latest"
458499 docker push " ${target_repo} :latest"
459500
460- # Tag and push version
461501 if [ -n " $tag " ]; then
462502 docker tag " ${BITCOIN_IMAGE_NAME} :${tag} " " ${target_repo} :${tag} "
463503 docker push " ${target_repo} :${tag} "
464504 print_success " Published ${target_repo} :${tag} "
465505 fi
466506
467507 print_success " Published ${target_repo} :latest"
508+ fi
468509}
469510
470511# Start the full stack using docker-compose
@@ -549,7 +590,9 @@ show_help() {
549590 echo " build Build the Docker image"
550591 echo " build-bitcoin Build the Bitcoin Mutinynet Docker image"
551592 echo " publish [ver] Publish image to Docker Hub (optional version tag)"
552- echo " publish-bitcoin Publish Bitcoin Mutinynet image to Docker Hub"
593+ echo " publish-bitcoin [options] Publish Bitcoin Mutinynet image to Docker Hub"
594+ echo " Options:"
595+ echo " --pre-sync Publish pre-synced Bitcoin image (presynced-latest)"
553596 echo " start [options] Start the full Coinswap stack"
554597 echo " Options:"
555598 echo " -d, --default Use default configuration without prompting"
@@ -594,7 +637,7 @@ case "${1:-}" in
594637 ;;
595638 " publish-bitcoin" )
596639 check_docker
597- publish_bitcoin_image
640+ publish_bitcoin_image " ${ @: 2} "
598641 ;;
599642 " start" )
600643 check_docker
0 commit comments