Commit 69150f2f authored by Justin Tyberg's avatar Justin Tyberg

Fix letsencrypt in make-deploy example.

(c) Copyright IBM Corp. 2016
parent cd4e9297
...@@ -59,7 +59,11 @@ make letsencrypt-notebook ...@@ -59,7 +59,11 @@ make letsencrypt-notebook
The first command creates a Docker volume named after the notebook container with a `-secrets` suffix. It then runs the `letsencrypt` client with a slew of options (one of which has you automatically agreeing to the Let's Encrypt Terms of Service, see the Makefile). The second command mounts the secrets volume and configures Jupyter to use the full-chain certificate and private key. The first command creates a Docker volume named after the notebook container with a `-secrets` suffix. It then runs the `letsencrypt` client with a slew of options (one of which has you automatically agreeing to the Let's Encrypt Terms of Service, see the Makefile). The second command mounts the secrets volume and configures Jupyter to use the full-chain certificate and private key.
Be aware: Let's Encrypt has a pretty [low rate limit per domain](https://community.letsencrypt.org/t/public-beta-rate-limits/4772/3) at the moment. Don't exhaust your requests playing around! Be aware: Let's Encrypt has a pretty [low rate limit per domain](https://community.letsencrypt.org/t/public-beta-rate-limits/4772/3) at the moment. You can avoid exhausting your limit by testing against the Let's Encrypt staging servers. To hit their staging servers, set the environment variable `CERT_SERVER=--staging`.
```
make letsencrypt FQDN=host.mydomain.com EMAIL=myemail@somewhere.com CERT_SERVER=--staging
```
Also, keep in mind Let's Encrypt certificates are short lived: 90 days at the moment. You'll need to manually setup a cron job to run the renewal steps at the moment. (You can reuse the first command above.) Also, keep in mind Let's Encrypt certificates are short lived: 90 days at the moment. You'll need to manually setup a cron job to run the renewal steps at the moment. (You can reuse the first command above.)
......
# Copyright (c) Jupyter Development Team. # Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License. # Distributed under the terms of the Modified BSD License.
# BE CAREFUL when using Docker engine <1.10 because running a container with
# `--rm` option while mounting a docker volume may wipe out the volume.
# See issue: https://github.com/docker/docker/issues/17907
# Use letsencrypt production server by default to get a real cert.
# Use CERT_SERVER=--staging to hit the staging server (not a real cert).
letsencrypt: NAME?=notebook letsencrypt: NAME?=notebook
letsencrypt: SECRETS_VOLUME?=$(NAME)-secrets letsencrypt: SECRETS_VOLUME?=$(NAME)-secrets
letsencrypt: TMP_CONTAINER?=$(NAME)-tmp
letsencrypt: CERT_SERVER?=
letsencrypt: letsencrypt:
@test -n "$(FQDN)" || \ @test -n "$(FQDN)" || \
(echo "ERROR: FQDN not defined or blank"; exit 1) (echo "ERROR: FQDN not defined or blank"; exit 1)
@test -n "$(EMAIL)" || \ @test -n "$(EMAIL)" || \
(echo "ERROR: EMAIL not defined or blank"; exit 1) (echo "ERROR: EMAIL not defined or blank"; exit 1)
@docker volume create --name $(SECRETS_VOLUME) > /dev/null @docker volume create --name $(SECRETS_VOLUME) > /dev/null
# Specifying an alternative cert path doesn't work with the --duplicate @docker run -it -p 80:80 \
# setting which we want to use for renewal. --name=$(TMP_CONTAINER) \
@docker run -it --rm -p 80:80 \
-v $(SECRETS_VOLUME):/etc/letsencrypt \ -v $(SECRETS_VOLUME):/etc/letsencrypt \
quay.io/letsencrypt/letsencrypt:latest \ quay.io/letsencrypt/letsencrypt:latest \
certonly \ certonly \
$(CERT_SERVER) \
--keep-until-expiring \
--standalone \ --standalone \
--standalone-supported-challenges http-01 \ --standalone-supported-challenges http-01 \
--agree-tos \ --agree-tos \
--duplicate \
--domain '$(FQDN)' \ --domain '$(FQDN)' \
--email '$(EMAIL)' --email '$(EMAIL)'; \
# The lets encrypt image has an entrypoint so we use the notebook image docker rm -f $(TMP_CONTAINER) > /dev/null
# instead which we know uses tini as the entry and can run arbitrary commands. # The letsencrypt image has an entrypoint, so we use the notebook image
# Here we need to set the permissions so nobody in the proxy container can read # instead so we can run arbitrary commands.
# the cert and key. Plus we want to symlink the certs into the root of the # Here we set the permissions so nobody can read the cert and key.
# /etc/letsencrypt directory so that the FQDN doesn't have to be known later. # We also symlink the certs into the root of the /etc/letsencrypt
@docker run -it --rm \ # directory so that the FQDN doesn't have to be known later.
@docker run -it \
--name=$(TMP_CONTAINER) \
-v $(SECRETS_VOLUME):/etc/letsencrypt \ -v $(SECRETS_VOLUME):/etc/letsencrypt \
$(NOTEBOOK_IMAGE) \ $(NOTEBOOK_IMAGE) \
bash -c "ln -s /etc/letsencrypt/live/$(FQDN)/* /etc/letsencrypt/ && \ bash -c "ln -s /etc/letsencrypt/live/$(FQDN)/* /etc/letsencrypt/ && \
find /etc/letsencrypt -type d -exec chmod 755 {} +" find /etc/letsencrypt -type d -exec chmod 755 {} +"; \
docker rm -f $(TMP_CONTAINER) > /dev/null
letsencrypt-notebook: PORT?=443 letsencrypt-notebook: PORT?=443
letsencrypt-notebook: NAME?=notebook letsencrypt-notebook: NAME?=notebook
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment