captainVersion: 4
services:
    # Postgres
    $$cap_appname-postgres:
        image: postgres:13
        volumes:
            - $$cap_appname-data:/var/lib/postgresql/data
        environment:
            POSTGRES_DB: $$cap_postgres_database_name
            POSTGRES_USER: $$cap_postgres_user
            POSTGRES_PASSWORD: $$cap_postgres_passwd
        caproverExtra:
            notExposeAsWebApp: 'true'
    # Cache
    $$cap_appname-redis:
        image: redis:6
        volumes:
            - $$cap_appname-redis:/data
        caproverExtra:
            notExposeAsWebApp: 'true'
    # Directus
    $$cap_appname:
        depends_on:
            - $$cap_appname-postgres
            - $$cap_appname-redis
        image: directus/directus:$$cap_directus_tag
        volumes:
            - $$cap_appname-uploads:/directus/uploads
            - $$cap_appname-extensions:/directus/extensions
        restart: always
        environment:
            KEY: $$cap_directus_auth_public_key
            SECRET: $$cap_directus_auth_secret_key
            DB_CLIENT: 'pg'
            DB_HOST: srv-captain--$$cap_appname-postgres
            DB_PORT: '5432'
            DB_DATABASE: $$cap_postgres_database_name
            DB_USER: $$cap_postgres_user
            DB_PASSWORD: $$cap_postgres_passwd
            CACHE_ENABLED: 'true'
            CACHE_STORE: 'redis'
            CACHE_REDIS: redis://srv-captain--$$cap_appname-redis:6379
            ADMIN_EMAIL: $$cap_admin_email
            ADMIN_PASSWORD: $$cap_admin_password
        caproverExtra:
            containerHttpPort: '8055'
caproverOneClickApp:
    variables:
        - description: Tag of Directus image on https://hub.docker.com/r/directus/directus/tags
          defaultValue: v9.0.0-rc.64
          id: $$cap_directus_tag
          label: Directus image tag
          validRegex: /.{1,}/
        - description: Name of the Directus database instance.
          defaultValue: directus
          id: $$cap_postgres_database_name
          label: Postgres database name
          validRegex: /.{1,}/
        - description: User for the Directus database instance.
          defaultValue: directus
          id: $$cap_postgres_user
          label: Postgres user
          validRegex: /.{1,}/
        - description: User password for the Directus database instance.
          defaultValue: $$cap_gen_random_hex(16)
          id: $$cap_postgres_passwd
          label: Postgres user password
          validRegex: /^(?=.*\d).{10,}$/
        - description: Directus Auth Secret Key (must not be the same as Directus Auth Public Key)
          defaultValue: $$cap_gen_random_hex(16)
          id: $$cap_directus_auth_secret_key
          label: Directus Auth Secret Key
          validRegex: /^(?=.*\d).{10,}$/
        - description: Directus Auth Public Key (must not be the same as Directus Auth Secret Key)
          defaultValue: $$cap_gen_random_hex(16)
          id: $$cap_directus_auth_public_key
          label: Directus Auth Public Key
          validRegex: /^(?=.*\d).{10,}$/
        - description: Directus admin user email
          defaultValue: admin@example.com
          id: $$cap_admin_email
          label: Directus admin user email
          validRegex: /.{1,}/
        - description: Directus admin user password
          defaultValue: $$cap_gen_random_hex(8)
          id: $$cap_admin_password
          label: Directus admin user password
          validRegex: /^(?=.*\d).{8,}$/
    instructions:
        end: >
            Aaaand you're done! 😄
            Your service is available at http://$$cap_appname.$$cap_root_domain
        start: >-
            Directus is an open-source suite of software that wraps custom SQL databases with a dynamic API and intuitive Admin App.
            For more information and available options, see https://github.com/directus/docker or the official documentation at https://docs.directus.io
    displayName: 'Directus'
    isOfficial: true
    description: Directus is an open-source tool for managing content across all your omni-channel digital experiences
    documentation: Taken from https://docs.directus.io/guides/installation/docker/.
