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

services:
  nextcloud-app:
    build: ./app
    restart: always
    mem_limit: 512m
    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}
      - TZ=${TZ}
    tmpfs:
      - /tmp
    volumes:
      - ./data/app:/var/www/html
    networks:
      nextcloud-network:
        ipv4_address: 172.22.5.100
        aliases:
          - app

  nextcloud-web:
    build: ./web
    restart: always
    mem_limit: 512m
    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: 172.22.5.101
        aliases:
          - web

  nextcloud-database:
    image: mariadb:10.2
    restart: always
    mem_limit: 1g
    command: mysqld --skip-name-resolve --skip-host-cache --log-warnings=0
    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: 172.22.5.102
        aliases:
          - mysql

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

  nextcloud-cron:
    build: ./app
    restart: always
    volumes:
      - ./data/app:/var/www/html
    user: www-data
    mem_limit: 256m
    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-app
    networks:
      nextcloud-network:


networks:
  nextcloud-network:
    driver: bridge
    enable_ipv6: false
    ipam:
      driver: default
      config:
        - subnet: 172.22.5.0/24

volumes:
  nextcloud-db-vol-1: