version: '3.1'

services:
  pgadmin:
    image: dpage/pgadmin4
    environment:
      PGADMIN_DEFAULT_EMAIL: prod@schoff.it
      PGADMIN_DEFAULT_PASSWORD: example
    restart: always
    volumes:
      - pgadmin-data:/var/lib/pgadmin
    labels:
      - "traefik.enable=true"
      # http (with redirect)
      - "traefik.http.routers.waschweiberpgadmin_http.entrypoints=web"
      - "traefik.http.routers.waschweiberpgadmin_http.rule=Host(`pgadmin.deizisauer-waschweiber.de`)"
      - "traefik.http.routers.waschweiberpgadmin_http.middlewares=https_redirect"

      # https
      - "traefik.http.routers.waschweiberpgadmin_https.rule=Host(`pgadmin.deizisauer-waschweiber.de`)"
      - "traefik.http.routers.waschweiberpgadmin_https.entrypoints=websecure"
      - "traefik.http.routers.waschweiberpgadmin_https.tls.certresolver=letsencrypt"
      - "traefik.http.services.waschweiberpgadmin_https.loadbalancer.server.port=80"

    networks:
      - traefik
      - shared-pgadmin

  #web:
  #  build: .
  #  restart: always
  #  labels:
  #    - "traefik.enable=true"
  #    # http (with redirect)
  #    - "traefik.http.routers.goapi_http.entrypoints=web"
  #    - "traefik.http.routers.goapi_http.rule=Host(`goapi.dev.duckduckfuck.com`)"
  #    - "traefik.http.routers.goapi_http.middlewares=https_redirect"
  #    # https
  #    - "traefik.http.routers.goapi_https.rule=Host(`goapi.dev.duckduckfuck.com`)"
  #    - "traefik.http.routers.goapi_https.entrypoints=websecure"
  #    - "traefik.http.routers.goapi_https.tls.certresolver=letsencrypt"
  #    - "traefik.http.services.goapi_https.loadbalancer.server.port=8082"
  #  networks:
  #    #- shared-traefik
  #    - shared-web

  postgres-db:
    image: postgres:11.6
    restart: always
    environment:
      POSTGRES_USER: web
      POSTGRES_PASSWORD: example
    volumes:
      - postgres-data:/var/lib/postgresql/data
    networks:
      - shared-pgadmin
      - shared-web

  web:
    build: .
    restart: always
    env_file:
      - web.env
    labels:
            - "traefik.enable=true"
            # http (with redirect)
            - "traefik.http.routers.waschweiberweb_http.entrypoints=web"
            - "traefik.http.routers.waschweiberweb_http.rule=Host(`deizisauer-waschweiber.de`)"
            - "traefik.http.routers.waschweiberweb_http.middlewares=https_redirect"

            # https
            - "traefik.http.routers.waschweiberweb_https.rule=Host(`deizisauer-waschweiber.de`)"
            - "traefik.http.routers.waschweiberweb_https.entrypoints=websecure"
            - "traefik.http.routers.waschweiberweb_https.tls.certresolver=letsencrypt"
            - "traefik.http.services.waschweiberweb_https.loadbalancer.server.port=8082"
    networks:
            - traefik
            - shared-web

volumes:
  postgres-data:
  pgadmin-data:

networks:
  shared-web:
  traefik:
    external:
      name: traefik
  shared-pgadmin:
