# yaml-language-server: $schema=https://schema.zeabur.app/template.json
apiVersion: zeabur.com/v1
kind: Template
metadata:
    name: Langfuse
spec:
    description: Open Source LLM Engineering Platform
    coverImage: https://avatars.githubusercontent.com/u/134601687
    icon: https://avatars.githubusercontent.com/u/134601687
    variables:
        - key: PUBLIC_DOMAIN
          type: DOMAIN
          name: Domain
          description: What is the domain you want for your Langfuse?
    tags:
        - Tool
    readme: |-
        # Langfuse

        Langfuse is an open source observability & analytics solution for LLM-based applications. It is mostly geared towards production usage but some users also use it for local development of their LLM applications.

        Langfuse is focused on applications built on top of LLMs. Many new abstractions and common best practices evolved recently, e.g. agents, chained prompts, embedding-based retrieval, LLM access to REPLs & APIs. These make applications more powerful but also unpredictable for developers as they cannot fully anticipate how changes impact the quality, cost and overall latency of their application. Thus Langfuse helps to monitor and debug these applications.

        Using this template, you can deploy Langfuse to Railway. It automatically creates a Postgres database to store your production data.

        In case of errors, try restarting the application container or join the Discord to get help: https://langfuse.com/discord
    services:
        - name: db
          icon: https://raw.githubusercontent.com/zeabur/service-icons/main/marketplace/postgresql.svg
          template: PREBUILT
          spec:
            id: db-unforthaffen
            source:
                image: postgres:16
            ports:
                - id: database
                  port: 5432
                  type: TCP
            volumes:
                - id: data
                  dir: /var/lib/postgresql/data
            instructions:
                - title: Connection String
                  content: postgresql://${POSTGRES_USERNAME}:${POSTGRES_PASSWORD}@${PORT_FORWARDED_HOSTNAME}:${DATABASE_PORT_FORWARDED_PORT}/${POSTGRES_DATABASE}
                - title: PostgreSQL Connect Command
                  content: psql "postgresql://${POSTGRES_USERNAME}:${POSTGRES_PASSWORD}@${PORT_FORWARDED_HOSTNAME}:${DATABASE_PORT_FORWARDED_PORT}/${POSTGRES_DATABASE}"
                - title: PostgreSQL username
                  content: ${POSTGRES_USERNAME}
                - title: PostgresSQL password
                  content: ${POSTGRES_PASSWORD}
                - title: PostgresSQL database
                  content: ${POSTGRES_DATABASE}
                - title: PostgreSQL host
                  content: ${PORT_FORWARDED_HOSTNAME}
                - title: PostgreSQL port
                  content: ${DATABASE_PORT_FORWARDED_PORT}
            env:
                PGDATA:
                    default: /var/lib/postgresql/data/pgdata
                POSTGRES_CONNECTION_STRING:
                    default: postgresql://${POSTGRES_USERNAME}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DATABASE}
                    expose: true
                POSTGRES_DATABASE:
                    default: ${POSTGRES_DB}
                    expose: true
                POSTGRES_DB:
                    default: zeabur
                POSTGRES_HOST:
                    default: ${CONTAINER_HOSTNAME}
                    expose: true
                POSTGRES_PASSWORD:
                    default: ${PASSWORD}
                    expose: true
                POSTGRES_PORT:
                    default: ${DATABASE_PORT}
                    expose: true
                POSTGRES_URI:
                    default: ${POSTGRES_CONNECTION_STRING}
                    expose: true
                POSTGRES_USER:
                    default: root
                POSTGRES_USERNAME:
                    default: ${POSTGRES_USER}
                    expose: true
        - name: Langfuse
          icon: https://avatars.githubusercontent.com/u/134601687
          template: PREBUILT
          spec:
            id: langfuse
            source:
                image: langfuse/langfuse:2
            ports:
                - id: web
                  port: 3000
                  type: HTTP
            env:
                DATABASE_URL:
                    default: ${POSTGRES_CONNECTION_STRING}
                LANGFUSE_ENABLE_EXPERIMENTAL_FEATURES:
                    default: "false"
                NEXT_PUBLIC_SIGN_UP_DISABLED:
                    default: "false"
                NEXTAUTH_SECRET:
                    default: ${PASSWORD}
                NEXTAUTH_URL:
                    default: ${ZEABUR_WEB_URL}
                SALT:
                    default: ${PASSWORD}
                TELEMETRY_ENABLED:
                    default: "true"
          domainKey: PUBLIC_DOMAIN
