diff --git a/.travis.yml b/.travis.yml index fbe991dd2..40d75cfa4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,115 +19,113 @@ jobs: name: "Arch Linux" if: fork = false script: - - docker build -f precice/Dockerfile.Arch -t $DOCKER_USERNAME/precice-arch-develop . + - python build_precice.py --dockerfile precice/Dockerfile.Arch deploy: skip_cleanup: true provider: script on: all_branches: true script: >- - echo "$DOCKER_PASSWORD" | docker login -u $DOCKER_USERNAME --password-stdin && - docker push $DOCKER_USERNAME/precice-arch-develop:latest + echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && + python push_precice.py --dockerfile precice/Dockerfile.Arch - stage: Building preCICE name: "Ubuntu 16.04 home" if: fork = false script: - - docker build -f precice/Dockerfile.Ubuntu1604.home -t $DOCKER_USERNAME/precice-ubuntu1604.home-develop . + - python build_precice.py --dockerfile precice/Dockerfile.Ubuntu1604.home deploy: skip_cleanup: true provider: script on: all_branches: true script: >- - echo "$DOCKER_PASSWORD" | docker login -u $DOCKER_USERNAME --password-stdin && - docker push $DOCKER_USERNAME/precice-ubuntu1604.home-develop:latest + echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && + python push_precice.py --dockerfile precice/Dockerfile.Ubuntu1604.home - stage: Building preCICE name: "Ubuntu 16.04 home PETSc [Job failure permitted]" if: fork = false script: - - > - docker build -f precice/Dockerfile.Ubuntu1604.home -t $DOCKER_USERNAME/precice-ubuntu1604.home.petsc-develop . - --build-arg petsc_para=yes + - python build_precice.py --dockerfile precice/Dockerfile.Ubuntu1604.home --petsc yes deploy: skip_cleanup: true provider: script on: all_branches: true script: >- - echo "$DOCKER_PASSWORD" | docker login -u $DOCKER_USERNAME --password-stdin && - docker push $DOCKER_USERNAME/precice-ubuntu1604.home.petsc-develop:latest + echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && + python push_precice.py --dockerfile precice/Dockerfile.Ubuntu1604.home --petsc yes - stage: Building preCICE name: "Ubuntu 16.04.sudo" if: type = cron script: - - docker build -f precice/Dockerfile.Ubuntu1604.sudo -t $DOCKER_USERNAME/precice-ubuntu1604.sudo-develop . + - python build_precice.py --dockerfile precice/Dockerfile.Ubuntu1604.sudo deploy: skip_cleanup: true provider: script on: all_branches: true script: >- - echo "$DOCKER_PASSWORD" | docker login -u $DOCKER_USERNAME --password-stdin && - docker push $DOCKER_USERNAME/precice-ubuntu1604.sudo-develop:latest + echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && + python push_precice.py --dockerfile precice/Dockerfile.Ubuntu1604.sudo - stage: Building preCICE name: "Ubuntu 18.04.home" if: fork = false script: - - docker build -f precice/Dockerfile.Ubuntu1804.home -t $DOCKER_USERNAME/precice-ubuntu1804.home-develop . + - python build_precice.py --dockerfile precice/Dockerfile.Ubuntu1804.home deploy: skip_cleanup: true provider: script on: all_branches: true script: >- - echo "$DOCKER_PASSWORD" | docker login -u $DOCKER_USERNAME --password-stdin && - docker push $DOCKER_USERNAME/precice-ubuntu1804.home-develop:latest + echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && + python push_precice.py --dockerfile precice/Dockerfile.Ubuntu1804.home - stage: Building preCICE name: "Ubuntu 18.04.sudo" if: type = cron script: - - docker build -f precice/Dockerfile.Ubuntu1804.sudo -t $DOCKER_USERNAME/precice-ubuntu1804.sudo-develop . + - python build_precice.py --dockerfile precice/Dockerfile.Ubuntu1804.sudo deploy: skip_cleanup: true provider: script on: all_branches: true script: >- - echo "$DOCKER_PASSWORD" | docker login -u $DOCKER_USERNAME --password-stdin && - docker push $DOCKER_USERNAME/precice-ubuntu1804.sudo-develop + echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && + python push_precice.py --dockerfile precice/Dockerfile.Ubuntu1804.sudo - stage: Building preCICE name: "Ubuntu 18.04.sudo.mpich [Job failure permitted]" if: type = cron script: - - docker build -f precice/Dockerfile.Ubuntu1804.sudo.mpich -t $DOCKER_USERNAME/precice-ubuntu1804.sudo.mpich-develop . + - python build_precice.py --dockerfile precice/Dockerfile.Ubuntu1804.sudo.mpich deploy: skip_cleanup: true provider: script on: all_branches: true script: >- - echo "$DOCKER_PASSWORD" | docker login -u $DOCKER_USERNAME --password-stdin && - docker push $DOCKER_USERNAME/precice-ubuntu1804.sudo.mpich-develop:latest + echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && + python push_precice.py --dockerfile precice/Dockerfile.Ubuntu1804.sudo.mpich - stage: Building preCICE name: "Ubuntu 18.04.package" if: fork = false script: - - docker build -f precice/Dockerfile.Ubuntu1804.package -t $DOCKER_USERNAME/precice-ubuntu1804.package-develop . + - python build_precice.py --dockerfile precice/Dockerfile.Ubuntu1804.package deploy: skip_cleanup: true provider: script on: all_branches: true script: >- - echo "$DOCKER_PASSWORD" | docker login -u $DOCKER_USERNAME --password-stdin && - docker push $DOCKER_USERNAME/precice-ubuntu1804.package-develop + echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && + python push_precice.py --dockerfile precice/Dockerfile.Ubuntu1804.package - name: "[Build preCICE on fork] Using cached version" if: fork = true @@ -139,112 +137,106 @@ jobs: name: SU2 adapter if: fork = false script: - - docker build -f adapters/Dockerfile.su2-adapter -t $DOCKER_USERNAME/su2-adapter-ubuntu1604.home-develop . + - python build_adapter.py --dockerfile adapters/Dockerfile.su2-adapter --operating-system ubuntu1604 --precice-installation home deploy: skip_cleanup: true provider: script on: all_branches: true script: >- - echo "$DOCKER_PASSWORD" | docker login -u $DOCKER_USERNAME --password-stdin && - docker push $DOCKER_USERNAME/su2-adapter-ubuntu1604.home-develop + echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && + python push_adapter.py --dockerfile adapters/Dockerfile.su2-adapter --operating-system ubuntu1604 --precice-installation home - name: CalculiX adapter if: fork = false script: - - docker build -f adapters/Dockerfile.calculix-adapter -t $DOCKER_USERNAME/calculix-adapter-ubuntu1604.home-develop . + - python build_adapter.py --dockerfile adapters/Dockerfile.calculix-adapter --operating-system ubuntu1604 --precice-installation home deploy: skip_cleanup: true provider: script on: all_branches: true script: >- - echo "$DOCKER_PASSWORD" | docker login -u $DOCKER_USERNAME --password-stdin && - docker push $DOCKER_USERNAME/calculix-adapter-ubuntu1604.home-develop + echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && + python push_adapter.py --dockerfile adapters/Dockerfile.calculix-adapter --operating-system ubuntu1604 --precice-installation home - name: deal.ii adapter if: fork = false script: - - docker build -f adapters/Dockerfile.dealii-adapter -t $DOCKER_USERNAME/dealii-adapter-ubuntu1604.home-develop . + - python build_adapter.py --dockerfile adapters/Dockerfile.dealii-adapter --operating-system ubuntu1604 --precice-installation home deploy: skip_cleanup: true provider: script on: all_branches: true script: >- - echo "$DOCKER_PASSWORD" | docker login -u $DOCKER_USERNAME --password-stdin && - docker push $DOCKER_USERNAME/dealii-adapter-ubuntu1604.home-develop + echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && + python push_adapter.py --dockerfile adapters/Dockerfile.dealii-adapter --operating-system ubuntu1604 --precice-installation home - - name: openFOAM adapter + - name: "[16.04] openFOAM adapter" if: fork = false script: - - docker build -f adapters/Dockerfile.openfoam-adapter -t $DOCKER_USERNAME/openfoam-adapter-ubuntu1604.home-develop . + - python build_adapter.py --dockerfile adapters/Dockerfile.openfoam-adapter --operating-system ubuntu1604 --precice-installation home deploy: skip_cleanup: true provider: script on: all_branches: true script: >- - echo "$DOCKER_PASSWORD" | docker login -u $DOCKER_USERNAME --password-stdin && - docker push $DOCKER_USERNAME/openfoam-adapter-ubuntu1604.home-develop + echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && + python push_adapter.py --dockerfile adapters/Dockerfile.openfoam-adapter --operating-system ubuntu1604 --precice-installation home - name: "[18.04] openFOAM adapter" if: fork = false script: - - docker build -f adapters/Dockerfile.openfoam-adapter.Ubuntu1804 -t $DOCKER_USERNAME/openfoam-adapter-ubuntu1804.home-develop . + - python build_adapter.py --dockerfile adapters/Dockerfile.openfoam-adapter --operating-system ubuntu1804 --precice-installation home deploy: skip_cleanup: true provider: script on: all_branches: true script: >- - echo "$DOCKER_PASSWORD" | docker login -u "precice" --password-stdin && - docker push precice/openfoam-adapter-ubuntu1804.home-develop + echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && + python push_adapter.py --dockerfile adapters/Dockerfile.openfoam-adapter --operating-system ubuntu1804 --precice-installation home - name: FEniCS adapter if: fork = false script: - - > - docker build -f adapters/Dockerfile.fenics-adapter -t $DOCKER_USERNAME/fenics-adapter-ubuntu1804.home-develop - --build-arg from=$DOCKER_USERNAME/precice-ubuntu1804.home-develop . + - python build_adapter.py --dockerfile adapters/Dockerfile.fenics-adapter --operating-system ubuntu1804 --precice-installation home deploy: skip_cleanup: true provider: script on: all_branches: true script: >- - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin && - docker push $DOCKER_USERNAME/fenics-adapter-ubuntu1804.home-develop + echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && + python push_adapter.py --dockerfile adapters/Dockerfile.fenics-adapter --operating-system ubuntu1804 --precice-installation home - name: openFOAM adapter [PETSc] [Job failure permitted] if: fork = false script: - - > - docker build -f adapters/Dockerfile.openfoam-adapter -t $DOCKER_USERNAME/openfoam-adapter-ubuntu1604.home.petsc-develop - --build-arg from=$DOCKER_USERNAME/precice-ubuntu1604.home.petsc-develop . + - python build_adapter.py --dockerfile adapters/Dockerfile.openfoam-adapter --operating-system ubuntu1604 --precice-installation home --petsc yes deploy: skip_cleanup: true provider: script on: all_branches: true script: >- - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin && - docker push $DOCKER_USERNAME/openfoam-adapter-ubuntu1604.home.petsc-develop + echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && + python push_adapter.py --dockerfile adapters/Dockerfile.openfoam-adapter --operating-system ubuntu1604 --precice-installation home --petsc yes - name: CalculiX adapter [PETSc] [Job failure permitted] if: fork = false script: - - > - docker build -f adapters/Dockerfile.calculix-adapter -t $DOCKER_USERNAME/calculix-adapter-ubuntu1604.home.petsc-develop - --build-arg from=$DOCKER_USERNAME/precice-ubuntu1604.home.petsc-develop . + - python build_adapter.py --dockerfile adapters/Dockerfile.calculix-adapter --operating-system ubuntu1604 --precice-installation home --petsc yes deploy: skip_cleanup: true provider: script on: all_branches: true script: >- - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin && - docker push $DOCKER_USERNAME/calculix-adapter-ubuntu1604.home.petsc-develop + echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin && + python push_adapter.py --dockerfile adapters/Dockerfile.calculix-adapter --operating-system ubuntu1604 --precice-installation home --petsc yes - name: "[Build adapters on fork] Using cached version" if: fork = true diff --git a/build_adapter.py b/build_adapter.py new file mode 100644 index 000000000..2673c7135 --- /dev/null +++ b/build_adapter.py @@ -0,0 +1,54 @@ +import argparse, docker +import system_testing +import os + +if __name__ == "__main__": + # Parsing flags + parser = argparse.ArgumentParser(description='Build local docker image of an adapter.') + parser.add_argument('-d', '--dockerfile', type=str, help="Choose Dockerfile you want to build", default="adapters/Dockerfile.fenics-adapter") + parser.add_argument('-b', '--branch', help="preCICE branch to use", default="develop") + parser.add_argument('-u', '--docker-username', help="docker username", default=os.environ["DOCKER_USERNAME"] if "DOCKER_USERNAME" in os.environ else "precice") + parser.add_argument('-os', '--operating-system', help="Operating system used by preCICE base image", default="ubuntu1604") + parser.add_argument('-i', '--precice-installation', help="Installation mode used for preCICE", default="home") + parser.add_argument('-p', '--petsc', help="set 'yes', if you want to use a preCICE base image that was built with PETSc.", default="no", choices={'yes', 'no'}) + parser.add_argument('-f', '--force-rebuild', nargs='+', help="Force rebuild of variable parts of docker image", default = [], choices = ["precice", "tests"]) + args = parser.parse_args() + + dockerfile = os.path.basename(args.dockerfile) + assert(dockerfile.split(".")[0] == "Dockerfile") # We have the convention that our Dockerfiles always start with the term "Dockerfile" + + adapter_name = dockerfile.split(".")[1] # Extract adapter name from filename + + # converting features provided via command-line to dictionary + features = dict() + assert(args.operating_system) + if args.operating_system: # first feature is mandatory always describes the os + features["os"] = args.operating_system + if args.precice_installation: # second feature is optional if it exists it describes the preCICE installation + features["installation"] = args.precice_installation + if args.petsc == "yes": + features["petsc"] = "yes" + + tag = system_testing.compose_tag(args.docker_username, adapter_name, features, args.branch) + + # converting features provided via command-line to dictionary + precice_base_features = dict() + assert(args.operating_system) + if args.operating_system: # first feature is mandatory always describes the os + precice_base_features["os"] = args.operating_system + if args.precice_installation: # second feature is optional if it exists it describes the preCICE installation + precice_base_features["installation"] = args.precice_installation + if args.petsc == "yes": + precice_base_features["petsc"] = "yes" + + precice_base_tag = system_testing.compose_tag(args.docker_username, "precice", precice_base_features, args.branch) + + print("Building {} image with the following features: {}".format(adapter_name, features)) + + docker.build_image(tag=tag, + dockerfile=args.dockerfile, + build_args={"branch" : args.branch, + "from" : precice_base_tag}, + force_rebuild=args.force_rebuild, + namespace="") + diff --git a/build_precice.py b/build_precice.py new file mode 100644 index 000000000..8f8b52414 --- /dev/null +++ b/build_precice.py @@ -0,0 +1,45 @@ +import argparse, docker +import system_testing +import os + +if __name__ == "__main__": + # Parsing flags + parser = argparse.ArgumentParser(description='Build local docker image of preCICE.') + parser.add_argument('-d', '--dockerfile', type=str, help="Choose Dockerfile you want to build", default="precice/Dockerfile.Ubuntu1604.home") + parser.add_argument('-b', '--branch', help="preCICE branch to use", default="develop") + parser.add_argument('-p', '--petsc', help="set 'yes', if you want to build with PETSc.", default="no", choices={'yes', 'no'}) + parser.add_argument('-u', '--docker-username', help="docker username", default=os.environ["DOCKER_USERNAME"] if "DOCKER_USERNAME" in os.environ else "precice") + parser.add_argument('-f', '--force-rebuild', nargs='+', help="Force rebuild of variable parts of docker image", default = [], choices = ["precice", "tests"]) + args = parser.parse_args() + + dockerfile = os.path.basename(args.dockerfile) + assert(dockerfile.split(".")[0] == "Dockerfile") # We have the convention that our Dockerfiles always start with the term "Dockerfile" + + # converting features provided in filename to dictionary + features = dict() + i = 0 + for feature in dockerfile.split(".")[1:]: # Extract features from filename and join features with "." as separator. + i += 1 + if i == 1: # first feature is mandatory always describes the os + assert(feature in ["Ubuntu1604", "Ubuntu1804", "Arch"]) # we expect that one of the following operating systems is used + features["os"] = feature + if i == 2: # second feature is optional if it exists it describes the preCICE installation + assert(feature in ["package", "home", "sudo"]) # we expect that one of the following installation procedures is used + features["installation"] = feature + if i >= 3: # third and following features are optional + assert(feature in ["mpich"]) # we expect one of these optional features + if feature is "mpich": + features["mpich"] = "yes" + assert(i > 0) # at least one feature (the os) should have been provided + if args.petsc == "yes": + features["petsc"] = "yes" + + print("Building preCICE image with the following features: {}".format(features)) + + tag = system_testing.compose_tag(args.docker_username, "precice", features, args.branch) + docker.build_image(tag=tag, + dockerfile=args.dockerfile, + build_args={"branch" : args.branch, "petsc_para" : args.petsc}, + force_rebuild=args.force_rebuild, + namespace="") + diff --git a/docker.py b/docker.py index 7bad9f37a..67c121cdf 100644 --- a/docker.py +++ b/docker.py @@ -22,10 +22,15 @@ def get_containers(): images = cp.stdout.decode().split("\n") return [i for i in images if len(i) > 0] # Remove empty lines -def build_image(tag, dockerfile = "Dockerfile", build_args = {}, force_rebuild = False): +def build_image(tag, dockerfile="Dockerfile", build_args={}, force_rebuild=False, namespace=get_namespace()): if force_rebuild: build_args["CACHEBUST"] = datetime.datetime.now().isoformat() # A unique string for every invocation args = " ".join(["--build-arg " + a + "=" + b for a, b in build_args.items()]) - cmd = "docker build --network=host --file {dockerfile} --tag {namespace}{tag} {build_args} .".format(dockerfile=dockerfile, namespace=get_namespace(), tag=tag.lower(), build_args=args) + cmd = "docker build --network=host --file {dockerfile} --tag {namespace}{tag} {build_args} .".format(dockerfile=dockerfile, namespace=namespace, tag=tag.lower(), build_args=args) + print("EXECUTING:", cmd) + subprocess.run(cmd, shell = True, check = True) + +def push_image(tag, namespace=get_namespace()): + cmd = "docker push {namespace}{tag}:latest".format(namespace=namespace, tag=tag.lower()) print("EXECUTING:", cmd) subprocess.run(cmd, shell = True, check = True) diff --git a/push_adapter.py b/push_adapter.py new file mode 100644 index 000000000..0f843a85e --- /dev/null +++ b/push_adapter.py @@ -0,0 +1,36 @@ +import argparse, docker +import system_testing +import os + +if __name__ == "__main__": + # Parsing flags + parser = argparse.ArgumentParser(description='Push local adapter image to Docker Hub.') + parser.add_argument('-d', '--dockerfile', type=str, help="Choose Dockerfile you want to build", default="adapters/Dockerfile.fenics-adapter") + parser.add_argument('-b', '--branch', help="preCICE branch to use", default="develop") + parser.add_argument('-u', '--docker-username', help="docker username", default=os.environ["DOCKER_USERNAME"] if "DOCKER_USERNAME" in os.environ else "precice") + parser.add_argument('-os', '--operating-system', help="Operating system used by preCICE base image", default="ubuntu1604") + parser.add_argument('-i', '--precice-installation', help="Installation mode used for preCICE", default="home") + parser.add_argument('-p', '--petsc', help="set 'yes', if you want to use a preCICE base image that was built with PETSc.", default="no", choices={'yes', 'no'}) + parser.add_argument('-f', '--force-rebuild', nargs='+', help="Force rebuild of variable parts of docker image", default = [], choices = ["precice", "tests"]) + args = parser.parse_args() + + dockerfile = os.path.basename(args.dockerfile) + assert(dockerfile.split(".")[0] == "Dockerfile") # We have the convention that our Dockerfiles always start with the term "Dockerfile" + + adapter_name = dockerfile.split(".")[1] # Extract adapter name from filename + + # converting features provided via command-line to dictionary + features = dict() + assert(args.operating_system) + if args.operating_system: # first feature is mandatory always describes the os + features["os"] = args.operating_system + if args.precice_installation: # second feature is optional if it exists it describes the preCICE installation + features["installation"] = args.precice_installation + if args.petsc == "yes": + features["petsc"] = "yes" + + tag = system_testing.compose_tag(args.docker_username, adapter_name, features, args.branch) + + docker.push_image(tag=tag, + namespace="") + diff --git a/push_precice.py b/push_precice.py new file mode 100644 index 000000000..b2bba3dcd --- /dev/null +++ b/push_precice.py @@ -0,0 +1,39 @@ +import argparse, docker +import system_testing +import os + +if __name__ == "__main__": + # Parsing flags + parser = argparse.ArgumentParser(description='Build local preCICE image to Docker Hub.') + parser.add_argument('-d', '--dockerfile', type=str, help="Choose Dockerfile you want to build", default="precice/Dockerfile.Ubuntu1604.home") + parser.add_argument('-b', '--branch', help="preCICE branch to use", default="develop") + parser.add_argument('-p', '--petsc', help="set 'yes', if you want to build with PETSc.", default="no", choices={'yes', 'no'}) + parser.add_argument('-u', '--docker-username', help="docker username", default=os.environ["DOCKER_USERNAME"] if "DOCKER_USERNAME" in os.environ else "precice") + args = parser.parse_args() + + dockerfile = os.path.basename(args.dockerfile) + assert(dockerfile.split(".")[0] == "Dockerfile") # We have the convention that our Dockerfiles always start with the term "Dockerfile" + + # converting features provided in filename to dictionary + features = dict() + i = 0 + for feature in dockerfile.split(".")[1:]: # Extract features from filename and join features with "." as separator. + i += 1 + if i == 1: # first feature is mandatory always describes the os + assert(feature in ["Ubuntu1604", "Ubuntu1804", "Arch"]) # we expect that one of the following operating systems is used + features["os"] = feature + if i == 2: # second feature is optional if it exists it describes the preCICE installation + assert(feature in ["package", "home", "sudo"]) # we expect that one of the following installation procedures is used + features["installation"] = feature + if i >= 3: # third and following features are optional + assert(feature in ["mpich"]) # we expect one of these optional features + if feature is "mpich": + features["mpich"] = "yes" + assert(i > 0) # at least one feature (the os) should have been provided + if args.petsc == "yes": + features["petsc"] = "yes" + + tag = system_testing.compose_tag(args.docker_username, "precice", features, args.branch) + docker.push_image(tag=tag, + namespace="") + diff --git a/system_testing.py b/system_testing.py index 13d6e5f53..f6af979b5 100644 --- a/system_testing.py +++ b/system_testing.py @@ -180,6 +180,42 @@ def build_run_compare(test, tag, branch, local_precice, force_rebuild, rm_all=Fa comparison(pathToRef, pathToOutput) +def compose_tag(docker_username, base, features, branch): + """ + Compose a tag based on certain features of the image. Our tagging system follows this scheme: + + DOCKER_USER/BASE-FEATURES-BRANCH + + Example: + precice/precice-ubuntu1604.home-develop + describes an image with the following properties: + + DOCKER_USER is precice. + I.e. image will be pushed to https://hub.docker.com/u/precice + + BASE is precice. + I.e. the image contains a build of precice. + + FEATURES are ubuntu1604 and home. + I.e. ubuntu1604 is used as operating system and preCICE is installed in a user directory + + BRANCH is develop. + I.e. image is based on the source code provided at precice:develop, https://github.com/precice/precice/tree/develop. + """ + features_list = [] + features_list.append(features.get("os")) + features_list.append(features.get("installation")) + if (features.get("petsc") is "yes"): features_list.append("petsc") + if (features.get("mpich") is "yes"): features_list.append("mpich") + features_list = list(filter(None, features_list)) # filter "None" features that might have been added by dict.get(key), if key did not exist. + + if features_list: # list of features is not empty + tag = docker_username.lower() + "/" + base + "-" + ".".join(features_list).lower() + '-' + branch.lower() + else: # list of features is empty + tag = docker_username.lower() + "/" + base + '-' + branch.lower() + return tag + + if __name__ == "__main__": # Parsing flags parser = argparse.ArgumentParser(description='Build local.')