---
# docker-compose file for owncloud server

# DOCKER_HOST=dkhost:2376 docker stack deploy -c docker-compose-prod.yml owncloud
# DOCKER_HOST=dkhost:2376 docker stack ps owncloud

version: '3.4'

volumes:
  cache:

services:

  app:
    image: ${REMOTE_IMAGE}
    ports:
      - 8083:80
    volumes:
#      - code:/var/www/html
      - /opt/nextcloud/nextcloud1/data:/var/www/html/data
      - /opt/nextcloud/nextcloud1/config:/var/www/html/config
      - /opt/nextcloud/nextcloud1/apps:/var/www/html/custom_apps
      - /opt/nextcloud/data/nextcloud2:/opt/data/nextcloud2
      - /opt/nextcloud/data/media-server:/opt/data/media-server
    environment:
      - DBTYPE=mysql
      - DBHOST=sql.xai-corp.net
      - DBPORT=3306
      - DBNAME=nextcloud2
      - DBUSER=nextcloud
      - DBPASS=xh891hx1hc89f239hibndnxc1i
      - REDISHOST=tasks.services_redis
      - REDISPORT=6379
      - LOGLEVEL=3
      - PHP_MEMORY_LIMIT=-1

    healthcheck:
      test: ["CMD", "curl", "-If", "http://localhost/status.php"]
      interval: 1m30s
      timeout: 10s
      retries: 3
      start_period: 40s

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

    networks:
    - prod_ui
    - prod_app
    - prod_db
    - prod_cache

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


networks:
  prod_ui:
    external:
      name: prod_ui
  prod_db:
    external:
      name: prod_db
  prod_cache:
    external:
      name: prod_cache
  prod_app:
    external:
      name: prod_app
