services:
  web:
    build: .
    command: gunicorn moby_dick.wsgi:application --bind 0.0.0.0:8000
    volumes:
      - static_volume:/app/staticfiles
      - media_volume:/app/mediafiles
    ports:
      - 8000:8000
    env_file:
      - .env
    depends_on:
      - db

  db:
    image: postgres:15
    volumes:
      - postgres_data:/var/lib/postgresql/data/
    env_file:
      - ./.env.db

  nginx:
    container_name: nginx
    build: ./nginx
    volumes:
      - static_volume:/app/staticfiles
      - media_volume:/app/mediafiles
    ports:
      - 8080:80
    depends_on:
      - web

volumes:
  static_volume:
  media_volume:
  postgres_data:
