services:
  nextcloud:
    image: nextcloud:22.2.6-apache
    depends_on:
      - postgres
    environment:
      - UID=1000
      - GID=1000
      - UPLOAD_MAX_SIZE=10G
      - APC_SHM_SIZE=128M
      - OPCACHE_MEM_SIZE=128
      - CRON_PERIOD=15m
      - TZ=Asia/Shanghai
      - DB_TYPE=postgres
      - DB_NAME=nextcloud
      - DB_USER=${POSTGRES_USER:-username}
      - DB_PASSWORD=${POSTGRES_PASSWORD:-password}
      - DB_HOST=postgres
      # - DOMAIN=your-domain
    volumes:
       - nextcloud:/var/www/html
    expose:
      - 7009
    ports:
      - 7009:80/tcp
    restart: always
  redis:
    image: redis:6.2.6-alpine
    container_name: redis
    restart: always
    expose:
      - 6379
  onlyoffice:
    image: onlyoffice/documentserver
    environment:
      - REDIS_SERVER_HOST=redis
      - REDIS_SERVER_PORT=6379
    volumes:
      - onlyoffice-data:/var/www/onlyoffice/Data
      - onlyoffice-logs:/var/log/onlyoffice
    restart: always
    expose:
      - 9000
      - 9001
    ports:
      - 9000:80
      - 9001:443
    links:
      - redis
  postgres:
    image: postgres:14.2-alpine
    volumes:
      - pgdata:/var/lib/postgresql/data
    privileged: true
    expose:
      - 5432
    environment:
      POSTGRES_USER: ${POSTGRES_USER:-username}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-password}
volumes:
  pgdata:
  nextcloud:
  onlyoffice-data:
  onlyoffice-logs: