# -*- coding: utf-8 -*-
#
# Copyright (c) 2015 Parisson SARL

# This file is part of TimeSide.

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# TimeSide is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with TimeSide.  If not, see <http://www.gnu.org/licenses/>.

# Authors:
# Guillaume Pellerin <yomguy@parisson.com>
# Thomas Fillon <thomas@parisson.com>

version: '3'

services:

  db:
    image: postgres:9
    volumes:
      - ./var/lib/postgresql/data:/var/lib/postgresql/data
      - ./var/backup:/srv/backup
      - ./bin:/srv/bin
    env_file:
      - env/debug.env

  broker:
    image: redis:5

  app:
    build: .
    command: /bin/bash /srv/app/app.sh --runserver
    volumes:
      - ./app:/srv/app
      - ./bin:/srv/bin
      - ./docs:/srv/docs
      - ./timeside:/srv/lib/timeside/timeside
      - ./tests:/srv/lib/timeside/tests
      - ./lib/plugins:/srv/lib/plugins
      - ./var/media:/srv/media
      - ./var/backup:/srv/backup
      - ./var/static:/srv/static
      - ./var/log/uwsgi:/var/log/uwsgi
      - ./var/log/app:/var/log/app
      - ./var/cache:/srv/cache
      - ./pyproject.toml:/srv/pyproject.toml
      - ./poetry.lock:/srv/poetry.lock
    env_file:
      - env/debug.env
    links:
      - broker
      - db
    expose:
      - "8000"

  worker:
    build: .
    command: /bin/bash /srv/app/worker.sh
    volumes:
      - /etc/._ifpk_2
      - ./var/log/celery:/var/log/celery
    volumes_from:
      - app
    env_file:
      - env/debug.env
    links:
      - broker
      - db

volumes:
  app:
  db:
  worker:
