version: '2.2'

services:
  web:
    restart: always
    build: 
      context: ./app
      dockerfile: Dockerfile.prod
    command: gunicorn calendarproject.wsgi:application --bind 0.0.0.0:8000
    mem_limit: 2048m
    mem_reservation: 1024m
    cpus: 1
    expose:
      - 8000
    env_file:
      - ./.env.prod
    depends_on:
      - db
  db:
    restart: always
    image: postgres:13.0-alpine
    volumes:
      - postgres_data:/var/lib/postgresql/data/
    env_file:
      - ./.env.prod.db
    mem_limit: 2048m
    mem_reservation: 512m
    cpus: 0.5
  nginx:
    restart: always
    build: ./nginx
    mem_limit: 2048m
    mem_reservation: 512m
    cpus: 0.5
    ports:
      - 8001:80
    depends_on:
      - web
  redis:
    restart: always
    image: redis:alpine
  celery:
    restart: always
    build: ./app
    command: celery -A calendarproject.celery worker -l info
    volumes:
      - ./app/:/usr/src/app/
    env_file:
      - ./.env.prod
    depends_on:
      - redis
  celery-beat:
    restart: always
    build: ./app
    command: celery -A calendarproject.celery beat -l info
    volumes:
      - ./app/:/usr/src/app/
    env_file:
      - ./.env.prod
    depends_on:
      - redis

volumes:
  postgres_data:
