#!/bin/sh set -e IFS=$'\n\t' function print_golang_args() { case "$1" in 1.8|1.8.6) INSTALL_GOLANG_VERSION=1.8.6 GOLANG_DOWNLOAD_SHA256=f558c91c2f6aac7222e0bd83e6dd595b8fac85aaa96e55d15229542eb4aaa1ff ;; 1.9) INSTALL_GOLANG_VERSION=1.9.4 GOLANG_DOWNLOAD_SHA256=15b0937615809f87321a457bb1265f946f9f6e736c563d6c5e0bd2c22e44f779 ;; 1.10|1.10.0) INSTALL_GOLANG_VERSION=1.10 GOLANG_DOWNLOAD_SHA256=b5a64335f1490277b585832d1f6c7f8c6c11206cba5cd3f771dcb87b98ad1a33 ;; *) echo "Unknown golang version $1"; exit 1; esac printf -- "--build-arg INSTALL_GOLANG_VERSION=%s " "$INSTALL_GOLANG_VERSION" printf -- "--build-arg GOLANG_DOWNLOAD_SHA256=%s " "$GOLANG_DOWNLOAD_SHA256" } # If you add a new minor version here, be sure to check that the # ChromeDriver supports this: https://sites.google.com/a/chromium.org/chromedriver/downloads # You may need to bump the version in scripts/install-chrome. function print_chrome_args() { case "$1" in 60|60.0) CHROME_VERSION=60.0.3112.90-1 ;; 61|61.0) CHROME_VERSION=61.0.3163.100-1 ;; 62|62.0) CHROME_VERSION=62.0.3202.89-1 ;; 63|63.0) CHROME_VERSION=63.0.3239.132-1 ;; 64|64.0) CHROME_VERSION=64.0.3282.186-1 ;; *) echo "Unknown chrome version $1"; exit 1; esac printf -- "--build-arg CHROME_VERSION=%s " "$CHROME_VERSION" } function print_git_args() { case "$1" in 2.7) # Code-debt: When the build refers to "git 2.7" its actually "default" git. # so don't actually install a git 2.7 as a default copy is already installed return ;; 2.8|2.8.4) GIT_VERSION=2.8.4 GIT_DOWNLOAD_SHA256=626e319f8a24fc0866167ea5f6bf3e2f38f69d6cb2e59e150f13709ca3ebf301 ;; 2.9|2.9.0) GIT_VERSION=2.9.0 GIT_DOWNLOAD_SHA256=bff7560f5602fcd8e37669e0f65ef08c6edc996e4f324e4ed6bb8a84765e30bd ;; 2.13) GIT_VERSION=2.13.6 GIT_DOWNLOAD_SHA256=cb53e6b388d8d19189933366c1fe5c1ca500e8b227b9e707af39c3d879e41015 ;; 2.14) GIT_VERSION=2.14.3 GIT_DOWNLOAD_SHA256=023ffff6d3ba8a1bea779dfecc0ed0bb4ad68ab8601d14435dd8c08416f78d7f ;; 2.16) GIT_VERSION=2.16.2 GIT_DOWNLOAD_SHA256=9acc4339b7a2ab484eea69d705923271682b7058015219cf5a7e6ed8dee5b5fb ;; *) echo "Unknown git version $1"; exit 1; esac printf -- "--build-arg GIT_VERSION=%s " "$GIT_VERSION" printf -- "--build-arg GIT_DOWNLOAD_SHA256=%s " "$GIT_DOWNLOAD_SHA256" } function print_node_args() { case "$1" in 7.x|7.1) NODE_INSTALL_VERSION=7.x ;; 8.x) NODE_INSTALL_VERSION=8.x ;; *) echo "Unknown node version $1"; exit 1; esac printf -- "--build-arg NODE_INSTALL_VERSION=%s " "$NODE_INSTALL_VERSION" } function print_yarn_args() { case "$1" in 1.0) YARN_INSTALL_VERSION=1.0.2-1 ;; 1.2) YARN_INSTALL_VERSION=1.2.1-1 ;; *) echo "Unknown yarn version $1"; exit 1; esac printf -- "--build-arg YARN_INSTALL_VERSION=%s " "$YARN_INSTALL_VERSION" } function print_postgres_args() { printf -- "--build-arg POSTGRES_VERSION=%s " "$1" } function parse_arguments() { read base read base_version printf -- "-f Dockerfile.custom " "$base" printf -- "--build-arg CUSTOM_IMAGE_NAME=%s " "$base" printf -- "--build-arg CUSTOM_IMAGE_VERSION=%s " "$base_version" while read image; do read version case "$image" in golang) print_golang_args $version ;; chrome) print_chrome_args $version ;; git) print_git_args $version ;; node) print_node_args $version ;; yarn) print_yarn_args $version ;; postgresql) print_postgres_args $version ;; *) exit 1;; esac done } function generate_command() { buildimage_name=$1; shift; printf -- "docker build " echo $buildimage_name | tr '-' '\n' | parse_arguments for i in "$@" do printf -- "%s " "$i" done printf -- ".\\n" } docker_command=$(generate_command $@) echo "$1: executing $docker_command" eval $docker_command