version: '3.8'

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: gembok-app
    restart: unless-stopped
    working_dir: /var/www
    volumes:
      - ./:/var/www
      - ./docker/php/local.ini:/usr/local/etc/php/conf.d/local.ini
    networks:
      - gembok-network
    depends_on:
      - db
      - redis

  nginx:
    image: nginx:alpine
    container_name: gembok-nginx
    restart: unless-stopped
    ports:
      - "8080:80"
    volumes:
      - ./:/var/www
      - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
    networks:
      - gembok-network
    depends_on:
      - app

  db:
    image: mysql:8.0
    container_name: gembok-db
    restart: unless-stopped
    environment:
      MYSQL_DATABASE: ${DB_DATABASE:-gembok_lara}
      MYSQL_ROOT_PASSWORD: ${DB_PASSWORD:-secret}
      MYSQL_PASSWORD: ${DB_PASSWORD:-secret}
      MYSQL_USER: ${DB_USERNAME:-gembok}
    ports:
      - "3307:3306"
    volumes:
      - gembok-db-data:/var/lib/mysql
    networks:
      - gembok-network

  redis:
    image: redis:alpine
    container_name: gembok-redis
    restart: unless-stopped
    ports:
      - "6380:6379"
    networks:
      - gembok-network

  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    container_name: gembok-pma
    restart: unless-stopped
    environment:
      PMA_HOST: db
      PMA_PORT: 3306
      UPLOAD_LIMIT: 100M
    ports:
      - "8081:80"
    networks:
      - gembok-network
    depends_on:
      - db

networks:
  gembok-network:
    driver: bridge

volumes:
  gembok-db-data:
