Skip to content

Instantly share code, notes, and snippets.

@vfarcic
Created May 8, 2017 10:13
Show Gist options
  • Save vfarcic/977558101802bd94e3bf54438228e9ce to your computer and use it in GitHub Desktop.
Save vfarcic/977558101802bd94e3bf54438228e9ce to your computer and use it in GitHub Desktop.
DFP + Portainer
docker-machine create -d virtualbox test

eval $(docker-machine env test)

docker swarm init \
  --advertise-addr $(docker-machine ip test)

docker-machine ssh test

echo '
version: "3"
networks:
  proxy:
    external: true
services:
  proxy:
    image: vfarcic/docker-flow-proxy:${TAG:-latest}
    ports:
      - 80:80
      - 443:443
      - 8080:8080
    networks:
      - proxy
    environment:
      - LISTENER_ADDRESS=swarm-listener
      - MODE=swarm
    deploy:
      replicas: 3
  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:8080/v1/docker-flow-proxy/reconfigure
      - DF_NOTIFY_REMOVE_SERVICE_URL=http://proxy:8080/v1/docker-flow-proxy/remove
    deploy:
      placement:
        constraints: [node.role == manager]' >proxy.yml

docker network create -d overlay proxy

docker stack deploy -c proxy.yml proxy

echo '
version: "3"
services:
  main:
    image: portainer/portainer
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    networks:
      - proxy
    deploy:
      placement:
        constraints: [node.role == manager]
      labels:
        - com.df.notify=true
        - com.df.distribute=true
        - com.df.servicePath=/portainer/
        - com.df.reqPathSearch=/portainer/
        - com.df.reqPathReplace=/
        - com.df.port=9000
    command: -H unix:///var/run/docker.sock
networks:
  proxy:
    external: true' >portainer.yml

docker stack deploy -c portainer.yml portainer

docker stack ps portainer # Wait until it's running

exit

open "http://$(docker-machine ip test)/portainer/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment