version: '3'
services:
  db:
    image: "postgres:14"
    restart: unless-stopped
    volumes:
      - "./data/db:/var/lib/postgresql/data"
    env_file:
      - config.env

  redis:
    image: 'redis:6.2-alpine'
    restart: unless-stopped
    command: redis-server
    volumes:
      - './data/redis:/data'

  app:
    build: .
    restart: unless-stopped
    command: ./utils/entrypoint.sh
    env_file:
      - config.env
    ports:
      - "5123:5123"
    volumes:
      - "./data/uploads:/var/cdb/uploads"
      - "./data/logs:/var/cdb/logs"
      - "./app:/source/app"
      - "./utils:/source/utils"
      - "./migrations:/source/migrations"
    depends_on:
      - db
      - redis

  worker:
    build: .
    restart: unless-stopped
    command: celery -A app.tasks.celery worker --concurrency 1
    env_file:
      - config.env
    environment:
      - FLASK_CONFIG=../config.cfg
    volumes:
      - "./data/uploads:/var/cdb/uploads"
      - "./app:/home/cdb/app"
    depends_on:
      - redis

  beat:
    build: .
    restart: unless-stopped
    command: celery -A app.tasks.celery beat
    env_file:
      - config.env
    environment:
      - FLASK_CONFIG=../config.cfg
    depends_on:
      - redis

  exporter:
    image: ovalmoney/celery-exporter
    restart: unless-stopped
    env_file:
      - config.env
    ports:
      - "5125:9540"
    depends_on:
      - redis
