services:

  server:
    image: catedit_server
    build:
      context: .
      dockerfile: docker/server.dockerfile
    depends_on:
      broker: service_started
      memcached: service_started
    environment:
      BROKER_URL: amqp://iri:${BROKER_PASSWORD}@broker:5672/catedit
      RESULT_BROKER_URL: rpc://iri:${BROKER_PASSWORD}@broker:5672/catedit
      MEMCACHED_URL: memcached:11211
      DEBUG: ${DEBUG}
      SECRET_KEY: ${SECRET_KEY}
      GITHUB_CLIENT_ID : ${GITHUB_CLIENT_ID}
      GITHUB_CLIENT_SECRET : ${GITHUB_CLIENT_SECRET}

  
  broker:
    image: rabbitmq:3-alpine
    hostname: catedit_rabbitmq
    environment: 
      RABBITMQ_DEFAULT_USER: iri
      RABBITMQ_DEFAULT_PASS: ${BROKER_PASSWORD}
      RABBITMQ_DEFAULT_VHOST: catedit

  worker:
    image: catedit_server
    depends_on:
      broker: service_started
      memcached: service_started
    command:
      - celery
      - -A
      - catedit.celery
      - worker
      - -c
      - "1"
      - -l
      - info
      - -Q
      - repo_catedit-dev-testing,repo_mons-categories-prototype,repo_habitabilite-prototype,repo_collaboration-prototype,repo_economie-de-la-contribution,repo_habitabilite-chercheur,repo_explorunivers-habitabilite,repo_catedit-testing
    environment:
      BROKER_URL: amqp://iri:${BROKER_PASSWORD}@broker:5672/catedit
      RESULT_BROKER_URL: rpc://iri:${BROKER_PASSWORD}@broker:5672/catedit
      MEMCACHED_URL: memcached:11211
      DEBUG: ${DEBUG}
      SECRET_KEY: ${SECRET_KEY}
      GITHUB_CLIENT_ID : ${GITHUB_CLIENT_ID}
      GITHUB_CLIENT_SECRET: ${GITHUB_CLIENT_SECRET}
      CATEDIT_SETTINGS: /code/config.py
      BASE_URL: "http://server:8000"


  memcached:
    image: docker.io/memcached

  web:
    build:
      context: docker
      dockerfile: web.dockerfile
    ports:
      - "443:443"