version: "3"

volumes:
  dbdata:
  static_files:
  media:

services:
  db:
    image: postgres:alpine
    environment:
      POSTGRES_USER: villafleurie
      POSTGRES_DB: villafleurie
      POSTGRES_PASS: villafleurie
    volumes:
      - dbdata:/var/lib/postgresql/data
    ports:
      - 5432:5432

  web: &web
    build: .
    command: bash -c "python manage.py migrate && gunicorn -w 4 villafleurie.wsgi -b 0.0.0.0:8000"
    volumes:
      - .:/villafleurie
      - static_files:/static_files
      - media:/villafleurie/media
    ports:
      - "8000:8000"
    depends_on:
      - db
      - rabbitmq
      - celery
    env_file: prod.env

  nginx:
    build:
      context: .
      dockerfile: nginx/Dockerfile
    ports:
      - 80:80
    volumes:
      - static_files:/static_files
      - media:/media
    depends_on:
      - web

  celery:
    <<: *web
    command: celery -A villafleurie worker --loglevel=info
    ports: []
    depends_on:
      - rabbitmq
      - db

  rabbitmq:
    image: rabbitmq:alpine
