version: '3.4'
services:
  api:
    container_name: api
    build:
      dockerfile: Dockerfile
      context: .
      target: test
      args:
        - VERSION
        - REVISION
        - BUILDTIME
        - PYPI_INDEX_URL=https://pypi.org/simple
    environment:
      DEBUG: 1
      DB_NAME: postgres_test
      DB_USER: postgres
      DB_PASS: postgres
      DB_HOST: postgres
      DB_PORT: 5432
      ENV_CONFIG: test
      WAIT_HOSTS: postgres:5432
    command: sh -c "/wait"
    volumes:
      - ./:/app:delegated
      - ~/.aws:/root/.aws
    depends_on:
      - postgres

  postgres:
    container_name: db_test
    image: postgres:12.10-alpine3.15
    environment:
      - "POSTGRES_PASSWORD=postgres"
    tmpfs: '/var/lib/postgresql/data'
    healthcheck:
      test: ["CMD", "pg_isready", "-U", "postgres"]

  redis:
    image: redis:3.2.10
    tmpfs: '/var/lib/redis/data'

  elasticsearch:
    container_name: elasticsearch
    image: docker.elastic.co/elasticsearch/elasticsearch:7.10.2
    tmpfs: '/var/lib/elasticsearch/data'
    environment:
      - node.name=es01
      - cluster.name=docker-cluster
      - network.host=0.0.0.0
      - discovery.zen.minimum_master_nodes=1
      - discovery.type=single-node
      - xpack.security.enabled=false
      - xpack.monitoring.enabled=false
      - xpack.ml.enabled=false
      - xpack.graph.enabled=false
      - xpack.watcher.enabled=false
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    healthcheck:
      test: "curl http://elasticsearch:9200"
      interval: "1s"
      timeout: "3s"
      retries: 60

