services:
  database:
    container_name: ogcore-database
    image: mariadb:10.11
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: ogcore
      MYSQL_PASSWORD: root
      MYSQL_USER: admin
    ports:
      - 3336:3306
    volumes:
      - database_data:/var/lib/mysql
    networks:
      - ogcore-network

  nginx:
    container_name: ogcore-nginx
    build:
      context: .
      dockerfile: ./docker/Dockerfile-nginx
    depends_on:
      - php
    ports:
      - 8080:80
      - 8443:443       # Añadir el puerto 443
    volumes:
      - ./public:/var/www/html/public:cached
      - ./docker/certs:/etc/nginx/certs
      - ./certs:/opt/opengnsys/ogcore/etc/certificates
    networks:
      - ogcore-network

  php:
    container_name: ogcore-php
    build:
      context: .
      dockerfile: ./docker/Dockerfile-php
    volumes:
      - ./:/var/www/html
      - ./certs:/opt/opengnsys/ogcore/etc/certificates
    depends_on:
      - database
    networks:
      - ogcore-network


  mercure:
    image: dunglas/mercure
    restart: unless-stopped
    container_name: ogcore-mercure
    environment:
      # Uncomment the following line to disable HTTPS,
      SERVER_NAME: ':3000'
      MERCURE_PUBLISHER_JWT_KEY: '!ChangeThisMercureHubJWTSecretKey!'
      MERCURE_SUBSCRIBER_JWT_KEY: '!ChangeThisMercureHubJWTSecretKey!'
      MERCURE_EXTRA_DIRECTIVES: |
        cors_origins *
    # Comment the following line to disable the development mode
    command: /usr/bin/caddy run --config /etc/caddy/dev.Caddyfile
    ports:
      - "3000:3000"
    volumes:
      - mercure_data:/data
      - mercure_config:/config
    networks:
      - ogcore-network

volumes:
  mercure_data:
  mercure_config:
  database_data:

networks:
  ogcore-network:
