# vim:ft=ansible:
- name: docker deploy nextcloud
  docker_container:
    name: nextcloud
    image: nextcloud:27
    # The entrypoint workaround is for this issue:
    #
    # https://github.com/nextcloud/docker/issues/1414
    #
    # This installs imagemagick to allow for SVG support and to clear the last
    # setup warning in the application.
    # It can be safely removed upon closure of this issue. I'm just doing it to
    # make the big bad triangle go away.
    entrypoint: /bin/sh
    command: -c "apt-get update; apt-get install -y libmagickcore-6.q16-6-extra; /entrypoint.sh apache2-foreground"
    env:
      PHP_UPLOAD_LIMIT: 1024M
    networks:
      - name: web
        aliases: [ "nextcloud" ]
    volumes:
      - /data/nextcloud/custom_apps:/var/www/html/custom_apps
      - /data/nextcloud/config:/var/www/html/config
      - /data/nextcloud/themes:/var/www/html/themes
      - /data/nextcloud/data:/var/www/html/data
      - /data/shared:/shared
  tags: [ docker, nextcloud ]
- name: assure nextcloud cron cronjob
  ansible.builtin.cron: user=root name=nextcloud minute=*/5 job="docker exec --user www-data nextcloud php -f /var/www/html/cron.php"
  tags: [ docker, nextcloud, cron ]
- name: assure nextcloud update cronjob
  ansible.builtin.cron: user=root name=nextcloud-update minute=*/30 job="docker exec --user www-data nextcloud php occ app:update --all"
  tags: [ docker, nextcloud, cron ]