version: "3.7"
services:

  quay-db:
    container_name: quay-db
    image: postgres:12.1
    environment:
      POSTGRES_USER: "quay"
      POSTGRES_PASSWORD: "quay"
      POSTGRES_DB: "quay"
    volumes:
      - "./local-dev/init/pg_bootstrap.sql:/docker-entrypoint-initdb.d/pg_bootstrap.sql"
    ports:
      - "5432:5432"
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U quay -d quay"]
      interval: 10s
      timeout: 9s
      retries: 3
      start_period: 10s

  clair-db:
    container_name: clair-db
    image: postgres:12.1
    environment:
      POSTGRES_USER: "clair"
      POSTGRES_DB: "clair"
    ports:
      - "5433:5432"
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U clair -d clair"]
      interval: 10s
      timeout: 9s
      retries: 3
      start_period: 10s

  redis:
    container_name: quay-redis
    image: redis:latest
    ports:
      - "6379:6379"

  quay:
    container_name: quay-quay
    image: quay.io/projectquay/quay:3.11.1
    volumes:
      - "/var/lib/docker/quay:/quay-registry"
    ports:
      - "8080:8080"
      - "8443:8443"
    environment:
      DEBUGLOG: "true"
      IGNORE_VALIDATION: "true"

  # clair is configured to share it's network
  # namespace with quay. this allows quay to serve
  # layers to clair over localhost.
  clair:
    container_name: quay-clair
    image: quay.io/projectquay/clair:4.0.0-rc.22
    volumes:
      - "/var/lib/docker/quay-clair:/src/clair/"
    environment:
      CLAIR_CONF: "/src/clair/config.yaml"
      CLAIR_MODE: "combo"
    network_mode: "service:quay"
    command:
      ["bash", "-c", "cd /src/clair/cmd/clair; go run -mod vendor ."]
    depends_on:
      - quay
