# yaml-language-server: $schema=https://schema.zeabur.app/template.json
apiVersion: zeabur.com/v1
kind: Template
metadata:
    name: Dragonfly
spec:
    description: Dragonfly is a simple, performant, and cost-efficient in-memory data store.
    icon: https://cdn.zeabur.com/database/dragonfly.svg
    readme: |-
        # Dragonfly

        Dragonfly is an in-memory data store built for modern application workloads.

        Fully compatible with Redis and Memcached APIs, Dragonfly requires no code changes to adopt. Compared to legacy in-memory datastores, Dragonfly delivers 25X more throughput, higher cache hit rates with lower tail latency, and can run on up to 80% less resources for the same sized workload.

        ## Getting Connection Info

        After you deploy the Dragonfly service, Zeabur will automatically inject the environment variables needed for connection into other services for you.

        - `DRAGONFLY_HOST`
        - `DRAGONFLY_PORT`
        - `DRAGONFLY_PASSWORD`

        Sometimes we can use `DRAGONFLY_URI` instead of the above environment variables, which is in the format of:

        ```bash
        redis://:${DRAGONFLY_PASSWORD}@${DRAGONFLY_HOST}:${DRAGONFLY_PORT}
        ```

        We can also find the connection information in the "Instructions" section on the console.
    services:
        - name: Dragonfly
          icon: https://cdn.zeabur.com/database/dragonfly.svg
          template: PREBUILT
          spec:
            id: dragonfly
            source:
                image: docker.dragonflydb.io/dragonflydb/dragonfly:v1.19.0
            ports:
                - id: database
                  port: 6379
                  type: TCP
            volumes:
                - id: data
                  dir: /data
            instructions:
                - title: Command to connect to your Dragonfly
                  content: redis-cli -h ${PORT_FORWARDED_HOSTNAME} -p ${DATABASE_PORT_FORWARDED_PORT} -a ${DRAGONFLY_PASSWORD}
                - title: Dragonfly password
                  content: ${DRAGONFLY_PASSWORD}
                - title: Redis host
                  content: ${PORT_FORWARDED_HOSTNAME}
                - title: Redis port
                  content: ${DATABASE_PORT_FORWARDED_PORT}
            env:
                DRAGONFLY_ARGS:
                    default: --requirepass ${DRAGONFLY_PASSWORD}
                DRAGONFLY_CONNECTION_STRING:
                    default: redis://:${DRAGONFLY_PASSWORD}@${DRAGONFLY_HOST}:${DRAGONFLY_PORT}
                    expose: true
                DRAGONFLY_HOST:
                    default: ${CONTAINER_HOSTNAME}
                    expose: true
                DRAGONFLY_PASSWORD:
                    default: ${PASSWORD}
                    expose: true
                DRAGONFLY_PORT:
                    default: ${DATABASE_PORT}
                    expose: true
                DRAGONFLY_URI:
                    default: ${DRAGONFLY_CONNECTION_STRING}
                    expose: true
