x-defaults: &defaults
  restart: unless-stopped
  logging:
    driver: json-file
    options:
      max-size: 100m
      max-file: '3'

services:
  libreoffice:
    <<: *defaults
    image: lscr.io/linuxserver/libreoffice:${LIBREOFFICE_VERSION:-latest}
    ports:
      - '${LIBREOFFICE_HTTP_PORT_OVERRIDE:-3000}:3000'
      - '${LIBREOFFICE_HTTPS_PORT_OVERRIDE:-3001}:3001'
    volumes:
      - libreoffice_config:/config
    environment:
      - PUID=${PUID:-1000}
      - PGID=${PGID:-1000}
      - TZ=${TZ:-UTC}
      - CUSTOM_USER=${CUSTOM_USER:-abc}
      - PASSWORD=${PASSWORD:-}
      - UMASK=${UMASK:-022}
    security_opt:
      - seccomp:unconfined
    deploy:
      resources:
        limits:
          cpus: ${LIBREOFFICE_CPU_LIMIT:-2.00}
          memory: ${LIBREOFFICE_MEMORY_LIMIT:-2G}
        reservations:
          cpus: ${LIBREOFFICE_CPU_RESERVATION:-0.50}
          memory: ${LIBREOFFICE_MEMORY_RESERVATION:-512M}
    healthcheck:
      test: [CMD, curl, -f, -k, 'https://localhost:3001/']
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

volumes:
  libreoffice_config:
