Skip to content

Commit

Permalink
Separate enabling buildkit (and installing buildx) and gcr mirror
Browse files Browse the repository at this point in the history
  • Loading branch information
briandealwis committed Jun 26, 2021
1 parent 87a7f2b commit 36bced4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ before_install:

# enable buildkit plus configure gcr mirror
#- sh hack/enable-docker-buildkit.sh
#- sudo service docker restart || (systemctl status docker.service; journalctl -xe)
- sh hack/use-gcr-mirror.sh
- sudo service docker restart || (systemctl status docker.service; journalctl -xe)
- docker info

# Remove buildkit'isms from Dockerfiles
- sh hack/strip-buildkitisms.sh

install:
Expand Down
6 changes: 1 addition & 5 deletions hack/enable-docker-buildkit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,15 @@ if [ -f /etc/docker/daemon.json ]; then
# avoid `jq ... | sudo tee /etc/docker/daemon.json` as we were
# having 0-byte files created instead (!)
jq '.+{"experimental":true}' /etc/docker/daemon.json \
| jq '."registry-mirrors" -= ["https://registry.docker.io"]' \
| jq '."registry-mirrors" += ["https://mirror.gcr.io"]' \
| tee /tmp/docker-daemon.json
echo "/tmp/docker-daemon.json:"
sed 's/^/> /' /tmp/docker-daemon.json
sudo cp /tmp/docker-daemon.json /etc/docker/daemon.json

echo "/etc/docker/daemon.json now:"
sed 's/^/> /' /etc/docker/daemon.json
else
sudo mkdir -vp /etc/docker
echo "/etc/docker/daemon.json now:"
echo '{"experimental":true,"registry-mirrors":["https://mirror.gcr.io"]}' \
echo '{"experimental":true}' \
| sudo tee /etc/docker/daemon.json
fi

Expand Down
24 changes: 24 additions & 0 deletions hack/use-gcr-mirror.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

echo ">> enabling gcr mirror"
if [ -f /etc/docker/daemon.json ]; then
echo "/etc/docker/daemon.json was:"
sed 's/^/> /' /etc/docker/daemon.json

# avoid `jq ... | sudo tee /etc/docker/daemon.json` as we were
# having 0-byte files created instead (!)
cat /etc/docker/daemon.json \
| jq '."registry-mirrors" -= ["https://registry.docker.io"]' \
| jq '."registry-mirrors" += ["https://mirror.gcr.io"]' \
| tee /tmp/docker-daemon.json
sudo cp /tmp/docker-daemon.json /etc/docker/daemon.json

echo "/etc/docker/daemon.json now:"
sed 's/^/> /' /etc/docker/daemon.json
else
sudo mkdir -vp /etc/docker
echo "/etc/docker/daemon.json now:"
echo '{"registry-mirrors":["https://mirror.gcr.io"]}' \
| sudo tee /etc/docker/daemon.json
fi

0 comments on commit 36bced4

Please sign in to comment.