#!/bin/sh
#
# Copyright The OpenZipkin Authors
# SPDX-License-Identifier: Apache-2.0
#

# Defends against build outages caused by Docker Hub (docker.io) pull rate limits.
#
# It should not login to anything, as that should be done in `configure_docker_push`

set -ue

# The below sets up testcontainers configuration, which will be ignored if it isn't used. Even if
# this is Docker related, it is coupled to integration tests configuration invoked with Maven.
# * See https://www.testcontainers.org/supported_docker_environment/image_registry_rate_limiting/
# * checks.disable=true - saves time and a docker.io pull of alpine
# * ryuk doesn't count against docker.io rate limits because Docker approved testcontainers as OSS
echo checks.disable=true >> ~/.testcontainers.properties

# We don't use any docker.io images, but add a Google's mirror in case something implicitly does
# * See https://cloud.google.com/container-registry/docs/pulling-cached-images
echo '{ "registry-mirrors": ["https://mirror.gcr.io"] }' | sudo tee /etc/docker/daemon.json
sudo service docker restart
