# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

services:
  backend:
    build:
      secrets:
        - gcp_credentials
      context: ./backend
      dockerfile: Dockerfile.local
      args:
        IS_FIRST_DEPLOYMENT: "True"
        GCLOUD_PROJECT: my-project-id
        ENVIRONMENT: development
        FRONTEND_URL: http://localhost:4200
        BIG_QUERY_DATASET: bigquery_quickbot_multi_playbook_search
    container_name: quickbot-multi-playbook-search-backend
    ports:
      - "8080:8080"
    volumes:
      - ./backend:/app
      # Mount the gcloud ADC directory. Replace with the correct path for your OS if different. :ro - read-only for better security
      - ~/.config/gcloud/:/root/.config/gcloud:ro # Linux/macOS example:
      # - %APPDATA%/gcloud:/root/.config/gcloud:ro # Windows example:
    environment:
      GOOGLE_APPLICATION_CREDENTIALS: "/root/.config/gcloud/application_default_credentials.json"
    restart: unless-stopped

  frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile
    container_name: quickbot-multi-playbook-search-frontend
    ports:
      - "4200:8080"
    volumes:
      - ./frontend:/app
      # Use an anonymous volume for node_modules to prevent host node_modules
      # from interfering and potentially speed up builds/rebuilds
      - /app/node_modules
    # To change the env variables in the frontend, change the environment.ts file
    restart: unless-stopped

secrets:
  gcp_credentials: # This ID must match the one used in services.backend.build.secrets
    # Path to your Google Application Default Credentials JSON file on the HOST machine.
    # Replace with the correct path for your OS if different.
    file: ~/.config/gcloud/application_default_credentials.json
    # Windows example (you might need to adjust the target path inside the container if it's a Linux container):
    # - %APPDATA%/gcloud/application_default_credentials.json