version: '3.8'

networks:
  kelola-network:
    name: kelola-network
    driver: bridge

services:
  nginx-kelola:
    build:
      context: docker/nginx/
      dockerfile: Dockerfile
    working_dir: /var/www/html
    ports:
      - "80:80"
    networks:
      - kelola-network
    volumes_from:
      - jasper-kelola
    depends_on:
      - jasper-kelola

  jasper-kelola:
    build:
      context: docker/laravel/
      dockerfile: Dockerfile
    command: ["sh", "/var/www/html/docker/laravel/dockerrun.sh"]
    working_dir: /var/www/html
    volumes:
      - ./:/var/www/html
    networks:
      - kelola-network
    environment:
      - DB_CONNECTION=mysql
      - DB_HOST=cloudsql-kelola
      - DB_PORT=3306
      - DB_DATABASE=jasaperantara
      - DB_USERNAME=root
      - DB_PASSWORD=R3@lh4ck3r
    depends_on:
      - cloudsql-kelola

  cloudsql-kelola:
    image: gcr.io/cloud-sql-connectors/cloud-sql-proxy:2.4.0-alpine
    volumes:
      - type: bind
        source: /Users/andreas/.config/gcloud
        target: /home/nonroot/.config/gcloud
        read_only: true
    ports:
      - "3306:3306"
    networks:
      - kelola-network
    command: --address 0.0.0.0 --port 3306 jasa-perantara-jkt:asia-southeast2:jasaperantara-sql
