mirror of
https://ops.gitlab.net/gitlab-org/gitlab-build-images.git
synced 2025-12-09 10:02:56 +01:00
Keep the build images DRY
This commit is contained in:
parent
2e43cb6259
commit
81d80aa564
17 changed files with 260 additions and 178 deletions
105
scripts/custom-docker-build
Executable file
105
scripts/custom-docker-build
Executable file
|
|
@ -0,0 +1,105 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
IFS=$'\n\t'
|
||||
|
||||
function print_golang_args() {
|
||||
GOLANG_VERSION=$1
|
||||
|
||||
case "$GOLANG_VERSION" in
|
||||
1.8)
|
||||
GOLANG_DOWNLOAD_SHA256=253ab94104ee3923e228a2cb2116e5e462ad3ebaeea06ff04463479d7f12d27ca
|
||||
;;
|
||||
*) echo "Unknown golang version $1"; exit 1;
|
||||
esac
|
||||
|
||||
printf -- "--build-arg GOLANG_VERSION=%s " "$GOLANG_VERSION"
|
||||
printf -- "--build-arg GOLANG_DOWNLOAD_SHA256=%s " "$GOLANG_DOWNLOAD_SHA256"
|
||||
}
|
||||
|
||||
function print_chrome_args() {
|
||||
case "$1" in
|
||||
60|60.0) CHROME_VERSION=60.0.3112.90-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.13)
|
||||
GIT_VERSION=2.13.0
|
||||
GIT_DOWNLOAD_SHA256=9f2fa8040ebafc0c2caae4a9e2cb385c6f16c0525bcb0fbd84938bc796372e80
|
||||
;;
|
||||
*) 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_phantomjs_args() {
|
||||
case "$1" in
|
||||
2.1) PHANTOMJS_VERSION=2.1.1 ;;
|
||||
*) echo "Unknown phantomjs version $1"; exit 1;
|
||||
esac
|
||||
printf -- "--build-arg PHANTOMJS_VERSION=%s " "$PHANTOMJS_VERSION"
|
||||
}
|
||||
|
||||
function print_node_args() {
|
||||
case "$1" in
|
||||
7.1) NODE_VERSION=7.x ;;
|
||||
*) echo "Unknown chrome version $1"; exit 1;
|
||||
esac
|
||||
printf -- "--build-arg NODE_VERSION=%s " "$NODE_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 ;;
|
||||
phantomjs) print_phantomjs_args $version ;;
|
||||
node) print_node_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
|
||||
|
|
@ -11,7 +11,7 @@ apt-get install -y \
|
|||
libxslt-dev libcurl4-openssl-dev libicu-dev \
|
||||
logrotate python-docutils pkg-config cmake nodejs \
|
||||
libkrb5-dev postgresql-client mysql-client unzip \
|
||||
libre2-dev \
|
||||
libre2-dev gettext \
|
||||
|
||||
echo deb http://httpredir.debian.org/debian stretch main > /etc/apt/sources.list.d/stretch.list
|
||||
apt-get update -yqqq
|
||||
|
|
|
|||
|
|
@ -2,8 +2,10 @@
|
|||
|
||||
set -xeo pipefail
|
||||
|
||||
NODE_VERSION=${1:-7.x}
|
||||
|
||||
# add official debian repos for node and yarn
|
||||
curl -sS -L https://deb.nodesource.com/setup_7.x | bash -
|
||||
curl -sS -L https://deb.nodesource.com/setup_${NODE_VERSION} | bash -
|
||||
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
|
||||
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue