Parallelize Docker builds

Log output to docker/logs.
This commit is contained in:
Andrew Schwartzmeyer 2016-09-12 12:38:52 -07:00
parent 002d2a6911
commit f0314cd86e
3 changed files with 35 additions and 25 deletions

3
docker/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
logs/*.log
packages/
unstable/*/bootstrap.ps1

View file

@ -21,31 +21,39 @@ if [[ -z $DISTROS ]]; then
fi
for build in $BUILDS; do
# cd so $distro is only the distro name
pushd "$build"
# each distro can be done in parallel; but stable must be done before unstable
for distro in $DISTROS; do
image="powershell/powershell:$build-$distro"
if [[ "$TEST" -eq 1 ]]; then
echo "Testing $image"
command="cd PowerShell; Import-Module ./build.psm1; Install-Dotnet -NoSudo; Start-PSPester -powershell powershell -Pester ./src/Modules/Shared/Pester"
# clone repo for stable images because it's not already done
if [[ "$build" = stable ]]; then
command="git clone --recursive https://github.com/$FORK/PowerShell -b $BRANCH; $command"
logfile="$build-$distro.log"
if [[ "$TEST" -eq 1 ]]; then logfile="test-$logfile"; fi
mkdir -p logs
logfile="logs/$logfile"
echo "Logging to docker/$logfile"
(
image="powershell/powershell:$build-$distro"
cd "$build"
if [[ "$TEST" -eq 1 ]]; then
echo "LOG: testing $image"
command="cd PowerShell; Import-Module ./build.psm1; Install-Dotnet -NoSudo; Start-PSPester -powershell powershell -Pester ./src/Modules/Shared/Pester"
# clone repo for stable images because it's not already done
if [[ "$build" = stable ]]; then
command="git clone --recursive https://github.com/$FORK/PowerShell -b $BRANCH; $command"
fi
# run Pester tests inside container
# RUNARGS can be set in the environment
docker run $RUNARGS "$image" -c "$command"
else
echo "LOG: building $image"
# copy the common script because it lives outside the docker build context
if [[ "$build" = unstable ]]; then
cp bootstrap.ps1 "$distro"
buildargs="--build-arg fork=$FORK --build-arg branch=$BRANCH"
fi
# build and tag the image so they can be derived from
# BUILDARGS can be set in the environment
docker build $buildargs $BUILDARGS -t "$image" "$distro"
fi
# run Pester tests inside container
# RUNARGS can be set in the environment
docker run -it $RUNARGS "$image" -c "$command"
else
echo "Building $image"
# copy the common script because it lives outside the docker build context
if [[ "$build" = unstable ]]; then
cp bootstrap.ps1 "$distro"
buildargs="--build-arg fork=$FORK --build-arg branch=$BRANCH"
fi
# build and tag the image so they can be derived from
# BUILDARGS can be set in the environment
docker build $buildargs $BUILDARGS -t "$image" "$distro"
fi
) &>> "$logfile" &
done
popd
echo "Waiting for $build containers to finish; tail the logs for more information."
wait
done

View file

@ -1 +0,0 @@
*/bootstrap.ps1