version: '3'
services:
  web:
    depends_on:
      - api
    environment:
      - NET_ASYNC_HTTP_MAXCONNS=1
    volumes:
      - ./configs/metacpan-web/metacpan_web.conf:/metacpan-web/metacpan_web.conf
  api:
    depends_on:
      - elasticsearch
      - elasticsearch_test
    image: metacpan-api:latest
    build:
      context: ./src/metacpan-api
    environment:
      - COLUMNS=80
      - ES=elasticsearch:9200
      - ES_TEST=elasticsearch_test:9200
      - MINICPAN=/CPAN
      - PLACK_ENV=development
    volumes:
      - cpan:/CPAN
      - api_carton:/carton
      - ./src/metacpan-api:/metacpan-api
      - ./configs/metacpan-api/metacpan_server.conf:/metacpan-api/metacpan_server.conf
      - ./configs/metacpan-api/metacpan.pl:/metacpan-api/etc/metacpan.pl
      - ./bin/index-cpan.sh:/bin/index-cpan.sh
      - ./bin/partial-cpan-mirror.sh:/bin/partial-cpan-mirror.sh
    ports:
      - "5000:5000"
    networks:
      - elasticsearch
      - web
  elasticsearch:
    image: elasticsearch:2.4
    volumes:
      - elasticsearch:/usr/share/elasticsearch/data
      - ./elasticsearch/metacpan.yml:/usr/share/elasticsearch/config/metacpan.yml
      - ./elasticsearch/scripts:/usr/share/elasticsearch/config/scripts
    ports:
      - "9200:9200"
    networks:
      - elasticsearch
  elasticsearch_test:
    image: elasticsearch:2.4
    volumes:
      - elasticsearch_test:/usr/share/elasticsearch/data
      - ./elasticsearch/test.yml:/usr/share/elasticsearch/config/test.yml
      - ./elasticsearch/scripts:/usr/share/elasticsearch/config/scripts
    ports:
      - "9900:9200"
    networks:
      - elasticsearch

networks:
  elasticsearch:

volumes:
  api_carton:
  cpan:
  elasticsearch:
  elasticsearch_test:

Add composable environment for running local metacpan-api
Add composable environment for running local metacpan-api

If using plain docker-compose, running

    export COMPOSE_PROJECT_NAME=metacpan
    export COMPOSE_FILE="docker-compose.yml:docker-compose.localapi.yml"
    docker-compose up

Will set up a complete MetaCPAN environment with both the
frontend (http://localhost;5001) and backend (http://localhost:5000) as
well as ElasticSearch (http://localhost:9200) online.  This makes use
the previous `docker-compose.yml` configuration, _composing_ in further
settings for the local API to happen.

But that's a mouthful, so use `bin/metacpan-docker` to make all that
simple instead.

See the [compose CLI][0] [docs][1] for the gory details.

[0]: https://docs.docker.com/compose/reference/envvars/
[1]: https://docs.docker.com/compose/reference/overview/#use--f-to-specify-name-and-path-of-one-or-more-compose-files
