volumes:
  couchdb_data:
  db_migrations_data:

services:
  couchdb:
    build: services/couchdb
    image: hereconnect/service-couchdb:${COUCHDB_TAG:-latest}
    ports:
      - "127.0.0.1:5984:5984"
    volumes:
      - couchdb_data:/opt/couchdb/data
    environment:
      - COUCHDB_USER=${COUCHDB_USER}
      - COUCHDB_PASSWORD=${COUCHDB_PASSWORD}
    restart: unless-stopped
    logging:
      driver: "json-file"
      options:
        max-size: "100m"
        max-file: "10"

  db-migrations:
    image: hereconnect/service-db-migrations:${DB_MIGRATIONS_TAG:-latest}
    build:
      context: build/service-db-migrations
      dockerfile: ../../services/db-migrations/Dockerfile
    volumes:
      - db_migrations_data:/opt/db-migrations/data
    environment:
      - API_URL=http://${COUCHDB_USER}:${COUCHDB_PASSWORD}@couchdb:5984
    depends_on:
      couchdb:
        condition: service_healthy
    restart: no
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "1"

  message-delivery-method-web-push:
    image: hereconnect/message-delivery-method-web-push:${MESSAGE_DELIVERY_METHOD_WEB_PUSH_TAG:-latest}
    build:
      context: build/service-message-delivery-method-web-push
      dockerfile: ../../services/message-delivery-method-web-push/Dockerfile
    environment:
      - API_URL=http://${COUCHDB_USER}:${COUCHDB_PASSWORD}@couchdb:5984
      - VAPID_SUBJECT=${VAPID_SUBJECT}
      - GCM_API_KEY=${GCM_API_KEY}
    depends_on:
      couchdb:
        condition: service_healthy
        restart: true
      db-migrations:
        condition: service_completed_successfully
    restart: no
    logging:
      driver: "json-file"
      options:
        max-size: "100m"
        max-file: "10"
