services:

  backend:
    platform: linux/amd64
    build:
      context: .
      dockerfile: Dockerfile
      target: backend-dev
      args:
        - IS_DEV=true
    ports:
      - "5000:5000"
    environment:
      - AWS_ACCESS_KEY_ID
      - AWS_SECRET_ACCESS_KEY
      - AWS_DEFAULT_REGION
      - AWS_SESSION_TOKEN
    env_file:
      - .env
    volumes:
      - ./feed_status/:/var/app/feed_status/
      - ./tests/:/var/app/tests/tests/
    command: pipenv run python dev.py

  frontend:
    platform: linux/amd64
    build:
      context: .
      dockerfile: Dockerfile
      target: frontend
    environment:
        - VUE_APP_SERVER_URL=http://backend:5000
    depends_on:
      - backend
    ports:
      - "8080:8080"
    volumes:
      - ./frontend/:/var/app/frontend/
    command: yarn serve

  unit-lint:
    platform: linux/amd64
    build:
      context: .
      dockerfile: Dockerfile
      target: backend-dev
      args:
        - IS_DEV=true
    volumes:
      - ./build:/var/app/build
    command: make test_unit_cov lint
    profiles:
      - test

  production:
    platform: linux/amd64
    build:
      context: .
      dockerfile: Dockerfile
      target: runtime
    env_file:
      - .env
    environment:
      - AWS_ACCESS_KEY_ID
      - AWS_SECRET_ACCESS_KEY
      - AWS_DEFAULT_REGION
      - AWS_SESSION_TOKEN
    profiles:
      - prod
    ports:
      - "80:8080"
