-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Morlay <[email protected]>
- Loading branch information
Showing
3 changed files
with
114 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/bin/bash | ||
|
||
set -eux | ||
|
||
# update docker | ||
# for setup buildx https://travis-ci.community/t/installing-docker-19-03/8077/2 | ||
sudo apt update | ||
|
||
sudo systemctl stop docker | ||
sudo apt install -y docker.io | ||
|
||
sudo systemctl unmask docker.service | ||
sudo systemctl unmask docker.socket | ||
sudo systemctl start docker | ||
sudo systemctl status docker.socket | ||
|
||
docker version | ||
|
||
DOCKER_BUILDX_VERSION=v0.4.1 | ||
|
||
LOCAL_OS=$(uname -s | tr '[A-Z]' '[a-z]') | ||
|
||
case $(uname -m) in | ||
x86_64) | ||
LOCAL_ARCH=amd64 | ||
;; | ||
aarch64) | ||
LOCAL_ARCH=arm64 | ||
;; | ||
*) | ||
echo "unsupported architecture" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
if [[ ! -f ~/.docker/cli-plugins/docker-buildx ]]; then | ||
DOCKER_BUILDX_DOWNLOAD_URL=https://github.com/docker/buildx/releases/download/${DOCKER_BUILDX_VERSION}/buildx-${DOCKER_BUILDX_VERSION}.${LOCAL_OS}-${LOCAL_ARCH} | ||
mkdir -p ~/.docker/cli-plugins | ||
echo "downloading from ${DOCKER_BUILDX_DOWNLOAD_URL}" | ||
curl -sL --output ~/.docker/cli-plugins/docker-buildx "${DOCKER_BUILDX_DOWNLOAD_URL}" | ||
chmod a+x ~/.docker/cli-plugins/docker-buildx | ||
fi | ||
|
||
# enable buildx | ||
export DOCKER_CLI_EXPERIMENTAL=enabled | ||
|
||
# checkout buildx available | ||
docker buildx version | ||
|
||
# enabled qemu if needed | ||
if [[ ! $(docker buildx inspect default | grep Platforms) == *arm64* ]]; then | ||
docker run --rm --privileged multiarch/qemu-user-static --reset -p | ||
fi | ||
|
||
# setup builder if need | ||
if [[ ! $(docker buildx inspect builder) == *"Name"* ]]; then | ||
docker buildx create --use --name=builder --platform=linux/amd64,linux/arm64 --driver-opt=image=moby/buildkit:master,network=host | ||
fi | ||
|
||
# log buildx detail | ||
docker buildx inspect builder |