#       Licensed to the Apache Software Foundation (ASF) under one
#       or more contributor license agreements.  See the NOTICE file
#       distributed with this work for additional information
#       regarding copyright ownership.  The ASF licenses this file
#       to you under the Apache License, Version 2.0 (the
#       "License"); you may not use this file except in compliance
#       with the License.  You may obtain a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#       Unless required by applicable law or agreed to in writing,
#       software distributed under the License is distributed on an
#       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
#       KIND, either express or implied.  See the License for the
#       specific language governing permissions and limitations
#       under the License.

services:
  web:
    build: .
    image: allura-web  # default in Compose 2+, makes work in Compose 1.x
    environment: &env
      # PATH=/allura-data/virtualenv/bin:$PATH doesn't work; see https://github.com/docker/compose/issues/650
      - PATH=/allura-data/virtualenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    ports:
      - "8088:8088"
    volumes: &volumes
      - .:/allura  # Allura source code from local host
      - ${LOCAL_SHARED_DATA_ROOT:-./allura-data}:/allura-data  # for virtualenv, scm repos, etc
      - ${LOCAL_SHARED_DATA_ROOT:-./allura-data}/root/home:/root  # for persistent home dir, mainly for pudb
    links:
      - mongo
      - solr

  taskd:
    image: allura-web
    working_dir: /allura/Allura
    environment: *env
    command: paster taskd docker-dev.ini
    volumes: *volumes
    links:
      - mongo
      - solr
      - outmail

  solr:
    image: solr:6-alpine  # alpine is a very small distro base
    ports:
      - "8983:8983"
    volumes:
      - ./solr_config/allura:/opt/solr/server/solr/allura
      - ${LOCAL_SHARED_DATA_ROOT:-./allura-data}/solr:/opt/solr/server/solr/allura/data

  mongo:
    image: mongo:4.2
    ports:
      - "27017:27017"
    volumes:
      - ${LOCAL_SHARED_DATA_ROOT:-./allura-data}/mongo:/data/db
    command: mongod --storageEngine wiredTiger

  outmail:
    image: allura-web
    environment: *env
    volumes_from:
      - web
    command: python -u -m aiosmtpd -n -c alluratest.smtp_debug.BetterDebuggingServer -l 0.0.0.0:8826
    expose:
      - "8826"

  inmail:
    image: allura-web
    working_dir: /allura/Allura
    environment: *env
    volumes: *volumes
    command: paster smtp_server docker-dev.ini
    ports:
      - "8825:8825"
    links:
      - mongo

  http:
    build: scm_config/git-http/
    ports:
      - "8080:80"
    volumes: *volumes
    links:
      - mongo
      - web
