---
version: '2.3'
services:
  registry:
    image: registry:{{ .registry_version }}
    container_name: registry
    restart: always
    dns_search: .
    cap_drop:
      - ALL
    cap_add:
      - CHOWN
      - DAC_OVERRIDE
      - SETGID
      - SETUID
    volumes:
      - type: bind
        source: /opt/registry/{{ .registry_version }}/ssl/
        target: /etc/registry/ssl/
      - type: bind
        source: /opt/registry/{{ .registry_version }}/config.yml
        target: /etc/docker/registry/config.yml
    port:
      - 443:5000
    networks:
      - registry
{{- if and .image_registry.ha_vip (ne .image_registry.ha_vip "") }}
  keepalived:
    image: osixia/keepalived:{{ .keepalived_version }}
    container_name: keepalived
    restart: always
    dns_search: .
    cap_drop:
      - ALL
    cap_add:
      - CHOWN
      - DAC_OVERRIDE
      - SETGID
      - SETUID
    depends_on:
      - registry
    volumes:
      - type: bind
        source: /opt/keeplived/{{ .keepalived_version }}/keepalived.conf
        target: /container/service/keepalived/assets/keepalived.conf
      - type: bind
        source: /opt/keeplived/{{ .keepalived_version }}/healthcheck.sh
        target: /etc/keepalived/healthcheck.sh
    networks:
      - registry
{{- end }}
networks:
  registry:
    external: false
