diff --git a/README.md b/README.md index 2d27f16..b3c258a 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,15 @@ # High-Throughput Computing Notebooks This repository contains the source Dockerfiles for -CHTC's High-Throughput Computing Notebooks (HTC Notebook). -Each notebook is based on one of the [Jupyter Docker Stacks](https://github.com/jupyter/docker-stacks), +CHTC's High-Throughput Computing Notebooks (HTC Notebooks). +Each notebook is based on one of the +[Jupyter Docker Stacks](https://github.com/jupyter/docker-stacks), as specified by their names. -A HTC Notebook contains both a Jupyter Lab and a "personal" HTCondor that can run jobs locally. -It can also be configured as (for example) part of a Jupyter Hub which connects users to a larger HTCondor pool. +A HTC Notebook contains both a Jupyter Lab and a "personal" HTCondor that can +run jobs locally. +It can also be configured as part of a Jupyter Hub which connects +users to a larger HTCondor pool. ## Quick Start @@ -20,4 +23,4 @@ Replace `htc-scipy-notebook` with your preferred stack, and `latest` with your preferred tag. The `latest` tag will always point at the most recent version of that stack, -but SHA-tagged previous version are available as well. +but date-tagged previous version are available as well. diff --git a/make.py b/make.py index 2157005..ecdecc9 100644 --- a/make.py +++ b/make.py @@ -8,20 +8,33 @@ NOTEBOOKS_DIR = ROOT / 'notebooks' TEMPLATE_DIR = ROOT / 'template' -shutil.rmtree(NOTEBOOKS_DIR, ignore_errors = True) -NOTEBOOKS_DIR.mkdir() +# get the base Dockerfile text +DF_TEMPLATE = (TEMPLATE_DIR / 'Dockerfile').read_text() -(NOTEBOOKS_DIR / 'DO_NOT_MODIFY').write_text('DO NOT MODIFY ANYTHING IN THIS DIRECTORY\nIT IS GENERATED BY make.py\n') -for base_image in (ROOT / 'BASE_IMAGES.txt').read_text().splitlines(): - repo, image, tag = re.match(r'(.*)\/(.*):(.*)', base_image).groups() +def main(): + shutil.rmtree(NOTEBOOKS_DIR, ignore_errors = True) + NOTEBOOKS_DIR.mkdir() - our_image = 'htc-{}'.format(image) + (NOTEBOOKS_DIR / 'DO_NOT_MODIFY').write_text( + 'DO NOT MODIFY ANYTHING IN THIS DIRECTORY\nIT IS GENERATED BY make.py\n' + ) - image_dir = NOTEBOOKS_DIR / our_image - shutil.copytree(TEMPLATE_DIR, image_dir, ignore = lambda *_: ['Dockerfile']) + for base_image in (ROOT / 'BASE_IMAGES.txt').read_text().splitlines(): + repo, image, tag = re.match(r'(.*)\/(.*):(.*)', base_image).groups() - df = image_dir / 'Dockerfile' - df_template = (TEMPLATE_DIR / 'Dockerfile').read_text() - df_text = df_template.replace('', base_image) - df.write_text(df_text) + our_image = 'htc-{}'.format(image) + + image_dir = NOTEBOOKS_DIR / our_image + + # copy everything but the Dockerfile, which will be done in the next step + shutil.copytree(TEMPLATE_DIR, image_dir, ignore = lambda *_: ['Dockerfile']) + + # write out the the modified Dockerfile for this image + df = image_dir / 'Dockerfile' + df_text = DF_TEMPLATE.replace('', base_image) + df.write_text(df_text) + + +if __name__ == '__main__': + main()