-
Notifications
You must be signed in to change notification settings - Fork 5
/
update-docker-cli.sh
executable file
·37 lines (31 loc) · 1.68 KB
/
update-docker-cli.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
set -eu
DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
BUILDX_VER=$(git ls-remote --sort -v:refname --tags https://github.com/docker/buildx.git|head -n 1|sed 's/^.*tags\///g'|sed 's/[^[:alnum:]+._-]//g')
COMPOSE_VER=$(git ls-remote --sort -v:refname --tags https://github.com/docker/compose.git|head -n 1|sed 's/^.*tags\///g'|sed 's/[^[:alnum:]+._-]//g')
case $(dpkg --print-architecture) in
arm64)
BUILDX_URL="https://github.com/docker/buildx/releases/download/$BUILDX_VER/buildx-$BUILDX_VER.linux-arm64"
COMPOSE_URL="https://github.com/docker/compose/releases/download/$COMPOSE_VER/docker-compose-linux-aarch64"
;;
armhf)
BUILDX_URL="https://github.com/docker/buildx/releases/download/$BUILDX_VER/buildx-$BUILDX_VER.linux-arm-v7"
COMPOSE_URL="https://github.com/docker/compose/releases/download/$COMPOSE_VER/docker-compose-linux-armv7"
;;
amd64)
BUILDX_URL="https://github.com/docker/buildx/releases/download/$BUILDX_VER/buildx-$BUILDX_VER.linux-amd64"
COMPOSE_URL="https://github.com/docker/compose/releases/download/$COMPOSE_VER/docker-compose-linux-x86_64"
;;
*)
echo "Unknown architecture, exiting."
exit 1
;;
esac
echo "Updating docker compose to $COMPOSE_VER and buildx to $BUILDX_VER in $DOCKER_CONFIG ..."
mkdir -p "$DOCKER_CONFIG/cli-plugins"
rm -f "$DOCKER_CONFIG/cli-plugins/docker-buildx" "$DOCKER_CONFIG/cli-plugins/docker-compose"
curl --progress-bar -SL "$BUILDX_URL" -o "$DOCKER_CONFIG/cli-plugins/docker-buildx"
curl --progress-bar -SL "$COMPOSE_URL" -o "$DOCKER_CONFIG/cli-plugins/docker-compose"
chmod 0755 "$DOCKER_CONFIG/cli-plugins/docker-buildx" "$DOCKER_CONFIG/cli-plugins/docker-compose"
docker buildx version
docker compose version