Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add `tls` label (alias of `tls-email`) #19

Merged
merged 2 commits into from Mar 10, 2019

Conversation

Projects
None yet
2 participants
@HugoDF
Copy link
Contributor

HugoDF commented Mar 10, 2019

Closes #18

  • adds a tls label (that gets injected as the tls value if tls-email is not set)
  • update the docs

How to test:

Build container:

docker build -t caddy-gen-dev .

Create empty directory and have a docker-compose.yml file:

version: "3"
services:
  caddy-gen:
    container_name: caddy-gen
    image: "caddy-gen-dev:latest" # IMPORTANT
    restart: always
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro  # needs socket to read events
      - ./certs/acme:/etc/caddy/acme  # to save acme
      - ./certs/ocsp:/etc/caddy/ocsp  # to save certificates
    ports:
      - "80:80"
      - "443:443"
    depends_on:
      - whoami

  whoami:  # this is your service
    image: "katacoda/docker-http-server:v2"
    labels:
      - "virtual.host=myapp.com"  # your domain
      - "virtual.port=80"  # exposed port of this container
      - "virtual.tls=admin@myapp.com"  # ssl is now on

Run:

docker-compose up

Output:

Creating test-caddy-gen-patch_whoami_1 ... done
Creating caddy-gen                     ... done
whoami_1     | Web Server started. Listening on 0.0.0.0:80
caddy-gen    | 2019/03/10 19:02:33 Generated '/etc/caddy/Caddyfile' from 2 containers
caddy-gen    | forego     | starting dockergen.1 on port 5000
caddy-gen    | forego     | starting caddy.1 on port 5100
caddy-gen    | dockergen.1 | 2019/03/10 19:02:33 Contents of /etc/caddy/Caddyfile did not change. Skipping notification ''
caddy-gen    | dockergen.1 | 2019/03/10 19:02:33 Watching docker events
caddy-gen    | dockergen.1 | 2019/03/10 19:02:34 Contents of /etc/caddy/Caddyfile did not change. Skipping notification ''
caddy-gen    | caddy.1    | Activating privacy features... 2019/03/10 19:02:34 [INFO] acme: Registering account for admin@myapp.com

Caddy attempted to create certificates with admin@myapp.com, which means virtual.tls gets injected as the tls directive value.

Alternatively, could attempt to use https://github.com/HugoDF/docker-compose-local-https/tree/master/caddy-gen, switch out the image at https://github.com/HugoDF/docker-compose-local-https/blob/master/caddy-gen/docker-compose.yml#L4 for caddy-gen-dev:latest and switch virtual.tls-email for virtual.tls.

@sobolevn

This comment has been minimized.

Copy link
Member

sobolevn commented Mar 10, 2019

Thanks!

@sobolevn sobolevn merged commit 1b4c950 into wemake-services:master Mar 10, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.