version: '2.2'

services:
  test_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.test
    depends_on:
      - test_db
    networks:
      - test_network
  test_db:
    restart: always
    image: postgres:13.0-alpine
    volumes:
      - test_postgres_data:/var/lib/postgresql/data/
    env_file:
      - ./.env.test.db
    mem_limit: 2048m
    mem_reservation: 512m
    cpus: 0.5
    networks:
      - test_network
  test_nginx:
    restart: always
    build: ./nginx
    mem_limit: 2048m
    mem_reservation: 512m
    cpus: 0.5
    ports:
      - 8002:80
    depends_on:
      - test_web
    networks:
      - test_network
  test_redis:
    restart: always
    image: redis:alpine
    networks:
      - test_network
  test_celery:
    restart: always
    build: ./app
    command: celery -A calendarproject.celery worker -l info
    volumes:
      - ./app/:/usr/src/app/
    env_file:
      - ./.env.test
    depends_on:
      - test_redis
    networks:
      - test_network
  test_celery-beat:
    restart: always
    build: ./app
    command: celery -A calendarproject.celery beat -l info
    volumes:
      - ./app/:/usr/src/app/
    env_file:
      - ./.env.test
    depends_on:
      - test_redis
    networks:
      - test_network
volumes:
  test_postgres_data:

networks:
  test_network:
