vitess.io/vitess@v0.16.2/docker/bootstrap/build.sh (about) 1 #!/bin/bash 2 3 # Copyright 2019 The Vitess Authors. 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 # 17 # Usage: 18 # 19 # First build the `common` image, then any flavors you want. For example: 20 # $ docker/bootstrap/build.sh common 21 # $ docker/bootstrap/build.sh mysql80 22 # 23 # Is it also possible to specify the resulting image name: 24 # $ docker/bootstrap/build.sh common --image my-common-image 25 # 26 # If custom image names are specified, you might need to set the base image name when building flavors: 27 # $ docker/bootstrap/build.sh mysql80 --base_image my-common-image 28 # Both arguments can be combined. For example: 29 # $ docker/bootstrap/build.sh mysql80 --base_image my-common-image --image my-mysql-image 30 31 32 flavor=$1 33 if [[ -z "$flavor" ]]; then 34 echo "Flavor must be specified as first argument." 35 exit 1 36 fi 37 38 # Set default version of 0 39 version="${2:-0}" 40 41 if [[ ! -f bootstrap.sh ]]; then 42 echo "This script should be run from the root of the Vitess source tree - e.g. ~/src/vitess.io/vitess" 43 exit 1 44 fi 45 46 # Fix permissions before copying files, to avoid AUFS bug other must have read/access permissions 47 chmod -R o=rx *; 48 49 arch=$(uname -m) 50 [ "$arch" == "aarch64" ] && [ $flavor != "common" ] && arch_ext='-arm64v8' 51 52 53 base_image="${base_image:-vitess/bootstrap:$version-common}" 54 image="${image:-vitess/bootstrap:$version-$flavor$arch_ext}" 55 56 while [ $# -gt 0 ]; do 57 if [[ $1 == *"--"* ]]; then 58 param="${1/--/}" 59 declare $param="$2" 60 fi 61 shift 62 done 63 64 if [ -f "docker/bootstrap/Dockerfile.$flavor$arch_ext" ]; then 65 docker build --no-cache -f docker/bootstrap/Dockerfile.$flavor$arch_ext -t $image --build-arg bootstrap_version=$version --build-arg image=$base_image . 66 fi