version: '3.7'

services:
  backend_2:
    build: 
      context: .
      dockerfile: Dockerfile.backend
    container_name: laravel_backend_2
    restart: always
    working_dir: /var/www/html
    depends_on:
      - backend_laravel_db_2
    volumes:
      - ./core-api:/var/www/html
    networks:
      - service_network

  backend_perxo_api_2:
    build:
      context: .
      dockerfile: Dockerfile.perxo_api_backend
    container_name: project_backend_perxo_api_2
    restart: always
    working_dir: /var/www/html
    volumes:
      - ./perxo-api:/var/www/html
    networks:
      - service_network

  backend_access_api_2:
    build:
      context: .
      dockerfile: Dockerfile.backend_access_api
    container_name: access_api_backend_2
    restart: always
    working_dir: /var/www/html
    depends_on:
      - backend_access_api_db_2
    volumes:
      - ./access-api:/var/www/html
    networks:
      - service_network

  backend_access_api_byplus_2:
    build:
      context: .
      dockerfile: Dockerfile.backend_access_api_byplus
    container_name: access_api_byplus_backend_2
    restart: always
    working_dir: /var/www/html
    depends_on:
      - backend_access_api_byplus_db_2
    volumes:
      - ./access-api-byplus:/var/www/html
    networks:
      - service_network

  backend_core_api_byplus_2:
    build:
      context: .
      dockerfile: Dockerfile.core_api_byplus
    container_name: core_api_byplus_backend_2
    restart: always
    working_dir: /var/www/html
    depends_on:
      - backend_laravel_db_2
    volumes:
      - ./core-api-byplus:/var/www/html
    networks:
      - service_network

  webserver_2:
    image: nginx:alpine
    container_name: nginx_webserver_2
    restart: unless-stopped
    ports:
      - 8092:80
    volumes:
      - ./core-api:/var/www/html
      - ./docker-compose/nginx/:/etc/nginx/conf.d/
    depends_on:
      - backend_2
    networks:
      - service_network

  webserver_perxo_api_2:
    image: nginx:alpine
    container_name: nginx_webserver_perxo_api_2
    restart: unless-stopped
    ports:
      - 8192:80
    volumes:
      - ./perxo-api:/var/www/html
      - ./docker-compose/nginx-perxo/:/etc/nginx/conf.d/
    depends_on:
      - backend_perxo_api_2
    networks:
      - service_network

  webserver_access_api_2:
    image: nginx:alpine
    container_name: nginx-webserver_access_api_2
    restart: unless-stopped
    ports:
      - 8095:80
    volumes:
      - ./access-api:/var/www/html
      - ./docker-compose/nginx-access-api/:/etc/nginx/conf.d/
    depends_on:
      - backend_access_api_2
    networks:
      - service_network

  webserver_access_api_byplus_2:
    image: nginx:alpine
    container_name: nginx-webserver_access_api_byplus_2
    restart: unless-stopped
    ports:
      - 8096:80
    volumes:
      - ./access-api-byplus:/var/www/html
      - ./docker-compose/nginx-access-api-byplus/:/etc/nginx/conf.d/
    depends_on:
      - backend_access_api_byplus_2
    networks:
      - service_network

  webserver_core_api_byplus_2:
    image: nginx:alpine
    container_name: nginx-webserver_core_api_byplus_2
    restart: unless-stopped
    ports:
      - 8098:80
    volumes:
      - ./core-api-byplus:/var/www/html
      - ./docker-compose/nginx-core-api-byplus/:/etc/nginx/conf.d/
    depends_on:
      - backend_core_api_byplus_2
    networks:
      - service_network

  backend_laravel_db_2:
    image: postgres
    container_name: laravel_backend_database_2
    restart: always
    environment:
      POSTGRES_USER: laradmin
      POSTGRES_PASSWORD: larapwd
      POSTGRES_DB: laravel
    ports:
      - 5434:5432
    volumes:
      - database:/var/lib/postgresql/data
      - ./by_plus_test_db.sql:/by_plus_test_db.sql
      - ./corenetbyusdb.sql:/corenetbyusdb.sql
      - ../volume-database-backend-2/laravel.sql:/docker-entrypoint-initdb.d/laravel.sql
    networks:
      - service_network

  backend_laravel_test_db_2:
    image: postgres
    container_name: laravel_backend_test_database_2
    restart: always
    environment:
      POSTGRES_USER: test_user
      POSTGRES_PASSWORD: test_password
      POSTGRES_DB: test_database
    ports:
      - 5436:5432
    volumes:
      - pg_test_data:/var/lib/postgresql/data
      - ../volume-database-backend-2/test_database.sql:/docker-entrypoint-initdb.d/test_database.sql
    networks:
      - service_network

  perxo_api_db_2:
    image: postgres
    container_name: perxo_api_database_2
    restart: always
    environment:
      POSTGRES_USER: perxo_api_user
      POSTGRES_PASSWORD: perxo_api_password
      POSTGRES_DB: perxo_api_database
    ports:
      - 5446:5432
    volumes:
      - pg_perxo_api_data:/var/lib/postgresql/data
      - ../volume-database-backend-2/perxo_api_database.sql:/docker-entrypoint-initdb.d/perxo_api_database.sql
    networks:
      - service_network

  backend_access_api_db_2:
    image: postgres
    container_name: access_api_backend_database_2
    restart: always
    environment:
      POSTGRES_USER: access_api_admin
      POSTGRES_PASSWORD: access_api_password
      POSTGRES_DB: access_api_database
    ports:
      - 5439:5432
    volumes:
      - pg_access_api_database_2:/var/lib/postgresql/data
      - ../volume-database-backend-2/access_api_database.sql:/docker-entrypoint-initdb.d/access_api_database.sql
    networks:
      - service_network

  backend_access_api_byplus_db_2:
    image: postgres
    container_name: access_api_byplus_backend_database_2
    restart: always
    environment:
      POSTGRES_USER: access_api_byplus_2_admin
      POSTGRES_PASSWORD: access_api_byplus_2_password
      POSTGRES_DB: access_api_byplus_2_database
    ports:
      - 5440:5432
    volumes:
      - pg_access_api_byplus_database_2:/var/lib/postgresql/data
      - ../volume-database-backend-2/access_api_byplus_2_database.sql:/docker-entrypoint-initdb.d/access_api_byplus_2_database.sql
    networks:
      - service_network

  code_server_2:
    image: codercom/code-server:latest
    container_name: code_server_2
    user: 1001:1002
    ports:
      - "8082:8080"
    environment:
      PASSWORD: "qUWPnnir7gwdH"
    command: ["code-server", "--bind-addr", "0.0.0.0:8080", "/home/coder/project", "--disable-file-downloads"]
    volumes:
      #  - ./core-api:/home/coder/project/core-api
      - ./core-api-byplus:/home/coder/project/core-api-byplus
      - ./perxo-api:/home/coder/project/perxo-api
      - ./access-api:/home/coder/project/access-api
      - ./access-api-byplus:/home/coder/project/access-api-byplus
      - ./code-server-init.sh:/code-server-init.sh
    networks:
      - service_network

volumes:
  database:
  pg_test_data:
  pg_perxo_api_data:
  pg_access_api_database_2:
  pg_access_api_byplus_database_2:

networks:
  service_network:
    driver: bridge
