├── runtime.txt ├── images ├── action.png ├── secrets.png ├── configurator.png └── coessing-image-quay.png ├── environment.yml ├── install.R ├── .github └── workflows │ ├── binder.yaml │ ├── test.yaml │ └── build.yaml ├── LICENSE ├── .gitignore └── README.md /runtime.txt: -------------------------------------------------------------------------------- 1 | r-4.1-2022-02-09 -------------------------------------------------------------------------------- /images/action.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuantEcon/jupyterhub-anu-emet2007/main/images/action.png -------------------------------------------------------------------------------- /images/secrets.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuantEcon/jupyterhub-anu-emet2007/main/images/secrets.png -------------------------------------------------------------------------------- /images/configurator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuantEcon/jupyterhub-anu-emet2007/main/images/configurator.png -------------------------------------------------------------------------------- /images/coessing-image-quay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QuantEcon/jupyterhub-anu-emet2007/main/images/coessing-image-quay.png -------------------------------------------------------------------------------- /environment.yml: -------------------------------------------------------------------------------- 1 | # This is the standard conda configuration file. Use this file to list 2 | # the conda packages that you need installed in your environment. 3 | channels: 4 | - conda-forge 5 | 6 | dependencies: 7 | - jupyter_contrib_nbextensions==0.5.1 8 | # Add other packages here 9 | # - 10 | -------------------------------------------------------------------------------- /install.R: -------------------------------------------------------------------------------- 1 | install.packages("tidyverse") 2 | install.packages("rmarkdown") 3 | install.packages("httr") 4 | install.packages("shinydashboard") 5 | install.packages("leaflet") 6 | install.packages("sandwich") 7 | install.packages("zoo") 8 | install.packages("lmtest") 9 | install.packages("tseries") 10 | install.packages("rprojroot") 11 | install.packages("here") 12 | 13 | -------------------------------------------------------------------------------- /.github/workflows/binder.yaml: -------------------------------------------------------------------------------- 1 | # Reference https://mybinder.readthedocs.io/en/latest/howto/gh-actions-badges.html 2 | name: Binder Badge 3 | on: 4 | pull_request_target: 5 | types: [opened] 6 | 7 | permissions: 8 | pull-requests: 9 | write 10 | 11 | jobs: 12 | binder: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: comment on PR with Binder link 16 | uses: actions/github-script@v3 17 | with: 18 | github-token: ${{secrets.GITHUB_TOKEN}} 19 | script: | 20 | var PR_HEAD_USERREPO = process.env.PR_HEAD_USERREPO; 21 | var PR_HEAD_REF = process.env.PR_HEAD_REF; 22 | github.issues.createComment({ 23 | issue_number: context.issue.number, 24 | owner: context.repo.owner, 25 | repo: context.repo.repo, 26 | body: `[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/${PR_HEAD_USERREPO}/${PR_HEAD_REF}) :point_left: Test this PR on Binder` 27 | }) 28 | env: 29 | PR_HEAD_REF: ${{ github.event.pull_request.head.ref }} 30 | PR_HEAD_USERREPO: ${{ github.event.pull_request.head.repo.full_name }} 31 | -------------------------------------------------------------------------------- /.github/workflows/test.yaml: -------------------------------------------------------------------------------- 1 | name: Test container image build 2 | 3 | on: 4 | pull_request: 5 | 6 | jobs: 7 | build: 8 | runs-on: ubuntu-latest 9 | steps: 10 | 11 | # For biggish images, github actions runs out of disk space. 12 | # So we cleanup some unwanted things in the disk image, and reclaim that space for our docker use 13 | # https://github.com/actions/virtual-environments/issues/2606#issuecomment-772683150 14 | # and https://github.com/easimon/maximize-build-space/blob/b4d02c14493a9653fe7af06cc89ca5298071c66e/action.yml#L104 15 | # This gives us a total of about 52G of free space, which should be enough for now 16 | - name: cleanup disk space 17 | run: | 18 | sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc 19 | df -h 20 | 21 | - name: checkout files in repo 22 | uses: actions/checkout@main 23 | 24 | - name: update jupyter dependencies with repo2docker 25 | uses: jupyterhub/repo2docker-action@master 26 | with: # make sure username & password/token matches your registry 27 | NO_PUSH: "true" 28 | DOCKER_REGISTRY: "quay.io" 29 | 30 | # Uncomment and modify the following line with your image name. 31 | IMAGE_NAME: "mmcky/anu-emet2007" 32 | 33 | # Lets us monitor disks getting full as images get bigger over time 34 | - name: Show how much disk space is left 35 | run: df -h -------------------------------------------------------------------------------- /.github/workflows/build.yaml: -------------------------------------------------------------------------------- 1 | name: Build container image 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | steps: 12 | 13 | # For biggish images, github actions runs out of disk space. 14 | # So we cleanup some unwanted things in the disk image, and reclaim that space for our docker use 15 | # https://github.com/actions/virtual-environments/issues/2606#issuecomment-772683150 16 | # and https://github.com/easimon/maximize-build-space/blob/b4d02c14493a9653fe7af06cc89ca5298071c66e/action.yml#L104 17 | # This gives us a total of about 52G of free space, which should be enough for now 18 | - name: cleanup disk space 19 | run: | 20 | sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc 21 | df -h 22 | 23 | - name: Checkout files in repo 24 | uses: actions/checkout@main 25 | 26 | - name: Update jupyter dependencies with repo2docker 27 | uses: jupyterhub/repo2docker-action@master 28 | with: 29 | # Make sure username & password/token pair matches your registry credentials 30 | DOCKER_USERNAME: ${{ secrets.QUAY_USERNAME }} 31 | DOCKER_PASSWORD: ${{ secrets.QUAY_PASSWORD }} 32 | DOCKER_REGISTRY: "quay.io" 33 | 34 | # Uncomment and modify the following line with your image name. 35 | IMAGE_NAME: "mmcky/anu-emet2007" 36 | 37 | # Lets us monitor disks getting full as images get bigger over time 38 | - name: Show how much disk space is left 39 | run: df -h -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2021, 2i2c-org 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # hub-user-image-template 2 | 3 | This is a template repository for creating dedicated user images for our hubs. 4 | 5 | ## About this template repository 6 | 7 | * It enables [jupyterhub/repo2docker-action](https://github.com/jupyterhub/repo2docker-action). 8 | This GitHub action builds a Docker image using the contents of this repo and pushes it to the [Quay.io](https://quay.io/) registry. 9 | 10 | * It provides an example of a `environment.yml` conda configuration file. 11 | This file can be used to list all the conda packages that need to be installed by `repo2docker` in 12 | your environment. 13 | The `repo2docker-action` will update the [base repo2docker](https://github.com/jupyterhub/repo2docker/blob/HEAD/repo2docker/buildpacks/conda/environment.yml) 14 | conda environment with the packages listed in this `environment.yml` file. 15 | 16 | **Note:** 17 | A complete list of possible configuration files that can be added to the repository and be used by repo2docker to build the Docker image, can be found in the [repo2docker docs](https://repo2docker.readthedocs.io/en/latest/config_files.html#configuration-files). 18 | 19 | ## How to create and use a custom user image for your hub 20 | 21 | ### 1. Use this template 22 | 23 | Create a new repository from `hub-user-image-template` repository, by clicking the *Use this template* button located at the top of this project's GitHub page. 24 | 25 | ### 2. Hook the new repository to [quay.io](https://quay.io/) 26 | 27 | Follow all the instructions (except the last step), provided by the [repo2docker-action docs](https://github.com/jupyterhub/repo2docker-action#push-image-to-quayio) on how to allow the built image to be pushed to [quay.io](https://quay.io/). 28 | 29 | When you have completed these steps, you should have: 30 | 31 | * a quay.io repository of the form `quay.io//` 32 | * two GitHub secrets **QUAY_USERNAME** (the user name of the `quay.io` robot account) and **QUAY_PASSWORD** (the password of the `quay.io` robot account) set on your newly created GitHub repository. 33 | 34 | ![Secrets](images/secrets.png) 35 | 36 | ### 3. Update repo2docker-action config 37 | 38 | Edit lines 24 and 25 of [build.yaml](https://github.com/2i2c-org/hub-user-image-template/blob/main/.github/workflows/build.yaml#L24-L25) and: 39 | 40 | * uncomment the `IMAGE_NAME` option 41 | * replace `/` with the info of the `quay.io` repository created at step 2 42 | * Commit the changes you've made to `build.yaml` 43 | 44 | Edit lines 20 and 21 of [test.yaml](https://github.com/2i2c-org/hub-user-image-template/blob/main/.github/workflows/test.yaml#L20-L21) in the same way. 45 | 46 | ### 4. Define the environment wanted 47 | 48 | * Modify [the environment.yml](https://github.com/2i2c-org/hub-user-image-template/blob/main/environment.yml) file and add all the packages you want installed in the conda environment. Note that repo2docker already installs [this list](https://github.com/jupyterhub/repo2docker/blob/HEAD/repo2docker/buildpacks/conda/environment.yml) of packages. More about what you can do with `environment.yml`, can be found in the [repo2docker docs](https://repo2docker.readthedocs.io/en/latest/config_files.html#environment-yml-install-a-conda-environment). 49 | 50 | * Commit the changes made to `environment.yml`. 51 | 52 | * Create a pull request with this commit, or push it dirrectly to the `main` branch. 53 | 54 | * If you merge the PR above or directly push the commit to the `main` branch, the GitHub Action will automatically build and push the container image. Wait for this action to finish. 55 | 56 | ![Actions](images/action.png) 57 | 58 | ### 5. Build and push the image of the repository 59 | 60 | Images generated by this action are automatically tagged with both latest and `` corresponding to the relevant commit SHA on GitHub. Both tags are pushed to the image registry specified by the user. If an existing image with the *latest* tag already exists in your registry, this Action attempts to pull that image as a cache to reduce uncessary build steps. 61 | 62 | Checkout an example of a [quay.io respository](https://quay.io/repository/2i2c/coessing-image?tab=tags) that hosts the user environment image of a 2i2c hub. 63 | 64 | ### 6. Connect the hub with this user image 65 | 66 | * Go to the list of image tags on `quay.io`, and find the tag of the last push. This is not the latest tag but is usually under it. Use this to construct your image name - `quay.io//:`. 67 | 68 | ![Tags list example](images/coessing-image-quay.png) 69 | 70 | * Open the [Configurator](https://pilot.2i2c.org/en/latest/admin/howto/configurator.html) for the hub (you need to be logged in as an admin). 71 | You can access it from the hub control panel, under Services in the top bar or by going to https:///services/configurator/ 72 | 73 | ![Configurator](images/configurator.png) 74 | 75 | * Make a note of the current image name there. 76 | 77 | * Put the image tag you constructed in a previous step into the User docker image text box. 78 | 79 | * Click Submit! *this is alpha level software, so there is no 'has it saved' indicator yet :)* 80 | 81 | You can find more information about the Configurator [here](https://pilot.2i2c.org/en/latest/admin/howto/configurator.html). 82 | 83 | ### 7. Test the new image 84 | 85 | Test the new image by starting a new user server! If you already had one running, you need to stop and start it again to test. 86 | If you find new issues, you can revert back to the previous image by entering the old image name, back in the JupyterHub Configurator. 87 | 88 | *This will be streamlined in the future.* 89 | 90 | ## Push image to a registry other than Quay.io 91 | 92 | The [jupyterhub/repo2docker-action](https://github.com/jupyterhub/repo2docker-action) can build and push the image to registries other than [Quay.io](https://quay.io/). Checkout the [action docs](https://github.com/jupyterhub/repo2docker-action/blob/master/README.md) for the instructions on how to setup your workflow to push to: [AWS Elastic Container Registry](https://github.com/jupyterhub/repo2docker-action#push-repo2docker-image-to-amazon-ecr), [Google Container Registry](https://github.com/jupyterhub/repo2docker-action#push-repo2docker-image-to-google-container-registry) (deprecated but popular), [Google Artifact Registry](https://github.com/jupyterhub/repo2docker-action#push-repo2docker-image-to-google-artifact-registry) (preferred), [Azure Container Registry](https://github.com/jupyterhub/repo2docker-action#push-repo2docker-image-to-azure-container-registry). 93 | 94 | **Note:** 95 | For cloud provider-specific registries, if we are running the cluster on our projects, please contact the 2i2c team to give you credentials for it. --------------------------------------------------------------------------------