Newer
Older
nextcloud / docker-compose.yml
version: '2.2'

services:
  nextcloud-app:
    #build: ./docker/app
    image: pgollor/nextcloud:app-latest-dev
    restart: always
    mem_limit: 512m
    cpus: 1.5
    depends_on:
      - nextcloud-database
      - nextcloud-redis
    environment:
      - MYSQL_HOST=mysql
      - MYSQL_DATABASE=cloud
      - MYSQL_USER=cloud
      - MYSQL_PASSWORD=${NEXTCLOUD_DATABASE_PASSWORD}
      - NEXTCLOUD_ADMIN_USER=${NEXTCLOUD_ADMIN_USER}
      - NEXTCLOUD_ADMIN_PASSWORD=${NEXTCLOUD_ADMIN_PASSWORD}
      - NEXTCLOUD_DATA_DIR=/srv/data
      - REDIS_HOST=redis
      - TZ=${TZ}
    tmpfs:
      - /tmp
    volumes:
      - ./data/app:/var/www/html
      - ./data/data:/srv/data
    networks:
      nextcloud-network:
        ipv4_address: ${NEXTCLOUD_IPV4_NETWORK:-172.22.5}.100
        aliases:
          - app

  nextcloud-web:
    #build: ./docker/web
    image: pgollor/nextcloud:web-latest
    restart: always
    mem_limit: 512m
    logging:
      driver: json-file
    ports:
      - "${NEXTCLOUD_WEB_BIND:-127.0.0.1}:${NEXTCLOUD_WEB_PORT:-8080}:80"
    volumes:
      - ./data/app:/var/www/html:ro
    depends_on:
      - nextcloud-app
    networks:
      nextcloud-network:
        ipv4_address: ${NEXTCLOUD_IPV4_NETWORK:-172.22.5}.101
        aliases:
          - web

  nextcloud-database:
    image: mariadb
    restart: always
    mem_limit: 1g
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    environment:
      - MYSQL_ROOT_PASSWORD=${NEXTCLOUD_DATABASE_ROOT}
      - MYSQL_DATABASE=cloud
      - MYSQL_USER=cloud
      - MYSQL_PASSWORD=${NEXTCLOUD_DATABASE_PASSWORD}
    volumes:
      -  nextcloud-db-vol-1:/var/lib/mysql/
      - ./data/conf/mysql:/etc/mysql/conf.d/:ro
    tmpfs:
      - /tmp
    networks:
      nextcloud-network:
        ipv4_address: ${NEXTCLOUD_IPV4_NETWORK:-172.22.5}.102
        aliases:
          - mysql

  nextcloud-redis:
    mem_limit: 1g
    image: redis:alpine
    restart: always
    networks:
      nextcloud-network:
        aliases:
          - redis

  nextcloud-cron:
    #build: ./docker/app
    image: pgollor/nextcloud:app-latest
    restart: always
    volumes:
      - ./data/app:/var/www/html
      - ./data/data:/srv/data
    user: www-data
    mem_limit: 256m
    logging:
      driver: json-file
    entrypoint: |
      bash -c 'bash -s <<EOF
        trap "break;exit" SIGHUP SIGINT SIGTERM
    
        while [ ! -f /var/www/html/config/config.php ]; do
          sleep 1
        done
    
        while true; do
          php -f /var/www/html/cron.php
          sleep 15m
        done
      EOF'
    depends_on:
      - nextcloud-database
      - nextcloud-redis
    networks:
      nextcloud-network:

networks:
  nextcloud-network:
    driver: bridge
    enable_ipv6: false
    ipam:
      driver: default
      config:
        - subnet: ${NEXTCLOUD_IPV4_NETWORK:-172.22.5}.0/24

volumes:
  nextcloud-db-vol-1: