services:
  app:
    image: cupcakearmy/static
    ports:
      - 8080:80
    volumes:
      - ./app/dist:/srv:ro

  database:
    image: postgis/postgis:13-master
    volumes:
      - ./data/database:/var/lib/postgresql/data:rw
    environment:
      POSTGRES_USER: 'directus'
      POSTGRES_PASSWORD: 'directus'
      POSTGRES_DB: 'directus'
    healthcheck:
      test: ['CMD', 'pg_isready', '--host=localhost', '--username=directus']
      interval: 10s
      timeout: 5s
      retries: 5
      start_interval: 5s
      start_period: 30s

  cache:
    image: redis:6
    healthcheck:
      test: ['CMD-SHELL', "[ $$(redis-cli ping) = 'PONG' ]"]
      interval: 10s
      timeout: 5s
      retries: 5
      start_interval: 5s
      start_period: 30s

  backend:
    container_name: backend
    build:
      context: ./backend
    depends_on:
      database:
        condition: service_healthy
      cache:
        condition: service_healthy
    ports:
      - 8055:8055
    volumes:
      - ./data/uploads:/directus/uploads
    # This is not compatible with the current setup with directus-sync as this
    # extension is installed before the volume bind onto the docker container
    #  - ./data/extensions:/directus/extensions
    environment:
      PUBLIC_URL: 'http://localhost'

      SECRET: 'SECRET'

      CORS_ENABLED: 'true'
      CORS_ORIGIN: 'array:http://localhost:8080,http://localhost:5174'
      PASSWORD_RESET_URL_ALLOW_LIST: 'http://localhost:8080/set-new-password/,http://localhost:5174/set-new-password/'

      DB_CLIENT: 'pg'
      DB_HOST: 'database'
      DB_PORT: '5432'
      DB_DATABASE: 'directus'
      DB_USER: 'directus'
      DB_PASSWORD: 'directus'

      CACHE_ENABLED: 'true'
      CACHE_AUTO_PURGE: 'true'
      CACHE_STORE: 'redis'
      REDIS: 'redis://cache:6379'

      ADMIN_EMAIL: 'admin@it4c.dev'
      ADMIN_PASSWORD: 'admin123'

      #EMAIL_FROM: 'utopia@localhost'
      #EMAIL_TRANSPORT: "smtp"
      #EMAIL_SMTP_HOST: "maildev"
      #EMAIL_SMTP_PORT: "465"
      #EMAIL_SMTP_POOL: false
      #EMAIL_SMTP_SECURE: true
      #EMAIL_VERIFY_SETUP: true
      #EMAIL_SMTP_IGNORE_TLS: true
      #EMAIL_SMTP_TLS: true
      #EMAIL_SMTP_TLS_REJECT_UNAUTHORIZED: false
      #EMAIL_SMTP_NAME: "Utopia Development"
