pygmystack / pygmy

the pygmy stack is a container stack for local development
MIT License
25 stars 13 forks source link

Request for example pygmy Traefik 2.x integration #153

Closed fubarhouse closed 3 years ago

fubarhouse commented 4 years ago

Background

Followup to #23 for modernization - there have historically been reasons that tie me to v1.x ongoing and/or on occasion, and this aims to fix that permanently.

Implementation

Docker

n/a

Variables

n/a

Volumes

n/a
fubarhouse commented 4 years ago
services:

  amazeeio-haproxy:
    Config:
      Labels:
        - pygmy.enable: false

  amazeeio-mailhog:
    Config:
      Labels:
        - pygmy.enable: true
        - traefik.enable: true
        - traefik.port: 80
        - traefik.http.routers.mailhog.rule: Host(`mailhog.docker.amazee.io`)

  amazeeio-traefik-2:
    Config:
      Image: library/traefik:v2.1.3
      Cmd:
        - --api
        - --api.insecure=true
        - --providers.docker
        - --providers.docker.exposedbydefault=false
        - --providers.docker.defaultrule=Host(`{{ index .Labels "com.docker.compose.project" }}.docker.amazee.io`)
        - --entrypoints.web.address=:80
        - --entrypoints.websecure.address=:443
      ExposedPorts:
        80/tcp:
          HostPort: 80
        443/tcp:
          HostPort: 443
        8080/tcp:
          HostPort: 3080
      Labels:
        - pygmy: pygmy
        - pygmy.enable: true
        - pygmy.name: amazeeio-traefik-2
        - pygmy.url: http://traefik.docker.amazee.io
        - traefik.docker.network: amazeeio-network
        - traefik.enable: true
        - traefik.port: 80
        - traefik.http.routers.traefik.rule: Host(`traefik.docker.amazee.io`)
        - traefik.http.routers.traefik.service: api@internal
        - traefik.providers.docker.defaultport: 8080
    HostConfig:
      Binds:
        - /var/run/docker.sock:/var/run/docker.sock
      PortBindings:
        443/tcp:
          - HostPort: 443
        80/tcp:
          - HostPort: 80
        8080/tcp:
          - HostPort: 8080
      RestartPolicy:
        Name: always
        MaximumRetryCount: 0
    NetworkConfig:
      Ports:
        80/tcp:
          - HostPort: 80
        8080/tcp:
          - HostPort: 8080

networks:
  amazeeio-network:
    Containers:
      amazeeio-traefik-2:
        Name: amazeeio-traefik-2
      amazeeio-mailhog:
        Name: amazeeio-mailhog

resolvers: []

In addition to the above, the following changes will be needed for one of the containers in the docker-compose project (based on the default rule in the traefik container). Convention is trivial, but we can target any of the docker-compose labels (ideally) under com.docker.compose such as project, service etc....

services:
  nginx:
    labels:
      traefik.enable: true
      traefik.port: 8080

Still a bonus: No resolver, no sudo, happy days.

fubarhouse commented 4 years ago
# todo: add example that doesn't inherit defaults