---
version: '3'

services:
  php: &php-definition
    build:
      context: .
      args:
        UID: ${PHP_FPM_USER:-1000}
    # uncomment and set your own image if needed
    image: ${IMAGE_PHP-chill_php82}:${VERSION:-latest}
    volumes:
      - .:/var/www/app
    environment:
      - "COMPOSER_HOME=/var/www/app/.composer"
      - "APP_DEBUG=${APP_DEBUG:-true}"
      - "APP_ENV=${APP_ENV:-dev}"
      - "DATABASE_HOST=db"
      - "DATABASE_PORT=5432"
      - "DATABASE_NAME=postgres"
      - "DATABASE_USER=postgres"
      - "GELF_HOST=logstash"
      - "GELF_PORT=12201"
      - "PHP_FPM_USER=${PHP_FPM_USER:-1000}"
      - "PHP_FPM_GROUP=${PHP_FPM_GROUP:-1000}"
      # openstack credentials, for async upload
      - "OS_USERNAME=${OS_USERNAME}"
      - "OS_PASSWORD=${OS_PASSWORD}"
      - "OS_REGION_NAME=${OS_REGION_NAME}"
      - "OS_AUTH_URL=${OS_AUTH_URL}"
      - "OS_TENANT_ID=${OS_TENANT_ID}"
      # configuration for async upload
      - "ASYNC_UPLOAD_TEMP_URL_BASE_PATH=${ASYNC_UPLOAD_TEMP_URL_BASE_PATH}"
      - "ASYNC_UPLOAD_TEMP_URL_CONTAINER=${ASYNC_UPLOAD_TEMP_URL_CONTAINER}"
      - "ASYNC_UPLOAD_TEMP_URL_KEY=${ASYNC_UPLOAD_TEMP_URL_KEY}"

    links:
      - db
      - redis
      - smtp
      - logstash
  nginx:
    build:
      context: .
      dockerfile: docker/nginx/Dockerfile
    image: ${IMAGE_NGINX-chill_nginx}:${VERSION:-latest}
    volumes:
      - .:/var/www/app
      - ./docker/nginx/nginx.conf:/etc/nginx/nginx.with-collabora.conf
    links:
      - php
      - logstash
    ports:
      - "8001:80"
  db:
    image: postgis/postgis:12-3.1-alpine
    volumes:
      - ./docker/db/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
    ports:
      - "127.0.0.1:5432:5432"
    environment:
      - "POSTGRES_PASSWORD=postgres"
  redis:
    image: redis

  logstash:
    build:
      context: ./docker/logstash

  pgadmin:
    image: dpage/pgadmin4
    links:
      - db
    environment:
      - "PGADMIN_DEFAULT_EMAIL=${PGADMIN_DEFAULT_EMAIL:-admin@chill.social}"
      - "PGADMIN_DEFAULT_PASSWORD=${PGADMIN_DEFAULT_PASSWORD:-password}"
      - "PGADMIN_DISABLE_POSTFIX=true"
    ports:
      - "8002:80"
    volumes:
      - "./docker/pgadmin4/servers.json:/pgadmin4/servers.json:ro"

  # fake smtp server
  smtp:
    image: schickling/mailcatcher
    ports:
      - "8005:1080"

  collabora:
    image: collabora/code
    restart: unless-stopped
    environment:
      - DONT_GEN_SSL_CERT="True"
      - extra_params=--o:ssl.enable=false --o:ssl.termination=false
      - username=admin
      - password=admin
      - dictionaries=en_US
    ports:
      - "9980:9980"
    cap_add:
      - MKNOD
...