version: '3.8'
services:
  usermicroservice:
    build:
      context: ./UserMicroservice
    image: usermicroservice:${IMAGE_TAG}
    ports:
      - "${USER_MICROSERVICE_PORT}:8080"
    environment:
      - ASPNETCORE_ENVIRONMENT=Production
      - DOTNET_RUNNING_IN_CONTAINER=true
      - ConnectionStrings__DefaultConnection=Server=host.docker.internal;Port=${DB_PORT};Database=${DB_NAME};User=${DB_USER};Password=${DB_PASSWORD};CharSet=${DB_CHARSET}
      - Jwt__Key=0QTrd3jToEYj205k01A2R87Hc5YpqDNeywg7JzQpczs=
      - Jwt__Issuer=http://usermicroservice:8080
      - Jwt__Audience=http://usermicroservice:8080

  flightmicroservice:
    build:
      context: ./FlightMicroservice
    image: flightmicroservice:${IMAGE_TAG}
    ports:
      - "${FLIGHT_MICROSERVICE_PORT}:8080"
    environment:
      - ASPNETCORE_ENVIRONMENT=Production
      - DOTNET_RUNNING_IN_CONTAINER=true
      - ConnectionStrings__DefaultConnection=Server=host.docker.internal;Port=${DB_PORT};Database=${DB_NAME};User=${DB_USER};Password=${DB_PASSWORD};CharSet=${DB_CHARSET}
      - Jwt__Key=0QTrd3jToEYj205k01A2R87Hc5YpqDNeywg7JzQpczs=
      - Jwt__Issuer=http://usermicroservice:8080
      - Jwt__Audience=http://usermicroservice:8080

  bookingmicroservice:
    build:
      context: ./BookingMicroservice
    image: bookingmicroservice:${IMAGE_TAG}
    ports:
      - "${BOOKING_MICROSERVICE_PORT}:8080"
    environment:
      - ASPNETCORE_ENVIRONMENT=Production
      - DOTNET_RUNNING_IN_CONTAINER=true
      - ConnectionStrings__DefaultConnection=Server=host.docker.internal;Port=${DB_PORT};Database=${DB_NAME};User=${DB_USER};Password=${DB_PASSWORD};CharSet=${DB_CHARSET}
      - Jwt__Key=0QTrd3jToEYj205k01A2R87Hc5YpqDNeywg7JzQpczs=
      - Jwt__Issuer=http://usermicroservice:8080
      - Jwt__Audience=http://usermicroservice:8080
      - FlightMicroservice__BaseUrl=http://flightmicroservice:8080

  gatewayapi:
    build:
      context: ./GatewayAPI
    image: gatewayapi:${IMAGE_TAG}
    ports:
      - "${GATEWAY_API_PORT}:8080"
    environment:
      - ASPNETCORE_ENVIRONMENT=Production
      - DOTNET_RUNNING_IN_CONTAINER=true
      - UserMicroservice__BaseUrl=http://usermicroservice:8080
      - FlightMicroservice__BaseUrl=http://flightmicroservice:8080
      - BookingMicroservice__BaseUrl=http://bookingmicroservice:8080

  client:
    build:
      context: ./client
    image: client:${IMAGE_TAG}
    ports:
      - "${CLIENT_PORT}:4200"

  db:
    image: mysql:${MYSQL_IMAGE_TAG}
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
      MYSQL_DATABASE: ${DB_NAME}
      MYSQL_USER: ${DB_USER}
      MYSQL_PASSWORD: ${DB_PASSWORD}
    volumes:
      - ./Database:/docker-entrypoint-initdb.d
    ports:
      - "${DB_PORT}:3306"
