---
# docker-compose file for logstash
# - see https://www.elastic.co/guide/en/logstash/current/_pulling_the_image.html
#
# DOCKER_HOST=dkhost:2376 docker-compose up -d
# DOCKER_HOST=dkhost:2376 docker stack deploy -c docker-compose.yml services

version: '3.4'
services:

  registry:
    image: registry:2
    ports:
      - 5000:5000
    environment:
      REGISTRY_HTTP_SECRET: aabuioqlwlcpp2
      REGISTRY_HTTP_TLS_CERTIFICATE: /certs/live/xai-corp.net/fullchain.pem
      REGISTRY_HTTP_TLS_KEY: /certs/live/xai-corp.net/privkey.pem
#      REGISTRY_HTTP_LETSENCRYPT_CACHEFILE: /var/run/letsencrypt.cache
#      REGISTRY_HTTP_LETSENCRYPT_EMAIL: r_morgan@sympatico.ca
      REGISTRY_HTTP_HOST: https://dkregistry.xai-corp.net:5000
#      REGISTRY_HTTP_ADDR: dkregistry.xai-corp.net:5000
      REGISTRY_AUTH: htpasswd
      REGISTRY_AUTH_HTPASSWD_PATH: /auth/htpasswd
      REGISTRY_AUTH_HTPASSWD_REALM: Registry Realm
    volumes:
      - /opt/shared/dkregistry/data:/var/lib/registry
      - /opt/shared/letsencrypt-2:/certs
      - /opt/shared/letsencrypt-2:/etc/letsencrypt
      - /opt/shared/dkregistry/auth:/auth
      - /opt/shared/dkregistry/config/config.yml:/etc/docker/registry/config.yml

    deploy:
      mode: replicated
      replicas: 1
      restart_policy:
        condition: any
        delay: "5s"
        max_attempts: 24
      update_config:
        parallelism: 1
        delay: 2s
        order: start-first
      resources:
        limits:
          cpus: '0.2'
          memory: 64M

    logging:
      driver: fluentd
      options:
        fluentd-address: "logs.xai-corp.net:24224"
        fluentd-async-connect: 'true'
        tag: dkregistry


  ui:
    image: joxit/docker-registry-ui:latest
    ports:
    - 8087:80
    environment:
      - REGISTRY_TITLE=Xai Corp. Private Docker Registry
      - REGISTRY_URL=https://dkregistry.xai-corp.net:5000
      - SINGLE_REGISTRY=true
      - DELETE_IMAGES=true

    deploy:
      mode: replicated
      replicas: 1
      restart_policy:
        condition: any
        delay: "1s"
        max_attempts: 1
      update_config:
        parallelism: 1
        delay: 2s
        order: start-first
      resources:
        limits:
          cpus: '2'
          memory: 2048M
