version: '3.9'
services:
  app:
    container_name: app
    image: node
    build:
      context: .
      dockerfile: Dockerfile
      target: base
    env_file:
      .env
    ports:
      - ${PORT}:${PORT}
    depends_on:
      - db
    profiles: ["prod"]

  db:
    container_name: postgres
    image: postgres
    env_file:
      .env
    ports:
      - '5432:${DB_PORT}'
    volumes:
      - data:/data/db
    environment:
      - POSTGRES_PASSWORD=${DB_PASSWORD}
      - POSTGRES_DB=${DB_NAME}
    profiles: ["dev", "prod"]

volumes: 
  data: {}