tembo-cli 0.21.3

The CLI for Tembo
Documentation
version: '3.8'

services:
{% for key, instance in instance_settings %}
  {{instance.instance_name}}:
    platform: linux/amd64
    build:
      context: ./{{instance.instance_name}}
    container_name: {{instance.instance_name}}
    volumes:
      - {{instance.instance_name}}-data:/var/lib/postgresql/data2
    networks:
      - tembo
    labels:
      - "traefik.enable=true"
      # an 'A' record *.local.tembo.io is set to 127.0.0.1
      # connect with TLS passthrough, SNI into local instance.
      # TLS termination inside postgres container.
      - "traefik.tcp.routers.{{instance.instance_name}}.rule=HostSNI(`{{instance.instance_name}}.local.tembo.io`)"
      - "traefik.tcp.routers.{{instance.instance_name}}.entrypoints=postgresql"
      - "traefik.tcp.routers.{{instance.instance_name}}.tls.passthrough=true"
      - "traefik.tcp.services.{{instance.instance_name}}.loadbalancer.server.port=5432"
{% if instance.controller_app_services -%}
{% for key, app_services in instance.controller_app_services -%}

{% set_global pathPrefixes = "" -%}
{% set_global prefixes = "" -%}
{% if app_services.routing -%}
{% for route in app_services.routing -%}
{% if prefixes == "" -%}
{% set_global prefixes = route.ingressPath -%}
{% set_global pathPrefixes = "PathPrefix(`" ~ route.ingressPath ~ "`)" -%}
{% else -%}
{% set_global prefixes = prefixes ~ ", " ~ route.ingressPath -%}
{% set_global pathPrefixes = pathPrefixes ~ " || PathPrefix(`" ~ route.ingressPath  ~ "`)" -%}
{% endif -%}
{% endfor -%}
{% endif %}

  {{instance.instance_name}}-{{app_services.name}}:
    image: {{app_services.image}}
    {% if app_services.name == "embeddings" -%}
    platform: linux/amd64
    {% endif %}
    environment:
      {% if app_services.env -%}
      {% for env in app_services.env -%}
      {% if env.value -%}
      {{ env.name }}: "{{ env.value }}"
      {% endif -%}
      {% endfor -%}
      {% endif %}
    networks:
      - tembo
    labels:
      - "traefik.enable=true"
      {% if app_services.routing -%}
      # The settings here depends on the app service settings
      - "traefik.http.routers.{{instance.instance_name}}-postgrest.rule=Host(`{{instance.instance_name}}.local.tembo.io`) && ({{ pathPrefixes }})"
      # in cloud, this is websecure instead of just web
      - "traefik.http.routers.{{instance.instance_name}}-postgrest.entrypoints=web"
      - "traefik.http.services.{{instance.instance_name}}-postgrest.loadbalancer.server.port={{ app_services.routing.0.port }}"
      {% endif -%}
      {% if app_services.middlewares -%}
      {% for middleware in app_services.middlewares -%}
      {% if middleware.stripPrefix -%}
      - "traefik.http.middlewares.postgrest-stripprefix.stripprefix.prefixes={{ prefixes }}"
      - "traefik.http.routers.{{instance.instance_name}}-postgrest.middlewares=postgrest-stripprefix"
      {% endif -%}
      {% if middleware.replacePathRegex -%}
      - "traefik.http.middlewares.postgrest-replacepathregex.replacepathregex.regex={{ middleware.replacePathRegex.config.regex | replace(from="\", to="") }}"
      - "traefik.http.middlewares.postgrest-replacepathregex.replacepathregex.replacement={{ middleware.replacePathRegex.config.replacement }}"
      - "traefik.http.routers.{{instance.instance_name}}-postgrest.middlewares=postgrest-replacepathregex"
      {% endif -%}
      {% endfor -%}
      {% endif -%}
{% endfor -%}
{% endif -%}
{% endfor %}

  traefik:
    image: traefik:v3.0.0-beta2
    networks:
      - tembo
    command:
      # Traefik can make routing rules by talking to
      # Docker. We also connect Docker socket to container.
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      # These are all the ports we can use for local dev
      - "--entrypoints.ferretdb.address=:27018/tcp"
      - "--entrypoints.postgresql.address=:5432/tcp"
      - "--entrypoints.traefik.address=:9000/tcp"
      - "--entrypoints.web.address=:8000/tcp"
      - "--api.dashboard=true"
      - "--api.insecure=true"
      # This could be enabled with debug mode on
      # - "--accesslog=true"
      # - "--log.level=DEBUG"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
    ports:
      - "8000:8000"
      # Traefik dashboard at http://localhost:9000/dashboard/
      # helpful for troubleshooting Traefik configurations
      - "9000:9000"
      - "5432:5432"
      # FerretDB port
      - "27018:27018"

networks:
  tembo: {}

volumes:
{% for key, instance in instance_settings %}
  {{instance.instance_name}}-data:
{% endfor %}