version: "3.8"

services:
  mariadb_db:
    image: mariadb:12.0.2
    restart: always
    container_name: mariadb_db
    ports:
      - ${DB_PORT}:3306
    environment:
      MYSQL_ROOT_PASSWORD: ${DB_PASS} # obligatorio
      MYSQL_DATABASE: ${DB_NAME}
      MYSQL_USER: ${DB_USER}
      MYSQL_PASSWORD: ${DB_PASS}
    volumes:
      - mariadb_data:/var/lib/mysql
    networks:
      - dokploy-network
  app:
    container_name: ${NAME_APP}
    build:
      context: .
      dockerfile: Dockerfile
      target: development
    ports:
      - "${PORT}:${PORT}"
    environment:
      - NODE_ENV=${NODE_ENV}
      - VITE_ENV=${VITE_ENV}
      - HOST=${HOST}
      - PORT=${PORT}
      - VITE_PORT=${VITE_PORT}
      - VITE_URL=${VITE_URL}
      - JWT_KEY=${JWT_KEY}
      - DB_HOST=${DB_HOST}
      - DB_PORT=${DB_PORT}
      - DB_USER=${DB_USER}
      - DB_PASS=${DB_PASS}
      - DB_NAME=${DB_NAME}
      - MAIL_HOST=${MAIL_HOST}
      - MAIL_PORT=${MAIL_PORT}
      - OPENAI_TOKEN=${OPENAI_TOKEN}
      - MODEL_AI=${MODEL_AI}
      - VITE_HMAC_KEY=${VITE_HMAC_KEY}
    depends_on:
      - mariadb_db
    restart: always
    networks:
      - dokploy-network
    labels:
      - traefik.enable=true
      - traefik.http.routers.${NAME_APP}.rule=Host(`${VITE_URL}`)
      - traefik.http.routers.${NAME_APP}.entrypoints=websecure
      - traefik.http.routers.${NAME_APP}.tls.certResolver=letsencrypt
      - traefik.http.services.${NAME_APP}.loadbalancer.server.port=${PORT}
    volumes:
      - ./:/usr/src/app
      - /usr/src/app/node_modules
#      - public_data:/usr/src/app/public
networks:
  dokploy-network:
    driver: bridge
volumes:
  mariadb_data:
  public_data:
