Skip to content

Commit

Permalink
Dockerfile Generation Overhaul (#1601)
Browse files Browse the repository at this point in the history
* Added support for nearly all external tests. Added a build_all.sh script. Improved supported version, jvms, etc.

* Enable building of Dockerfiles
  • Loading branch information
Jim Crowley authored Feb 5, 2020
1 parent 4ddd672 commit 28a458b
Show file tree
Hide file tree
Showing 4 changed files with 490 additions and 121 deletions.
51 changes: 51 additions & 0 deletions external/build_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env bash
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
set -o pipefail

source ./common_functions.sh

# Cleanup any old containers and images
echo "==============================================================================="
echo " Cleaning up images "
echo "==============================================================================="
cleanup_images

# Loop through all possible images
for test in ${supported_tests}
do
for version in ${supported_versions}
do
for vm in ${supported_jvms}
do
for os in ${supported_os}
do
for package in ${supported_packages}
do
for build in ${supported_builds}
do
echo "==============================================================================="
echo " "
echo " Building Docker Images for ${test} ${version} ${vm} ${os} ${package} ${build} "
echo " "
echo "==============================================================================="
./build_image.sh ${test} ${version} ${vm} ${os} ${package} ${build}
echo
echo
done
done
done
done
done
done
76 changes: 42 additions & 34 deletions external/build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,49 +19,57 @@ source ./dockerfile_functions.sh

if [ $# -ne 6 ]; then
echo
echo "usage: $0 os test version vm package build"
echo "os = ${all_os}"
echo "test = ${all_tests}"
echo "version = ${all_versions}"
echo "vm = ${all_jvms}"
echo "package = ${all_packages}"
echo "build = ${all_builds}"
echo "usage: $0 test version vm os package build"
echo "test = ${supported_tests}"
echo "version = ${supported_versions}"
echo "vm = ${supported_jvms}"
echo "os = ${supported_os}"
echo "package = ${supported_packages}"
echo "build = ${supported_builds}"
exit -1
fi

set_os $1
set_test $2
set_version $3
set_vm $4
set_test $1
set_version $2
set_vm $3
set_os $4
set_package $5
set_build $6


# Build the Docker image with the given repo, build, build type and tags.
#function build_image() {
# repo=$1; shift;
# build=$1; shift;
# btype=$1; shift;
#
# tags=""
#
# dockerfile="Dockerfile.${vm}.${build}.${btype}"
#
# echo "#####################################################"
# echo "INFO: docker build --no-cache ${tags} -f ${dockerfile} ."
# echo "#####################################################"
# docker build --pull --no-cache ${tags} -f ${dockerfile} .
# if [ $? != 0 ]; then
# echo "ERROR: Docker build of image: ${tags} from ${dockerfile} failed."
# exit 1
# fi
#}
function build_image() {
local file=$1
local test=$2

# Used for tagging the image
tags="adoptopenjdk-${test}-test"

echo "#####################################################"
echo "INFO: docker build --no-cache -t ${tags} -f ${file} ."
echo "#####################################################"
docker build --no-cache -t ${tags} -f ${file} .
if [ $? != 0 ]; then
echo "ERROR: Docker build of image: ${tags} from ${file} failed."
exit 1
fi
}

# Handle making the directory for organizing the Dockerfiles
dir="${test}/dockerfile/${version}/${package}/${os}"
mkdir -p ${dir}

# File Path to Dockerfile
file="${dir}/Dockerfile.${vm}.${build}"

# Generate Dockerfile
generate_dockerfile ${file} ${test} ${version} ${vm} ${os} ${package} ${build}

# Generate all the Dockerfiles for each of the builds and build types
dir="${test}/dockerfile"
file="${dir}/Dockerfile.${os}"
generate_dockerfile ${file} ${os} ${test} ${version} ${vm} ${package} ${build}
# Check if Dockerfile exists
if [ ! -f ${file} ]; then
continue;
echo "ERROR: Dockerfile generation for ${file} failed."
exit 1
fi

# Build Dockerfile that was generated
build_image ${file} ${test}
Loading

0 comments on commit 28a458b

Please sign in to comment.