{% include 'roles/docker-compose/templates/base.yml.j2' %}

  postgres:
    container_name:   "{{ POSTGRES_CONTAINER }}"
    image:            "{{ POSTGRES_CUSTOM_IMAGE }}"
    {{ lookup('template', 'roles/docker-container/templates/build.yml.j2') | indent(4) }}
    command:
      - "postgres"
      - "-c"
      - "max_connections={{ POSTGRES_MAX_CONNECTIONS }}"
      - "-c"
      - "superuser_reserved_connections={{ POSTGRES_SUPERUSER_RESERVED_CONNECTIONS }}"
      - "-c"
      - "shared_buffers={{ POSTGRES_SHARED_BUFFERS }}"
      - "-c"
      - "work_mem={{ POSTGRES_WORK_MEM }}"
      - "-c"
      - "maintenance_work_mem={{ POSTGRES_MAINTENANCE_WORK_MEM }}"

{% include 'roles/docker-container/templates/base.yml.j2' %}
{% if POSTGRES_EXPOSE_LOCAL %}
    ports: 
      - "{{ POSTGRES_LOCAL_HOST }}:{{ POSTGRES_PORT }}:5432"
{% endif %}
    volumes:
      - "data:/var/lib/postgresql/data"
{% include 'roles/docker-container/templates/networks.yml.j2' %}

{% include 'roles/docker-compose/templates/volumes.yml.j2' %}
  data:
    name: "{{ POSTGRES_VOLUME }}"

{% include 'roles/docker-compose/templates/networks.yml.j2' %}