|
| 1 | +# Let's Encrypt |
| 2 | + |
| 3 | +copied from: https://github.com/mtnygard/jupyterhub-deploy-docker/blob/master/Dockerfile.jupyterhub |
| 4 | + |
| 5 | +This example includes a Docker Compose configuration file that you can |
| 6 | +use to deploy [JupyterHub](https://github.com/jupyter/jupyterhub) with |
| 7 | +TLS certificate and key files generated by [Let's Encrypt](https://letsencrypt.org). |
| 8 | + |
| 9 | +The `docker-compose.yml` configuration file in this example extends the |
| 10 | +JupyterHub service defined in the `docker-compose.yml` file in the root |
| 11 | +directory of this repository. |
| 12 | + |
| 13 | +When you run the JupyterHub Docker container using the configuration |
| 14 | +file in this directory, Docker mounts an additional volume containing |
| 15 | +the Let's Encrypt TLS certificate and key files, and overrides the |
| 16 | +`SSL_CERT` and `SSL_KEY` environment variables to point to these files. |
| 17 | + |
| 18 | +## Create a secrets volume |
| 19 | + |
| 20 | +This example stores the Let's Encrypt TLS certificate and key files in |
| 21 | +a Docker volume, and mounts the volume to the JupyterHub container at |
| 22 | +runtime. |
| 23 | + |
| 24 | +Create a volume to store the certificate and key files. |
| 25 | + |
| 26 | +``` |
| 27 | +# Activate Docker machine where JupyterHub will run |
| 28 | +eval "$(docker-machine env jupyterhub)" |
| 29 | +
|
| 30 | +docker volume create --name jupyterhub-secrets |
| 31 | +``` |
| 32 | + |
| 33 | +## Generate Let's Encrypt certificate and key |
| 34 | + |
| 35 | +Run the `letsencrypt.sh` script to create a TLS full-chain certificate |
| 36 | +and key. |
| 37 | + |
| 38 | +The script downloads and runs the `letsencrypt` Docker image to create a |
| 39 | +full-chain certificate and private key, and stores the files in a Docker |
| 40 | +volume. You must provide a valid, routable, fully-qualified domain name (you |
| 41 | +must own it), and you must activate the Docker machine host that the domain |
| 42 | +points to before you run this script. You must also provide a valid email |
| 43 | +address and the name of the volume you created above. |
| 44 | + |
| 45 | +_Notes:_ The script hard codes several `letsencrypt` options, one of which |
| 46 | +automatically agrees to the Let's Encrypt Terms of Service. |
| 47 | + |
| 48 | +``` |
| 49 | +# Activate Docker machine where JupyterHub will run |
| 50 | +eval "$(docker-machine env jupyterhub)" |
| 51 | +
|
| 52 | +./letsencrypt.sh \ |
| 53 | + --domain myhost.mydomain \ |
| 54 | + --email me@mydomain \ |
| 55 | + --volume jupyterhub-secrets |
| 56 | +``` |
| 57 | + |
| 58 | +## Run JupyterHub container |
| 59 | + |
| 60 | +To run the JupyterHub container using the Let's Encrypt certificate and key, |
| 61 | +set the `SECRETS_VOLUME` environment variable to the name of the Docker volume |
| 62 | +containing the certificate and key files, and run `docker-compose` **from the |
| 63 | +root directory** of this repository while specifying the `docker-compose.yml` |
| 64 | +configuration in this directory: |
| 65 | + |
| 66 | +``` |
| 67 | +export SECRETS_VOLUME=jupyterhub-secrets |
| 68 | +
|
| 69 | +docker-compose -f examples/letsencrypt/docker-compose.yml up -d |
| 70 | +``` |
0 commit comments