Skip to content

Commit

Permalink
Merge pull request #1 from ryanlovett/readme-truncate
Browse files Browse the repository at this point in the history
Truncate README. Integrate old infra-requirements.txt.
  • Loading branch information
ryanlovett authored Sep 3, 2024
2 parents d3fd1f6 + 6b6d944 commit 5eed7cb
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 131 deletions.
8 changes: 2 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ RUN /tmp/install-mambaforge.bash
USER ${NB_USER}

COPY environment.yml /tmp/environment.yml
COPY infra-requirements.txt /tmp/infra-requirements.txt
RUN mamba env update -p ${CONDA_DIR} -f /tmp/environment.yml && \
mamba clean -afy

Expand All @@ -80,13 +79,10 @@ RUN R --quiet -e "install.packages('IRkernel', quiet = TRUE)" && \

COPY class-libs.R /tmp/class-libs.R

COPY r-packages/2023-fall-stat-20.r /tmp/r-packages/
RUN r /tmp/r-packages/2023-fall-stat-20.r
COPY r-packages/2024-fall-stat-20.r /tmp/r-packages/
RUN r /tmp/r-packages/2024-fall-stat-20.r

# Configure locking behavior
COPY file-locks /etc/rstudio/file-locks

# Disable visual markdown editing by default
COPY rstudio-prefs.json /etc/rstudio/rstudio-prefs.json

ENTRYPOINT ["tini", "--"]
83 changes: 3 additions & 80 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,82 +1,5 @@
# hub-user-image-template :paperclip:
# stat20-user-image

This is a template repository for creating dedicated user images for UC Berkeley hubs.
This is the repository for the stat20 datahub and local user images.

## Overall workflow :gear:

The overall workflow is to:

1. Create a new repository using this one as a template. Be sure to set the owner as `berkeley-dsep-infra`.

2. Fork that repository to create your image repository (optional, but recommended).

3. Set the appropriate values in the Actions environment variables for `HUB` and `IMAGE`.

4. Customize the image by editing repo2docker files in your image repository.

Changes can either be done by direct commits to main on your image repository, or through a pull request from a fork of your image repository. Direct commits will build the image and push it to Google Artifact Registry (GAR) on merge. PRs will also build the image and offer a link to test it using Binder (currently disabled). Merging the PR will also create and push a commit to the [datahub repo](https://github.com/berkeley-dsep-infra/datahub/), which requires a human to open a PR to merge said commit and deploy that image to the proper hub(s).

5. Configure your Hub to use this new image

More detailed instructions are [located below](https://github.com/berkeley-dsep-infra/hub-user-image-template/#in-depth-guide).

### Modifying the new image

Detailed instructions showing the workflow to modify an image and push it
the CI/CD workflow are located in the [contribution guide](CONTRIBUTING.md)

### In-depth guide

Check out the 2i2c docs for an in-depth guide on how to use this template repository to create a custom user image and use it for your hub :arrow_right: https://infrastructure.2i2c.org/howto/update-env/#split-up-an-image-for-use-with-the-repo2docker-action.

Here's a rough guide on how to create your own fresh user image :arrow_right: https://docs.datahub.berkeley.edu/en/latest/admins/howto/new-image.html.

After creating a new image repo from here as a template, and bringing in the commit history (if any) of the image, you will need to set two [Github Actions Repository Variables](https://docs.github.com/en/actions/learn-github-actions/variables) for the image: `HUB` and `IMAGE`.

`HUB` is the short name of the hub (eg: `data100`, `datahub`, etc).
`IMAGE` is the path to the image in the Artifact Registry (eg: `ucb-datahub-2018/user-images/<hubname>-user-image`)

Next, you will need to give the newly created repo access to two organizational-level [secrets in the berkeley-dsep-infra repo](https://github.com/organizations/berkeley-dsep-infra/settings/secrets/actions): `GAR_SECRET_KEY` (to allow pushes to the Artifact Registry) and `DATAHUB_USER_IMAGE_BRANCH_PUSH` (to allow commits to be pushed to the [datahub](https://github.com/berkeley-dsep-infra/datahub) repo).

## About this template repository :information_source:

This template repository enables [jupyterhub/repo2docker-action](https://github.com/jupyterhub/repo2docker-action).
This GitHub action builds a Docker image using the contents of this repo and pushes it to the [Google Artifact Registry](https://cloud.google.com/artifact-registry) registry.

### The environment

It provides an example of a `environment.yml` conda configuration file for repo2docker to use.
This file can be used to list all the conda packages that need to be installed by `repo2docker` in your environment.
The `repo2docker-action` will update the [base repo2docker](https://github.com/jupyterhub/repo2docker/blob/HEAD/repo2docker/buildpacks/conda/environment.yml) conda environment with the packages listed in this `environment.yml` file.

**Note:**
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).

### Making changes to a single user server image

Once you've created the new image repo from this template, please refer to [the contribution instructions](CONTRIBUTING.md) located in the repo for detailed instructions.

### The GitHub Action workflows

This template repository provides some GitHub Action workflows that can build and push the image to Google Artifact Repository when configured, and test the image on Binder.

![Workflows](images/workflows.png)

#### 1. Build and test container image :arrow_right: [test.yaml](https://github.com/berkeley-dsep-infra/hub-user-image-template/blob/main/.github/workflows/test.yaml)

This workflow is triggered when a Pull Request is opened against the default branch (`main`)..
During PR builds, the image is **only** built and **not** pushed, unless explicitly configured to do so.

#### 2. Test this PR on Binder Badge :arrow_right: [binder.yaml](https://github.com/berkeley-dsep-infra/hub-user-image-template/blob/main/.github/workflows/binder.yaml.disable)

*Temporarily disabled*

Since our images are typically large and take > 10m to build, this means that Binderhub builds will currently time out.

This workflow posts a comment inside a pull request, every time a pull request gets opened. The comment contains a "Test this PR on Binder" badge, which can be used to access the image defined by the PR in [mybinder.org](https://mybinder.org/).

![Test this PR on Binder](images/binder-badge.png)

#### 3. Build, test and push container image :arrow_right: [build-push-open-pr.yaml](https://github.com/berkeley-dsep-infra/hub-user-image-template/blob/main/.github/workflows/build-push-image-commit.yaml)

After a PR is merged to `main`, this workflow builds the image again, pushes to the Artifact Registry and will create a push to the [Datahub repo](https://github.com/berkeley-dsep-infra/datahub) to update the image tag for any hubs that use this image. The PR there will need to be created manually.
See this repository's CONTRIBUTING.md for instructions. That information will eventually be migrated to docs.datahub.berkeley.edu.
35 changes: 22 additions & 13 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,31 @@ channels:
- conda-forge

dependencies:
- syncthing==1.22.2
- jupyter-server-proxy==4.2.0
- jupyter-rsession-proxy==2.2.0
# Matches version in images/hub/Dockerfile
- jupyterhub==4.1.6
- jupyterlab==4.2.5
- jupyter-server-proxy==4.4.0
- jupyter-rsession-proxy==2.2.1
- jupyter-syncthing-proxy==1.0.3
- jupyter-archive==3.4.0
- jupyter-resource-usage==1.1.0
- notebook==7.2.2
- nbconvert==7.6.0
- nbgitpuller==1.2.1
- ipywidgets==8.0.7
# bug w/notebook and traitlets: https://github.com/jupyter/notebook/issues/7048
- traitlets=5.9.*
# for usage analysis dashboard (to be removed during sp 24 maintenance window)
- pandas==2.2.1
#- traitlets=5.9.*
- matplotlib==3.8.3
- shiny==1.0.0
- appmode==1.0.0
- syncthing==1.22.2
- gh-scoped-creds==4.1
- pip
- pip:
- -r /tmp/infra-requirements.txt
# For push authentication to GitHub
- gh-scoped-creds==4.1
- git-credential-helpers==0.2
# Measure popularity of different packages in our hubs
# https://discourse.jupyter.org/t/request-for-implementation-instrument-libraries-actively-used-by-users-on-a-jupyterhub/7994?u=yuvipanda
- git+https://github.com/shaneknapp/python-popularity-contest.git@add-error-handling
- jupyter-shiny-proxy==1.1
# for notebook exporting
- nbconvert==7.6.0
- nb2pdf==0.6.2
- nbpdfexport==0.2.1
- shiny==0.8.1 # for usage analysis dashboard (to be removed during sp 24 maintenance window)

29 changes: 0 additions & 29 deletions infra-requirements.txt

This file was deleted.

File renamed without changes.
3 changes: 0 additions & 3 deletions rstudio-prefs.json

This file was deleted.

0 comments on commit 5eed7cb

Please sign in to comment.