version: "3"

services:

  db:
    image: postgres:12.0-alpine  # Image will be pulled directly from docker hub
    ports:
      - ${DB_PORT}:5432
    volumes: 
      - db-data:/var/lib/postgresql/data
    environment:
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: ${POSTGRES_DB}


  color-service:
    build:
      context: ./color-service
      dockerfile: ./Dockerfile
    ports:
      - ${COLOR_SERVICE_PORT}:4000
    environment:
      HTTP_PORT: 4000
    volumes:
      - ./data.json:/app/data.json  # example of how to mount external files into the container (e.g. a data set)


  api:
    build:
      context: ./api
      dockerfile: ./Dockerfile
    depends_on:
      - db  # example of a depency between services, the api service will be started after the db service
    ports:
      - ${API_PORT}:3000
    volumes:
      - ${DATA_PATH}:/app/data.json  # example of how to mount external files into the container (e.g. a data set)

  
  frontend:
    build:
      context: ./frontend
      dockerfile: ./Dockerfile
    ports:
      - ${FRONTEND_PORT}:8000  # example of how to bind to a different port


volumes: 
  db-data:  # db-data is a volume that will be generated by docker compose