Skip to content

Commit

Permalink
Remove all references to docs_site
Browse files Browse the repository at this point in the history
Add a how-to on enabling staticSites instead
  • Loading branch information
yuvipanda committed Jul 8, 2022
1 parent 878288d commit 5085fac
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 64 deletions.
4 changes: 0 additions & 4 deletions config/clusters/cloudbank/staging.values.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
jupyterhub:
custom:
docs_service:
enabled: true
repo: https://github.com/jupyterhub/nbgitpuller
branch: gh-pages
2i2c:
add_staff_user_ids_to_admin_users: true
add_staff_user_ids_of_type: "google"
Expand Down
34 changes: 0 additions & 34 deletions docs/howto/customize/docs-service.md

This file was deleted.

83 changes: 83 additions & 0 deletions docs/howto/features/static-sites.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Deploy authenticated static websites along the hub

We can deploy *authenticated* static websites on the same domain as the hub
that is only accessible to users who have access to the hub. The source
for these come from git repositories that should contain rendered HTML,
and will be updated every 5 minutes. They can be under any prefix on the
same domain as the hub (such as `/docs`, `/textbook`, etc).

You can enable this with the following config in the `.values.yaml`
file for your hub.

```yaml

dex:
# Enable authentication
enabled: true
hubHostName: <hostname-of-hub>

staticSites:
enabled: true
repo: <url-of-git-repo>
branch: <name-of-git-branch>
host: <hostname-of-hub>
path: <absolute-path-where-content-is-available>

jupyterhub:
hub:
services:
dex:
url: http://dex:5556
oauth_redirect_url: https://<hostname-of-hub>/services/dex/callback
oauth_no_confirm: true
oauth2-proxy:
url: http://dex:9000

```

```{note}
We manually configure the hub services instead of autogenerating
them in our deploy scripts. This leads to some additional copy-pasting and
duplication, but keeps our config explicit and simple.
```

## Example

Here's a sample that hosts the data8 textbook under `https://staging.2i2c.cloud/textbook`:

```yaml
dex:
enabled: true
hubHostName: staging.2i2c.cloud

staticSites:
enabled: true
repo: https://github.com/inferentialthinking/inferentialthinking.github.io
branch: master
host: staging.2i2c.cloud
path: /textbook

jupyterhub:
hub:
services:
dex:
url: http://dex:5556
oauth_redirect_uri: https://staging.2i2c.cloud/services/dex/callback
oauth_no_confirm: true
oauth2-proxy:
url: http://dex:9000
```
This clones the [repo]( https://github.com/inferentialthinking/inferentialthinking.github.io),
checks out the `master` branch and keeps it up to date by doing a
`git pull` every 5 minutes. It is made available under `/textbook`,
and requires users be logged-in to the hub before they can access it.

### Note on relative URLs

Depending on what Static Site Generator has been used to generate the website's static content, it **may** or **may not** use relative paths routing by default.
For example, [Sphinx](https://www.sphinx-doc.org/en/master/) handles relative paths by default, whereas, [Hugo](https://gohugo.io/) leaves all [relative URLs unchanged](https://gohugo.io/content-management/urls/#relative-urls).

However, having relative URLS is a **must** in order for the hub docs service to work. Please check with the docs of your SSG of choice and enable relative URLs if they
aren't enabled already.
```
Binary file removed docs/images/docs-service.png
Binary file not shown.
15 changes: 0 additions & 15 deletions helm-charts/basehub/values.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ properties:
required:
- singleuserAdmin
- cloudResources
- docs_service
- 2i2c
properties:
homepage:
Expand Down Expand Up @@ -297,20 +296,6 @@ properties:
properties:
enabled:
type: boolean
docs_service:
type: object
additionalProperties: false
required:
- enabled
- repo
- branch
properties:
enabled:
type: boolean
repo:
type: string
branch:
type: string
2i2c:
type: object
additionalProperties: false
Expand Down
12 changes: 1 addition & 11 deletions helm-charts/basehub/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ dex:
staticSites:
enabled: false
branch: main

azureFile:
enabled: false
pv:
Expand Down Expand Up @@ -62,10 +61,6 @@ jupyterhub:
projectId: ""
scratchBucket:
enabled: false
docs_service:
enabled: false
repo: ""
branch: ""
2i2c:
# Should 2i2c engineering staff user IDs be injected to the admin_users
# configuration of the JupyterHub's authenticator by our custom
Expand Down Expand Up @@ -459,12 +454,7 @@ jupyterhub:
if authenticator_class == "github" and c.Authenticator.allowed_users:
print("WARNING: hub.config.JupyterHub.authenticator_class was set to github and c.Authenticator.allowed_users was set, custom 2i2c jupyterhub config is now resetting allowed_users to an empty set.")
c.Authenticator.allowed_users = set()
05-add-docs-service-if-enabled: |
from z2jh import get_config
if get_config("custom.docs_service.enabled"):
c.JupyterHub.services.append({"name": "docs", "url": "http://docs-service"})
06-gh-teams: |
05-gh-teams: |
from textwrap import dedent
from tornado import gen, web
from oauthenticator.github import GitHubOAuthenticator
Expand Down

0 comments on commit 5085fac

Please sign in to comment.