#services:
#  www:
#    build: ./devops/php/
#    depends_on:
#      - database
#    container_name: e_batella
#    restart: always
#    ports:
#      - '8000:8000'
#    dns:
#      - 8.8.8.8
#    volumes:
#      - ./:/var/www/
#      - ./var:/var/www/html/var
#    command: "symfony server:start"
#
#    environment:
#      - DATABASE_URL=${DATABASE_URL}
#  database:
#    image: postgres:${POSTGRES_VERSION:-14}-alpine
# #   build:
##      context: ./db/
##      dockerfile: Dockerfile
##    networks:
##      dev:
#    restart: always
#    environment:
#      POSTGRES_HOST: ${POSTGRES_HOST}
#      POSTGRES_DB: ${POSTGRES_DB}
#      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
#      POSTGRES_USER: ${POSTGRES_USER}
#   #   DATABASE_URL: ${DATABASE_URL}
#    container_name: e_database
#    volumes:
#      - ./devops/db/init.sh:/docker-entrypoint-initdb.d/init.sh
#      - db-data:/var/lib/postgresql/data:rw
#
#  rabbitmq:
#    container_name: e_rabbitmq
#    image: rabbitmq:3.9-management
#    ports:
#      - "5672:5672"
#      - "15672:15672"
##    networks:
##      dev:
#  redis:
#    container_name: e_redis
#    image: redis:latest
#    ports:
#      - "6379:6379"
#      - "50949:50949"
##    networks:
##      dev:
##  elk:
##    container_name: elk_events
##    image: sebp/elk
##    volumes:
##      - ./elk/logstash:/etc/logstash
##      - ./elk/logstash/patterns:/opt/logstash/patterns
##      - ./.data/elasticsearch:/var/lib/elasticsearch
#    #          - ./elk/elasticsearch:/etc/elasticsearch # to place elastisearch.yml configuration
##    volumes_from:
##      - php
##      - nginx
##    ports:
##      - "5601:5601"
##      - "9200:9200"
##      - "5044:5044"
#
#
#volumes:
#  db-data:
##networks:
##  dev:
#  #  driver: "bridge"
###
##volumes:
##  db-data:

services:
  postgres:
    image: postgres:${POSTGRES_VERSION:-14}-alpine
#    build:
#      context: ./db/
#      dockerfile: Dockerfile
    restart: always
    environment:
     # POSTGRES_HOST: ${POSTGRES_HOST}
      POSTGRES_DB: ${DATABASE_NAME}
      POSTGRES_PASSWORD: ${DATABASE_PASSWORD}
      POSTGRES_USER: ${DATABASE_USER}
    container_name: ${DATABASE_CONTAINER_NAME}
    volumes:
      - ./docker/db/init.sh:/docker-entrypoint-initdb.d/init.sh
      - db-data:/var/lib/postgresql/batela/data
    networks:
      - mynetwork
#    image: postgres
#    user: "${USER_UID}:${USER_GID}"
#    container_name: "${DATABASE_CONTAINER_NAME}"
#    ports:
#      - "5432:5432"
#    environment:
#      POSTGRES_USER: ${DATABASE_USER}
#      POSTGRES_PASSWORD: ${DATABASE_PASSWORD}
#      POSTGRES_DB: ${DATABASE_NAME}
#    volumes:
#      - ./data/postgres:/var/lib/postgresql/batella/data:rw
#      - ./docker/db/init.sh:/docker-entrypoint-initdb.d/init.sh

#  pgAdmin:
#    restart: always
#    image: dpage/pgadmin4
#    ports:
#      - "7000:80"
#    environment:
#      PGADMIN_DEFAULT_EMAIL: ${PGADMIN_EMAIL}
#      PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_PASSWORD}
#    depends_on:
#      - postgres

  php:
    container_name: "php-fpm"
    command: "symfony console make:migration --no-interaction && symfony console doctrine:migrations:migrate --no-interaction && symfony serve"

    build:
      context: ./docker/php
      args:
        PHP_VERSION: ${PHP_VERSION}
    depends_on:
      - postgres
    environment:
      # Symfony Config
      - APP_ENV=${APP_ENV}
      - APP_SECRET=${APP_SECRET}
      - DATABASE_URL=${DATABASE_URL}
      - MESSENGER_TRANSPORT_DSN=${MESSENGER_TRANSPORT_DSN}
      - APP_DEBUG=${APP_DEBUG}
    networks:
      - mynetwork
    volumes:
      - ${APP_FOLDER}:/var/www
      - ./php/vhosts:/etc/apache2/sites-enabled

#  nginx:
#    container_name: "nginx"
#    environment:
#      HOSTNAME: ${HOSTNAME}
#    build:
#      context: ./docker/nginx
#    volumes:
#      - ${APP_FOLDER}:/var/www
##      - ./nginx.conf:/etc/nginx/nginx.conf
#
#      - ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf
##      - ./logs:/var/log
#    depends_on:
#      - php
#    ports:
#      - "80:80"

volumes:
  db-data:
networks:
  mynetwork: