This directory contains Dockerfiles to create new Docker images for
running Daikon tests reproducibly.

The rest of this file explains how to build new Docker images.


Preliminaries:

  # Finish docker setup if necessary.
  sudo usermod -aG docker $(whoami)
  # Then log out and back in.

  # Obtain Docker credentials.
  # (This is only necessary once per machine; credentials are cached.)
  docker login


Cleanup:

After running any of the below, consider deleting the docker containers,
which can take up a lot of disk space.

To stop and remove/delete *all* docker containers:
  docker stop $(docker ps -a -q)
  docker rm -vf $(docker ps -aq)
To remove all images:
  docker rmi -f $(docker images -aq)
To remove most everything, including build cache objects:
  docker system prune -a -f


Create the Docker image:

# Alias to create the Docker image, in an empty directory, and upload to Docker Hub.
# Takes about 12 minutes for jdk8, about 1 hour for jdk8-plus.
# Run from a terminal, NOT from Emacs, because it produces vast amounts of output.
DOCKERTESTING=""
# When DOCKERTESTING is enabled, also edit any file containing the string "mdernst/".
# DOCKERTESTING="-testing"
# Arguments: project, OS, JDK version
function create_upload_docker_image {
  DPROJECT=$1
  OS=$2
  JDKVER=$3
  DOCKERIMAGE="mdernst/$DPROJECT-$OS-$JDKVER$DOCKERTESTING"
  if [ -n "$INSIDE_EMACS" ]; then
    echo "Do not run within Emacs"
    return 1
  fi
  (rm -rf dockerdir && \
  mkdir -p dockerdir && \
  cd dockerdir && \
  \cp -pf ../Dockerfile-$OS-$JDKVER Dockerfile && \
  docker build -t $DOCKERIMAGE . && \
  docker push $DOCKERIMAGE && \
  rm -rf dockerdir) || \
  (echo "*****"; echo "*****"; echo "FAILURE in $DOCKERIMAGE"; echo "*****"; echo "*****"; exit 1)
}


create_upload_docker_image daikon ubuntu jdk8 && \
create_upload_docker_image daikon ubuntu jdk8-plus && \
create_upload_docker_image daikon ubuntu jdk11 && \
create_upload_docker_image daikon ubuntu jdk11-plus && \
create_upload_docker_image daikon ubuntu jdk17 && \
create_upload_docker_image daikon ubuntu jdk17-plus && \
create_upload_docker_image daikon ubuntu jdk21 && \
create_upload_docker_image daikon ubuntu jdk21-plus && \
create_upload_docker_image daikon ubuntu jdk24 && \
create_upload_docker_image daikon ubuntu jdk24-plus && \
create_upload_docker_image daikon rockylinux jdk8 && \
create_upload_docker_image daikon rockylinux jdk8-plus && \
create_upload_docker_image daikon rockylinux jdk11 && \
create_upload_docker_image daikon rockylinux jdk11-plus && \
create_upload_docker_image daikon rockylinux jdk17 && \
create_upload_docker_image daikon rockylinux jdk17-plus && \
create_upload_docker_image daikon rockylinux jdk21 && \
create_upload_docker_image daikon rockylinux jdk21-plus && \
create_upload_docker_image daikon rockylinux jdk24 && \
create_upload_docker_image daikon rockylinux jdk24-plus && \
git push
