Skip to content

Commit

Permalink
Push and pull 'nightly' tag Docker images in nightly test job (#25619)
Browse files Browse the repository at this point in the history
Adjust the nightly Docker testing script to push (and pull) `nightly`
tags of the images.

This incidentally makes the chapel-gasnet and chapel-gasnet-smp images
build off of the just-built Chapel base image. Previously it was
building off of the `latest` tag from the last release, not accessing
the local copy of `latest` due to [behavior of the buildx
builder](docker/buildx#847).

While here, adjust formatting of `util/cron/test-docker.bash` script for
clarity.

Resolves Cray/chapel-private#6436.

[reviewed by @arezaii , thanks!]

Testing:
- [x] manual run succeeds and pushes `nightly` images on chapelmac-m1
- [x] build exits with error if Chapel base image can't build
- [x] (pre-merge reminder) update Dockerhub page to note the meaning of
the `nightly` tag
  • Loading branch information
riftEmber authored Jul 30, 2024
2 parents fd0f741 + e2b1613 commit 1f5ed02
Showing 1 changed file with 49 additions and 27 deletions.
76 changes: 49 additions & 27 deletions util/cron/test-docker.bash
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#
# This script will build, run, and verify chapel, gasnet, and gasnet-smp docker images.
# This script will build, run, and verify chapel, gasnet, and gasnet-smp docker images.

CWD=$(cd $(dirname $0) ; pwd)
source $CWD/common.bash
Expand All @@ -9,41 +9,63 @@ export CHPL_HOME=$(cd $CWD/../.. ; pwd)
log_info "Setting CHPL_HOME to: ${CHPL_HOME}"

start_docker

# build_image function takes image name and docker script location as arguments.
# Builds the image with the name from arg$1, runs the container and execute the install and verify script located in the location $2.
build_image(){

local imageName="$1"
local script="$2"
# Remove any existing image with the tag before building docker image
docker image rm --force $imageName
docker build --load . -t $imageName
containerid= docker image ls | grep $imageName | awk '{print$3}'
cd ${CHPL_HOME}/util/cron
echo 'writeln("Hello, world!");' > hello.chpl

docker run --rm -i $imageName < $script

CONTAINER_RUN=$?
if [ $CONTAINER_RUN -ne 0 ]
then
echo "docker commands failed inside chapel $imageName container"
exit 1
else
echo "docker commands succeeded inside chapel $imageName container"
fi
build_image() {
local imageName="$1"
local script="$2"
# Remove any existing image with the tag before building docker image
docker image rm --force $imageName

docker build --push . -t $imageName
BUILD_RESULT=$?
if [ $BUILD_RESULT -ne 0 ]
then
echo "docker build failed for $imageName image"
exit 1
fi

containerid= docker image ls | grep $imageName | awk '{print$3}'
cd ${CHPL_HOME}/util/cron
echo 'writeln("Hello, world!");' > hello.chpl

docker run --rm -i $imageName < $script

CONTAINER_RUN=$?
if [ $CONTAINER_RUN -ne 0 ]
then
echo "docker commands failed inside chapel $imageName container"
exit 1
else
echo "docker commands succeeded inside chapel $imageName container"
fi
}

# Patch the Dockerfile to build FROM the nightly image instead of latest.
# Assumes the Dockerfile is available at ./Dockerfile.
dockerfile_nightly_patch() {
local nightlypatch="
1c1
< FROM chapel/chapel:latest
---
> FROM chapel/chapel:nightly
"
patch ./Dockerfile << EOF
$nightlypatch
EOF
}

# Build chapel docker image.
# Build chapel Docker images
cd $CHPL_HOME
build_image chapel/chapel ${CHPL_HOME}/util/cron/docker-chapel.bash
build_image chapel/chapel:nightly ${CHPL_HOME}/util/cron/docker-chapel.bash

cd $CHPL_HOME/util/packaging/docker/gasnet
build_image chapel/chapel_gasnet ${CHPL_HOME}/util/cron/docker-gasnet.bash
dockerfile_nightly_patch
build_image chapel/chapel-gasnet:nightly ${CHPL_HOME}/util/cron/docker-gasnet.bash

cd $CHPL_HOME/util/packaging/docker/gasnet-smp
build_image chapel/chapel_gasnet_smp ${CHPL_HOME}/util/cron/docker-gasnet.bash
dockerfile_nightly_patch
build_image chapel/chapel-gasnet-smp:nightly ${CHPL_HOME}/util/cron/docker-gasnet.bash

export CHPL_NIGHTLY_TEST_CONFIG_NAME="docker"

0 comments on commit 1f5ed02

Please sign in to comment.