Skip to content

Instantly share code, notes, and snippets.

@eoldavix
Created July 30, 2018 11:48
Show Gist options
  • Select an option

  • Save eoldavix/8d32e5b018c2aed2e8ac35830189346f to your computer and use it in GitHub Desktop.

Select an option

Save eoldavix/8d32e5b018c2aed2e8ac35830189346f to your computer and use it in GitHub Desktop.
Docker Stack for Docker Flow Proxy with automatic LetsEncrypt certificate creation
version: "3"
services:
proxy:
image: vfarcic/docker-flow-proxy
ports:
- 80:80
- 443:443
volumes:
- dfp-certs:/certs
networks:
- proxy
environment:
- LISTENER_ADDRESS=swarm-listener
- MODE=swarm
- SERVICE_NAME=proxy_proxy
deploy:
replicas: 1
swarm-listener:
image: vfarcic/docker-flow-swarm-listener
networks:
- proxy
volumes:
- /var/run/docker.sock:/var/run/docker.sock
environment:
- DF_NOTIFY_CREATE_SERVICE_URL=http://proxy-le:8080/v1/docker-flow-proxy-letsencrypt/reconfigure
- DF_NOTIFY_REMOVE_SERVICE_URL=http://proxy:8080/v1/docker-flow-proxy/remove
deploy:
placement:
constraints: [node.role == manager]
proxy-le:
image: nib0r/docker-flow-proxy-letsencrypt
networks:
- proxy
environment:
- DF_PROXY_SERVICE_NAME=proxy_proxy
# - LOG=debug
- CERTBOT_OPTIONS=--update-registration
#- CERTBOT_OPTIONS=--staging
volumes:
- /var/run/docker.sock:/var/run/docker.sock
# create a dedicated volume for letsencrypt folder.
# MANDATORY to keep persistent certificates on DFPLE.
# Without this volume, certificates will be regenerated every time DFPLE is recreated.
# OPTIONALY you will be able to link this volume to another service that also needs certificates (gitlab/gitlab-ce for example)
- le-certs:/etc/letsencrypt
deploy:
replicas: 1
labels:
- com.df.notify=true
- com.df.distribute=true
- com.df.servicePath=/.well-known/acme-challenge
- com.df.port=8080
networks:
proxy:
external: true
volumes:
le-certs:
external: true
dfp-certs:
external: true
@eoldavix
Copy link
Author

Network and Volume creation:

docker volume create le-certs
docker volume create dfp-certs
docker network create -d overlay proxy

Stack execution:

docker stack deploy -c docker-compose.yml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment