version: "3.8"

services:
  redis:
    image: redis:alpine
    container_name: redis
    ports:
      - "6379:6379"
    restart: unless-stopped

  flask_app:
    build: .
    container_name: flask_app
    command: gunicorn -b 0.0.0.0:5001 app:app --workers 2 --threads 4
    volumes:
      - tmp_data:/app/public/tmp
      - ./public/credentials/isentropic-card-468114-f6-1ee415ed3a11.json:/app/credentials/google.json:ro
      - ./static/uploads/:/app/static/uploads/:rw  
    env_file:
      - .env
    environment:
      - FLASK_ENV=production
      - FLASK_APP=app.py
      - CELERY_BROKER_URL=redis://redis:6379/0
      - CELERY_RESULT_BACKEND=redis://redis:6379/0
      - REDIS_HOST=redis
      - REDIS_PORT=6379
      - GOOGLE_APPLICATION_CREDENTIALS=/app/credentials/google.json
    ports:
      - "5001:5001"
    depends_on:
      - redis
    restart: unless-stopped

  celery_worker:
    build: .
    container_name: celery_worker
    command: celery -A celery_app.celery worker --loglevel=info --concurrency=1
    volumes:
      - tmp_data:/app/public/tmp
      - ./public/credentials/isentropic-card-468114-f6-1ee415ed3a11.json:/app/credentials/google.json:ro
    env_file:
      - .env
    environment:
      - CELERY_BROKER_URL=redis://redis:6379/0
      - CELERY_RESULT_BACKEND=redis://redis:6379/0
      - REDIS_HOST=redis
      - REDIS_PORT=6379
      - GOOGLE_APPLICATION_CREDENTIALS=/app/credentials/google.json
    depends_on:
      - redis
    restart: unless-stopped

volumes:
  tmp_data: {}
