# compose.prod.yml
# Docker Comose para entorno de producción o production.


services:

  app:
    build:
      context: ./services/app
      dockerfile: Dockerfile.production
    expose: 
      - ${APP_LOCAL_PORT}
    volumes:
      - ./services/app:/app
    env_file:
      - ./services/app/.env.production
    environment:
      - NODE_ENV=${NODE_ENV}
    networks:
      net:
        aliases: [prod-app]
    command: npm run start

  auth:
    build:
      context: ./services/auth
      dockerfile: Dockerfile.production
    expose: 
      - ${AUTH_LOCAL_PORT}
    volumes:
      - ./services/auth:/app
    env_file:
      - ./services/auth/.env.production
    environment:
      - NODE_ENV=${NODE_ENV}
    command: npm run start
    networks:
      net:
        aliases: [prod-auth]

  db:
    image: postgres:16
    environment:
      POSTGRES_DB: ${DB_NAME}
      POSTGRES_USER: ${DB_USER}
      POSTGRES_PASSWORD: ${DB_PASS}
    volumes:
      - suitecoffee-db:/var/lib/postgresql/data
    networks:
      net:
        aliases: [prod-db]

  tenants:
    image: postgres:16
    environment:
      POSTGRES_DB: ${TENANTS_DB_NAME}
      POSTGRES_USER: ${TENANTS_DB_USER}
      POSTGRES_PASSWORD: ${TENANTS_DB_PASS}
    volumes:
      - tenants-db:/var/lib/postgresql/data
    networks:
      net:
        aliases: [prod-tenants]

volumes:
  tenants-db:
  suitecoffee-db:

networks:
  net:
    driver: bridge