captainVersion: 4

services:
    $$cap_appname-db:
        image: postgres:$$cap_postgres_version
        volumes:
            - '$$cap_appname-db-data:/var/lib/postgresql/data'
        restart: unless-stopped
        environment:
            POSTGRES_USER: flagsmith
            POSTGRES_PASSWORD: $$cap_postgres_password
            POSTGRES_DB: $$cap_postgres_db
        caproverExtra:
            notExposeAsWebApp: true

    $$cap_appname:
        image: flagsmith/flagsmith:$$cap_flagsmith_tag
        depends_on:
            - $$cap_appname-db
        restart: unless-stopped
        environment:
            DATABASE_URL: postgres://flagsmith:$$cap_postgres_password@srv-captain--$$cap_appname-db/$$cap_postgres_db?sslmode=disable
            DJANGO_ALLOWED_HOSTS: '*'
        caproverExtra:
            containerHttpPort: '8000'

caproverOneClickApp:
    variables:
        - id: $$cap_postgres_version
          label: Postgres Version
          defaultValue: '13.1'
        - id: $$cap_postgres_db
          label: Postgres DB
          defaultValue: 'flagsmith'
        - id: $$cap_postgres_password
          label: Postgres Password
          defaultValue: $$cap_gen_random_hex(16)
          validRegex: /^(?=.*\d).{10,}$/
        - id: $$cap_flagsmith_tag
          label: Flagsmith Version
          defaultValue: '2.14.3'
          description: Check out our docker page for the valid tags https://hub.docker.com/r/flagsmith/flagsmith/tags
    instructions:
        start: >-
            Flagsmith - an open source, fully featured, Feature Flag and Remote Config service. Use our hosted API, deploy to your own private cloud, or run on-premise.
            For more info visit https://flagsmith.com/
        end: |-
            Flagsmith has been successfully deployed!
            App is available as http://$$cap_appname.$$cap_root_domain

    displayName: Flagsmith
    isOfficial: true
    description: >-
        Flagsmith - an open source, fully featured, Feature Flag and Remote Config service. Use our hosted API, deploy to your own private cloud, or run on-premise.
    documentation: >-
        This docker-compose is taken from https://github.com/Flagsmith/self-hosted/blob/master/docker-compose.yml
