version: '3'

services:
  laravel-app:
    env_file: .env
    build:
      context: .
      dockerfile: Dockerfile
    container_name: ${CONTAINER_NAME:-pcag-laravel}
    volumes:
      - ${PATH_TO_SITE}:/var/www/html
      - ${PATH_TO_STATIC}:/static
      - ./nginx/default.conf:/etc/nginx/sites-available/default
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf
    environment:
      TZ: UTC
      PUID: ${UID:-1000}
      PGID: ${GID:-1000}
      REDIS_HOST: redis
      DB_HOST: db
      DB_DATABASE: ${LIVE_DB_DATABASE}
      DB_USERNAME: ${LIVE_DB_USERNAME}
      DB_PASSWORD: ${LIVE_DB_PASSWORD}
      LARAVEL_QUEUE_ENABLED: true
      LARAVEL_QUEUE_OPTIONS: --timeout=60 --tries=3 redis
      LARAVEL_SCHEDULE_ENABLED: true
      PHP_OPEN_BASEDIR: "/var/www/html:/static"
    ports:
      - "80:80"
    links:
      - db
      - redis
      - static
  static:
    image: nginx:alpine
    volumes:
      - ./static:/usr/share/nginx/html
    environment:
      TZ: UTC
      PUID: ${UID:-1000}
      PGID: ${GID:-1000}
    ports:
      - "8181:80"
  db:
    image: mariadb:latest
    env_file: .env
    environment:
      TZ: UTC
      MARIADB_ROOT_PASSWORD: ${LIVE_DB_ROOT_PASSWORD}
      MARIADB_USER: ${LIVE_DB_USERNAME}
      MARIADB_DATABASE: ${LIVE_DB_DATABASE}
      MARIADB_PASSWORD: ${LIVE_DB_PASSWORD}
    volumes:
      - "./db/data:/var/lib/mysql"
      - "./db/dump:/docker-entrypoint-initdb.d"
    ports:
      - "3306:3306"
  redis:
    image: redis:latest
    ports:
      - "6379:6379"
  npm:
    image: node:latest
    working_dir: /var/www/html
    entrypoint: ["npm"]
    volumes:
      - ./site:/var/www/html