version: '3'

services:
  front:
    build: front
    env_file:
      - .env.dev
      - .env
    environment:
      - "HOST=0.0.0.0"
      - "WEBPACK_DEVSERVER_PORT=${WEBPACK_DEVSERVER_PORT-8080}"
    ports:
      - "${WEBPACK_DEVSERVER_PORT-8080}:${WEBPACK_DEVSERVER_PORT-8080}"
    volumes:
      - './front:/app'
      - './po:/po'

  postgres:
    env_file:
      - .env.dev
      - .env
    image: postgres

  redis:
    env_file:
      - .env.dev
      - .env
    image: redis:3.0

  celeryworker:
    env_file:
      - .env.dev
      - .env
    build:
      context: ./api
      dockerfile: docker/Dockerfile.test
    links:
     - postgres
     - redis
    command: celery -A funkwhale_api.taskapp worker -l debug
    environment:
      - "DATABASE_URL=postgresql://postgres@postgres/postgres"
      - "CACHE_URL=redis://redis:6379/0"
    volumes:
      - ./api:/app
      - ./data/music:/music
  api:
    env_file:
      - .env.dev
      - .env
    build:
      context: ./api
      dockerfile: docker/Dockerfile.test
    command: python /app/manage.py runserver 0.0.0.0:12081
    volumes:
      - ./api:/app
      - ./data/music:/music
    environment:
      - "DATABASE_URL=postgresql://postgres@postgres/postgres"
      - "CACHE_URL=redis://redis:6379/0"
    links:
      - postgres
      - redis

  nginx:
    command: /entrypoint.sh
    env_file:
      - .env.dev
      - .env
    image: nginx
    environment:
      - "WEBPACK_DEVSERVER_PORT=${WEBPACK_DEVSERVER_PORT-8080}"
    links:
      - api
      - front
    volumes:
      - ./docker/nginx/conf.dev:/etc/nginx/nginx.conf
      - ./docker/nginx/entrypoint.sh:/entrypoint.sh:ro
      - ./deploy/funkwhale_proxy.conf:/etc/nginx/funkwhale_proxy.conf.template:ro
      - ./api/funkwhale_api/media:/protected/media
    ports:
      - "0.0.0.0:6001:6001"

  docs:
    build: docs
    command: python serve.py
    volumes:
      - ".:/app/"
    ports:
      - '35730:35730'
      - '8001:8001'